diff options
| author | Sean Whitton | 2025-10-24 20:55:19 +0100 |
|---|---|---|
| committer | Sean Whitton | 2025-10-24 20:55:19 +0100 |
| commit | d0bcbc7ada3c079b975244801399eecc1261bc97 (patch) | |
| tree | f9701b6a383471934acab0b4e54f32b67b5c9589 | |
| parent | 68e07ef8b22f69e21ca3aa4fca5ef86a7cf0707f (diff) | |
| download | emacs-d0bcbc7ada3c079b975244801399eecc1261bc97.tar.gz emacs-d0bcbc7ada3c079b975244801399eecc1261bc97.zip | |
Make UPSTREAM-LOCATION argument to incoming-revision optional
Using an empty string to mean the location from which vc-update
would pull was inherited from the old incoming/outgoing
functions, but we have opportunity to simplify things for this
new one.
* lisp/vc/vc-bzr.el (vc-bzr-incoming-revision):
* lisp/vc/vc-git.el (vc-git-incoming-revision):
* lisp/vc/vc-hg.el (vc-hg-incoming-revision):
* lisp/vc/vc.el (vc-diff-incoming, vc-diff-outgoing)
(vc-diff-outgoing-base, vc--incoming-revision): Make
UPSTREAM-LOCATION parameter optional. Use nil, rather than an
empty string, to mean the default.
| -rw-r--r-- | lisp/vc/vc-bzr.el | 5 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 10 | ||||
| -rw-r--r-- | lisp/vc/vc-hg.el | 6 | ||||
| -rw-r--r-- | lisp/vc/vc.el | 14 |
4 files changed, 14 insertions, 21 deletions
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index df8005309ce..fb7361120fb 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el | |||
| @@ -822,13 +822,12 @@ If LIMIT is non-nil, show no more than this many entries." | |||
| 822 | (list "--theirs-only" (and (not (string-empty-p upstream-location)) | 822 | (list "--theirs-only" (and (not (string-empty-p upstream-location)) |
| 823 | upstream-location)))) | 823 | upstream-location)))) |
| 824 | 824 | ||
| 825 | (defun vc-bzr-incoming-revision (upstream-location &optional _refresh) | 825 | (defun vc-bzr-incoming-revision (&optional upstream-location _refresh) |
| 826 | (with-temp-buffer | 826 | (with-temp-buffer |
| 827 | (vc-bzr-command "missing" t 1 nil | 827 | (vc-bzr-command "missing" t 1 nil |
| 828 | "--log-format=long" "--show-ids" | 828 | "--log-format=long" "--show-ids" |
| 829 | "--theirs-only" "-r-1.." | 829 | "--theirs-only" "-r-1.." |
| 830 | (and (not (string-empty-p upstream-location)) | 830 | upstream-location) |
| 831 | upstream-location)) | ||
| 832 | (goto-char (point-min)) | 831 | (goto-char (point-min)) |
| 833 | (and (re-search-forward "^revision-id: " nil t) | 832 | (and (re-search-forward "^revision-id: " nil t) |
| 834 | (buffer-substring (point) (pos-eol))))) | 833 | (buffer-substring (point) (pos-eol))))) |
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 1a4e10ea9f2..2524becafe4 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -70,7 +70,7 @@ | |||
| 70 | ;; - get-change-comment (files rev) OK | 70 | ;; - get-change-comment (files rev) OK |
| 71 | ;; HISTORY FUNCTIONS | 71 | ;; HISTORY FUNCTIONS |
| 72 | ;; * print-log (files buffer &optional shortlog start-revision limit) OK | 72 | ;; * print-log (files buffer &optional shortlog start-revision limit) OK |
| 73 | ;; * incoming-revision (upstream-location &optional refresh) OK | 73 | ;; * incoming-revision (&optional upstream-location refresh) OK |
| 74 | ;; - log-search (buffer pattern) OK | 74 | ;; - log-search (buffer pattern) OK |
| 75 | ;; - log-view-mode () OK | 75 | ;; - log-view-mode () OK |
| 76 | ;; - show-log-entry (revision) OK | 76 | ;; - show-log-entry (revision) OK |
| @@ -1741,13 +1741,11 @@ If LIMIT is a non-empty string, use it as a base revision." | |||
| 1741 | start-revision)) | 1741 | start-revision)) |
| 1742 | '("--"))))))) | 1742 | '("--"))))))) |
| 1743 | 1743 | ||
| 1744 | (defun vc-git-incoming-revision (upstream-location &optional refresh) | 1744 | (defun vc-git-incoming-revision (&optional upstream-location refresh) |
| 1745 | (let ((rev (if (string-empty-p upstream-location) | 1745 | (let ((rev (or upstream-location "@{upstream}"))) |
| 1746 | "@{upstream}" | ||
| 1747 | upstream-location))) | ||
| 1748 | (when (or refresh (null (vc-git--rev-parse rev))) | 1746 | (when (or refresh (null (vc-git--rev-parse rev))) |
| 1749 | (vc-git-command nil 0 nil "fetch" | 1747 | (vc-git-command nil 0 nil "fetch" |
| 1750 | (and (not (string-empty-p upstream-location)) | 1748 | (and upstream-location |
| 1751 | ;; Extract remote from "remote/branch". | 1749 | ;; Extract remote from "remote/branch". |
| 1752 | (replace-regexp-in-string "/.*" "" | 1750 | (replace-regexp-in-string "/.*" "" |
| 1753 | upstream-location)))) | 1751 | upstream-location)))) |
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index fe977df6aae..4349e21ef7a 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el | |||
| @@ -1549,10 +1549,8 @@ This runs the command \"hg summary\"." | |||
| 1549 | (nreverse result)) | 1549 | (nreverse result)) |
| 1550 | "\n")))) | 1550 | "\n")))) |
| 1551 | 1551 | ||
| 1552 | (defun vc-hg-incoming-revision (upstream-location &optional _refresh) | 1552 | (defun vc-hg-incoming-revision (&optional upstream-location _refresh) |
| 1553 | (let* ((upstream-location (if (string-empty-p upstream-location) | 1553 | (let* ((upstream-location (or upstream-location "default")) |
| 1554 | "default" | ||
| 1555 | upstream-location)) | ||
| 1556 | ;; Use 'hg identify' like this, and not 'hg incoming', because | 1554 | ;; Use 'hg identify' like this, and not 'hg incoming', because |
| 1557 | ;; this will give a sensible answer regardless of whether the | 1555 | ;; this will give a sensible answer regardless of whether the |
| 1558 | ;; incoming revision has been pulled yet. | 1556 | ;; incoming revision has been pulled yet. |
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index bc43239354e..d0c86ba1201 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el | |||
| @@ -427,9 +427,10 @@ | |||
| 427 | ;; received when performing a pull operation from UPSTREAM-LOCATION. | 427 | ;; received when performing a pull operation from UPSTREAM-LOCATION. |
| 428 | ;; Deprecated: implement incoming-revision and mergebase instead. | 428 | ;; Deprecated: implement incoming-revision and mergebase instead. |
| 429 | ;; | 429 | ;; |
| 430 | ;; * incoming-revision (upstream-location &optional refresh) | 430 | ;; * incoming-revision (&optional upstream-location refresh) |
| 431 | ;; | 431 | ;; |
| 432 | ;; Return revision at the head of the branch at UPSTREAM-LOCATION. | 432 | ;; Return revision at the head of the branch at UPSTREAM-LOCATION. |
| 433 | ;; UPSTREAM-LOCATION defaults to where `vc-update' would pull from. | ||
| 433 | ;; If there is no such branch there, return nil. (Should signal an | 434 | ;; If there is no such branch there, return nil. (Should signal an |
| 434 | ;; error, not return nil, in the case that fetching data fails.) | 435 | ;; error, not return nil, in the case that fetching data fails.) |
| 435 | ;; For a distributed VCS, should also fetch that revision into local | 436 | ;; For a distributed VCS, should also fetch that revision into local |
| @@ -2752,8 +2753,7 @@ global binding." | |||
| 2752 | (let* ((fileset (or fileset (vc-deduce-fileset t))) | 2753 | (let* ((fileset (or fileset (vc-deduce-fileset t))) |
| 2753 | (backend (car fileset)) | 2754 | (backend (car fileset)) |
| 2754 | (incoming (vc--incoming-revision backend | 2755 | (incoming (vc--incoming-revision backend |
| 2755 | (or upstream-location "") | 2756 | upstream-location 'refresh))) |
| 2756 | 'refresh))) | ||
| 2757 | (vc-diff-internal vc-allow-async-diff fileset | 2757 | (vc-diff-internal vc-allow-async-diff fileset |
| 2758 | (vc-call-backend backend 'mergebase incoming) | 2758 | (vc-call-backend backend 'mergebase incoming) |
| 2759 | incoming | 2759 | incoming |
| @@ -2799,8 +2799,7 @@ global binding." | |||
| 2799 | (interactive (list (vc--maybe-read-upstream-location))) | 2799 | (interactive (list (vc--maybe-read-upstream-location))) |
| 2800 | (let* ((fileset (or fileset (vc-deduce-fileset t))) | 2800 | (let* ((fileset (or fileset (vc-deduce-fileset t))) |
| 2801 | (backend (car fileset)) | 2801 | (backend (car fileset)) |
| 2802 | (incoming (vc--incoming-revision backend | 2802 | (incoming (vc--incoming-revision backend upstream-location))) |
| 2803 | (or upstream-location "")))) | ||
| 2804 | (vc-diff-internal vc-allow-async-diff fileset | 2803 | (vc-diff-internal vc-allow-async-diff fileset |
| 2805 | (vc-call-backend backend 'mergebase incoming) | 2804 | (vc-call-backend backend 'mergebase incoming) |
| 2806 | ;; FIXME: In order to exclude uncommitted | 2805 | ;; FIXME: In order to exclude uncommitted |
| @@ -2885,8 +2884,7 @@ includes uncommitted changes." | |||
| 2885 | (interactive (list (vc--maybe-read-upstream-location) nil)) | 2884 | (interactive (list (vc--maybe-read-upstream-location) nil)) |
| 2886 | (let* ((fileset (or fileset (vc-deduce-fileset t))) | 2885 | (let* ((fileset (or fileset (vc-deduce-fileset t))) |
| 2887 | (backend (car fileset)) | 2886 | (backend (car fileset)) |
| 2888 | (incoming (vc--incoming-revision backend | 2887 | (incoming (vc--incoming-revision backend upstream-location))) |
| 2889 | (or upstream-location "")))) | ||
| 2890 | (vc-diff-internal vc-allow-async-diff fileset | 2888 | (vc-diff-internal vc-allow-async-diff fileset |
| 2891 | (vc-call-backend backend 'mergebase incoming) | 2889 | (vc-call-backend backend 'mergebase incoming) |
| 2892 | nil | 2890 | nil |
| @@ -3744,7 +3742,7 @@ The command prompts for the branch whose change log to show." | |||
| 3744 | (read-string "Upstream location/branch (empty for default): " nil | 3742 | (read-string "Upstream location/branch (empty for default): " nil |
| 3745 | 'vc-remote-location-history))) | 3743 | 'vc-remote-location-history))) |
| 3746 | 3744 | ||
| 3747 | (defun vc--incoming-revision (backend upstream-location &optional refresh) | 3745 | (defun vc--incoming-revision (backend &optional upstream-location refresh) |
| 3748 | (or (vc-call-backend backend 'incoming-revision upstream-location refresh) | 3746 | (or (vc-call-backend backend 'incoming-revision upstream-location refresh) |
| 3749 | (user-error "No incoming revision -- local-only branch?"))) | 3747 | (user-error "No incoming revision -- local-only branch?"))) |
| 3750 | 3748 | ||