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." (list "--theirs-only" (and (not (string-empty-p upstream-location)) upstream-location)))) -(defun vc-bzr-incoming-revision (upstream-location &optional _refresh) +(defun vc-bzr-incoming-revision (&optional upstream-location _refresh) (with-temp-buffer (vc-bzr-command "missing" t 1 nil "--log-format=long" "--show-ids" "--theirs-only" "-r-1.." - (and (not (string-empty-p upstream-location)) - upstream-location)) + upstream-location) (goto-char (point-min)) (and (re-search-forward "^revision-id: " nil t) (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 @@ ;; - get-change-comment (files rev) OK ;; HISTORY FUNCTIONS ;; * print-log (files buffer &optional shortlog start-revision limit) OK -;; * incoming-revision (upstream-location &optional refresh) OK +;; * incoming-revision (&optional upstream-location refresh) OK ;; - log-search (buffer pattern) OK ;; - log-view-mode () OK ;; - show-log-entry (revision) OK @@ -1741,13 +1741,11 @@ If LIMIT is a non-empty string, use it as a base revision." start-revision)) '("--"))))))) -(defun vc-git-incoming-revision (upstream-location &optional refresh) - (let ((rev (if (string-empty-p upstream-location) - "@{upstream}" - upstream-location))) +(defun vc-git-incoming-revision (&optional upstream-location refresh) + (let ((rev (or upstream-location "@{upstream}"))) (when (or refresh (null (vc-git--rev-parse rev))) (vc-git-command nil 0 nil "fetch" - (and (not (string-empty-p upstream-location)) + (and upstream-location ;; Extract remote from "remote/branch". (replace-regexp-in-string "/.*" "" 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\"." (nreverse result)) "\n")))) -(defun vc-hg-incoming-revision (upstream-location &optional _refresh) - (let* ((upstream-location (if (string-empty-p upstream-location) - "default" - upstream-location)) +(defun vc-hg-incoming-revision (&optional upstream-location _refresh) + (let* ((upstream-location (or upstream-location "default")) ;; Use 'hg identify' like this, and not 'hg incoming', because ;; this will give a sensible answer regardless of whether the ;; 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 @@ ;; received when performing a pull operation from UPSTREAM-LOCATION. ;; Deprecated: implement incoming-revision and mergebase instead. ;; -;; * incoming-revision (upstream-location &optional refresh) +;; * incoming-revision (&optional upstream-location refresh) ;; ;; Return revision at the head of the branch at UPSTREAM-LOCATION. +;; UPSTREAM-LOCATION defaults to where `vc-update' would pull from. ;; If there is no such branch there, return nil. (Should signal an ;; error, not return nil, in the case that fetching data fails.) ;; For a distributed VCS, should also fetch that revision into local @@ -2752,8 +2753,7 @@ global binding." (let* ((fileset (or fileset (vc-deduce-fileset t))) (backend (car fileset)) (incoming (vc--incoming-revision backend - (or upstream-location "") - 'refresh))) + upstream-location 'refresh))) (vc-diff-internal vc-allow-async-diff fileset (vc-call-backend backend 'mergebase incoming) incoming @@ -2799,8 +2799,7 @@ global binding." (interactive (list (vc--maybe-read-upstream-location))) (let* ((fileset (or fileset (vc-deduce-fileset t))) (backend (car fileset)) - (incoming (vc--incoming-revision backend - (or upstream-location "")))) + (incoming (vc--incoming-revision backend upstream-location))) (vc-diff-internal vc-allow-async-diff fileset (vc-call-backend backend 'mergebase incoming) ;; FIXME: In order to exclude uncommitted @@ -2885,8 +2884,7 @@ includes uncommitted changes." (interactive (list (vc--maybe-read-upstream-location) nil)) (let* ((fileset (or fileset (vc-deduce-fileset t))) (backend (car fileset)) - (incoming (vc--incoming-revision backend - (or upstream-location "")))) + (incoming (vc--incoming-revision backend upstream-location))) (vc-diff-internal vc-allow-async-diff fileset (vc-call-backend backend 'mergebase incoming) nil @@ -3744,7 +3742,7 @@ The command prompts for the branch whose change log to show." (read-string "Upstream location/branch (empty for default): " nil 'vc-remote-location-history))) -(defun vc--incoming-revision (backend upstream-location &optional refresh) +(defun vc--incoming-revision (backend &optional upstream-location refresh) (or (vc-call-backend backend 'incoming-revision upstream-location refresh) (user-error "No incoming revision -- local-only branch?")))