aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2025-07-03 20:21:29 +0100
committerSean Whitton2025-07-03 20:53:24 +0100
commit8c6d549f6ffd623e30fef9aeb73ccb1194bcfb58 (patch)
treef761371a46f8d584a7ff1eeb199491becd47dafa
parentf1fe815b43c87b147e3e6cc5cd600cd66cc65b7f (diff)
downloademacs-8c6d549f6ffd623e30fef9aeb73ccb1194bcfb58.tar.gz
emacs-8c6d549f6ffd623e30fef9aeb73ccb1194bcfb58.zip
Factor out some common code from VC incoming/outgoing functions
* lisp/vc/vc.el (vc--maybe-read-remote-location) (vc--incoming-revision): New functions, factored out. (vc-log-incoming, vc-default-log-incoming, vc-log-outgoing) (vc-default-log-outgoing): Use them.
-rw-r--r--lisp/vc/vc.el26
1 files changed, 12 insertions, 14 deletions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 07a8ddb5706..bd2c67fc29e 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -3294,24 +3294,27 @@ The command prompts for the branch whose change log to show."
3294 (list rootdir) branch t 3294 (list rootdir) branch t
3295 (when (> vc-log-show-limit 0) vc-log-show-limit)))) 3295 (when (> vc-log-show-limit 0) vc-log-show-limit))))
3296 3296
3297(defun vc--maybe-read-remote-location ()
3298 (and current-prefix-arg
3299 (list (read-string "Remote location/branch (empty for default): "))))
3300
3301(defun vc--incoming-revision (backend remote-location)
3302 (or (vc-call-backend backend 'incoming-revision remote-location)
3303 (user-error "No incoming revision -- local-only branch?")))
3304
3297;;;###autoload 3305;;;###autoload
3298(defun vc-log-incoming (&optional remote-location) 3306(defun vc-log-incoming (&optional remote-location)
3299 "Show log of changes that will be received with pull from REMOTE-LOCATION. 3307 "Show log of changes that will be received with pull from REMOTE-LOCATION.
3300When called interactively with a prefix argument, prompt for REMOTE-LOCATION. 3308When called interactively with a prefix argument, prompt for REMOTE-LOCATION.
3301In some version control systems REMOTE-LOCATION can be a remote branch name." 3309In some version control systems REMOTE-LOCATION can be a remote branch name."
3302 (interactive 3310 (interactive (vc--maybe-read-remote-location))
3303 (when current-prefix-arg
3304 (list (read-string "Remote location/branch (empty for default): "))))
3305 (vc--with-backend-in-rootdir "VC root-log" 3311 (vc--with-backend-in-rootdir "VC root-log"
3306 (vc-incoming-outgoing-internal backend (or remote-location "") 3312 (vc-incoming-outgoing-internal backend (or remote-location "")
3307 "*vc-incoming*" 'log-incoming))) 3313 "*vc-incoming*" 'log-incoming)))
3308 3314
3309(defun vc-default-log-incoming (_backend buffer remote-location) 3315(defun vc-default-log-incoming (_backend buffer remote-location)
3310 (vc--with-backend-in-rootdir "" 3316 (vc--with-backend-in-rootdir ""
3311 (let ((incoming (or (vc-call-backend backend 3317 (let ((incoming (vc--incoming-revision backend remote-location)))
3312 'incoming-revision
3313 remote-location)
3314 (user-error "No incoming revision -- local-only branch?"))))
3315 (vc-call-backend backend 'print-log (list rootdir) buffer t 3318 (vc-call-backend backend 'print-log (list rootdir) buffer t
3316 incoming 3319 incoming
3317 (vc-call-backend backend 'mergebase incoming))))) 3320 (vc-call-backend backend 'mergebase incoming)))))
@@ -3321,19 +3324,14 @@ In some version control systems REMOTE-LOCATION can be a remote branch name."
3321 "Show log of changes that will be sent with a push operation to REMOTE-LOCATION. 3324 "Show log of changes that will be sent with a push operation to REMOTE-LOCATION.
3322When called interactively with a prefix argument, prompt for REMOTE-LOCATION. 3325When called interactively with a prefix argument, prompt for REMOTE-LOCATION.
3323In some version control systems REMOTE-LOCATION can be a remote branch name." 3326In some version control systems REMOTE-LOCATION can be a remote branch name."
3324 (interactive 3327 (interactive (vc--maybe-read-remote-location))
3325 (when current-prefix-arg
3326 (list (read-string "Remote location/branch (empty for default): "))))
3327 (vc--with-backend-in-rootdir "VC root-log" 3328 (vc--with-backend-in-rootdir "VC root-log"
3328 (vc-incoming-outgoing-internal backend (or remote-location "") 3329 (vc-incoming-outgoing-internal backend (or remote-location "")
3329 "*vc-outgoing*" 'log-outgoing))) 3330 "*vc-outgoing*" 'log-outgoing)))
3330 3331
3331(defun vc-default-log-outgoing (_backend buffer remote-location) 3332(defun vc-default-log-outgoing (_backend buffer remote-location)
3332 (vc--with-backend-in-rootdir "" 3333 (vc--with-backend-in-rootdir ""
3333 (let ((incoming (or (vc-call-backend backend 3334 (let ((incoming (vc--incoming-revision backend remote-location)))
3334 'incoming-revision
3335 remote-location)
3336 (user-error "No incoming revision -- local-only branch?"))))
3337 (vc-call-backend backend 'print-log (list rootdir) buffer t 3335 (vc-call-backend backend 'print-log (list rootdir) buffer t
3338 "" 3336 ""
3339 (vc-call-backend backend 'mergebase incoming))))) 3337 (vc-call-backend backend 'mergebase incoming)))))