master b49da1b7e0e: vc-git, vc-hg log outgoing: Avoid unnecessary mergebase calls
Sean Whitton <[email protected]>
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: master commit b49da1b7e0e639092edff2959720b4df4b86fcc2 Author: Sean Whitton <[email protected]> Commit: Sean Whitton <[email protected]> vc-git, vc-hg log outgoing: Avoid unnecessary mergebase calls * lisp/vc/vc.el (vc-standard-log-outgoing): New function. (vc-default-log-outgoing): * lisp/vc/vc-git.el (vc-git-log-outgoing): * lisp/vc/vc-hg.el (vc-hg-log-outgoing): Use it. --- lisp/vc/vc-git.el | 5 +++++ lisp/vc/vc-hg.el | 5 +++++ lisp/vc/vc.el | 28 +++++++++++++++++++++++----- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index e68945cda8d..312abcbb975 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -909,6 +909,11 @@ them one-by-one, accepting the first that has an upstream.)" (when-let* ((upstream (branch-upstream target))) (throw 'ret upstream)))))))))) +(declare-function vc-standard-log-outgoing "vc") + +(defun vc-git-log-outgoing (buffer upstream-location) + (vc-standard-log-outgoing 'Git buffer upstream-location 'skip-mergebase)) + (defun vc-git-dir--branch-headers () "Return headers for branch-related information." (let ((branch (vc-git-working-branch)) diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 0fa22d97fad..c00723af102 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -2015,6 +2015,11 @@ This is based on the following assumptions: (ii) there is only one remote head for the current branch." (cdr (assq 'branch (vc-hg--working-branch)))) +(declare-function vc-standard-log-outgoing "vc") + +(defun vc-hg-log-outgoing (buffer upstream-location) + (vc-standard-log-outgoing 'Hg buffer upstream-location 'skip-mergebase)) + (provide 'vc-hg) ;;; vc-hg.el ends here diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index ddac5724f63..46715d01693 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -460,17 +460,21 @@ ;; revision shown, rather than the working revision, which is normally ;; the case). Not all backends support this. ;; -;; - log-outgoing (buffer upstream-location) (DEPRECATED) +;; - log-outgoing (buffer upstream-location) (SOFT DEPRECATED) ;; ;; Insert in BUFFER the revision log for the changes that will be ;; sent when performing a push operation to UPSTREAM-LOCATION. -;; Deprecated: implement incoming-revision and mergebase instead. +;; Deprecated: implement incoming-revision and mergebase instead, +;; unless what `vc-default-log-outgoing' does with those is too slow +;; for this backend. ;; -;; - log-incoming (buffer upstream-location) (DEPRECATED) +;; - log-incoming (buffer upstream-location) (SOFT DEPRECATED) ;; ;; Insert in BUFFER the revision log for the changes that will be ;; received when performing a pull operation from UPSTREAM-LOCATION. -;; Deprecated: implement incoming-revision and mergebase instead. +;; Deprecated: implement incoming-revision and mergebase instead, +;; unless what `vc-default-log-incoming' does with those is too slow +;; for this backend. ;; ;; * incoming-revision (&optional upstream-location refresh) ;; @@ -4710,11 +4714,25 @@ can be a remote branch name." "31.1") (defun vc-default-log-outgoing (backend buffer upstream-location) + (vc-standard-log-outgoing backend buffer upstream-location nil)) + +(defun vc-standard-log-outgoing + (backend buffer upstream-location &optional skip-mergebase) + "VC `log-outgoing' in terms of `incoming-revision' and `mergebase'. +BACKEND is the VC backend, BUFFER is the buffer to log to, +UPSTREAM-LOCATION is the place to which the changes are outgoing. +Optional argument SKIP-MERGEBASE, if non-nil, skips calling `mergebase' +and instead passes `incoming-revision' directly as the log limit. +For some backends this is equivalent, and saves running one external +command. Whether this equivalence holds depends on the details of the +`print-log' implementation for BACKEND when `vc-log-view-types' contains +`log-outgoing'." (let ((incoming (vc--incoming-revision backend upstream-location)) (default-directory (vc-root-dir backend))) (vc-call-backend backend 'print-log (list default-directory) buffer t "" - (vc-call-backend backend 'mergebase incoming)))) + (if skip-mergebase incoming + (vc-call-backend backend 'mergebase incoming))))) ;;;###autoload (defun vc-log-search (pattern)