diff options
| author | Sean Whitton | 2025-08-17 11:36:13 +0100 |
|---|---|---|
| committer | Sean Whitton | 2025-08-17 11:36:30 +0100 |
| commit | da3973b657db46501e650fb4af4a4f3bb07c77fd (patch) | |
| tree | 4266aef001ec7211db151a2916cfe7d6334d1166 | |
| parent | 70b5ad0192b2dd6232c1961b49e94a6620d02152 (diff) | |
| download | emacs-da3973b657db46501e650fb4af4a4f3bb07c77fd.tar.gz emacs-da3973b657db46501e650fb4af4a4f3bb07c77fd.zip | |
VC: New commands for incoming and outgoing fileset diffs
* lisp/vc/vc.el (vc-fileset-diff-incoming)
(vc-fileset-diff-outgoing): New commands.
(vc-root-diff-incoming): Refactor to call
vc-fileset-diff-incoming.
(vc-root-diff-outgoing): Refactor to call
vc-fileset-diff-outgoing.
* lisp/vc/vc-hooks.el (vc-incoming-prefix-map)
(vc-outgoing-prefix-map): Bind the new commands.
* doc/emacs/maintaining.texi (VC Change Log):
* etc/NEWS: Document the new commands.
| -rw-r--r-- | doc/emacs/maintaining.texi | 31 | ||||
| -rw-r--r-- | etc/NEWS | 12 | ||||
| -rw-r--r-- | lisp/vc/vc-hooks.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc.el | 102 |
4 files changed, 103 insertions, 44 deletions
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index ffa3b7f2a58..4e531805f26 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi | |||
| @@ -1070,11 +1070,18 @@ non-@code{nil}, @kbd{C-x v I} becomes a prefix key, and | |||
| 1070 | @code{vc-log-incoming} becomes bound to @kbd{C-x v I L}. | 1070 | @code{vc-log-incoming} becomes bound to @kbd{C-x v I L}. |
| 1071 | 1071 | ||
| 1072 | @item M-x vc-root-diff-incoming | 1072 | @item M-x vc-root-diff-incoming |
| 1073 | Display a diff of the changes that a pull operation will retrieve. | 1073 | Display a diff of all changes that a pull operation will retrieve. |
| 1074 | 1074 | ||
| 1075 | If you customize @code{vc-use-incoming-outgoing-prefixes} to | 1075 | If you customize @code{vc-use-incoming-outgoing-prefixes} to |
| 1076 | non-@code{nil}, this command becomes available on @kbd{C-x v I D}. | 1076 | non-@code{nil}, this command becomes available on @kbd{C-x v I D}. |
| 1077 | 1077 | ||
| 1078 | @item M-x vc-fileset-diff-incoming | ||
| 1079 | Display a diff of changes that a pull operation will retrieve, but | ||
| 1080 | limited to the current fileset. | ||
| 1081 | |||
| 1082 | If you customize @code{vc-use-incoming-outgoing-prefixes} to | ||
| 1083 | non-@code{nil}, this command becomes available on @kbd{C-x v I =}. | ||
| 1084 | |||
| 1078 | @item C-x v O | 1085 | @item C-x v O |
| 1079 | Display log entries for the changes that will be sent by the next | 1086 | Display log entries for the changes that will be sent by the next |
| 1080 | ``push'' operation (@code{vc-log-outgoing}). | 1087 | ``push'' operation (@code{vc-log-outgoing}). |
| @@ -1084,12 +1091,19 @@ non-@code{nil}, @kbd{C-x v O} becomes a prefix key, and | |||
| 1084 | @code{vc-log-outgoing} becomes bound to @kbd{C-x v O L}. | 1091 | @code{vc-log-outgoing} becomes bound to @kbd{C-x v O L}. |
| 1085 | 1092 | ||
| 1086 | @item M-x vc-root-diff-outgoing | 1093 | @item M-x vc-root-diff-outgoing |
| 1087 | Display a diff of the changes that will be sent by the next push | 1094 | Display a diff of all changes that will be sent by the next push |
| 1088 | operation. | 1095 | operation. |
| 1089 | 1096 | ||
| 1090 | If you customize @code{vc-use-incoming-outgoing-prefixes} to | 1097 | If you customize @code{vc-use-incoming-outgoing-prefixes} to |
| 1091 | non-@code{nil}, this command is bound to @kbd{C-x v O D}. | 1098 | non-@code{nil}, this command is bound to @kbd{C-x v O D}. |
| 1092 | 1099 | ||
| 1100 | @item M-x vc-fileset-diff-outgoing | ||
| 1101 | Display a diff of changes that will be sent by the next push operation, | ||
| 1102 | but limited to the current fileset. | ||
| 1103 | |||
| 1104 | If you customize @code{vc-use-incoming-outgoing-prefixes} to | ||
| 1105 | non-@code{nil}, this command becomes available on @kbd{C-x v O =}. | ||
| 1106 | |||
| 1093 | @item C-x v h | 1107 | @item C-x v h |
| 1094 | Display the history of changes made in the region of file visited by | 1108 | Display the history of changes made in the region of file visited by |
| 1095 | the current buffer (@code{vc-region-history}). | 1109 | the current buffer (@code{vc-region-history}). |
| @@ -1176,13 +1190,22 @@ version control system can be a branch name. | |||
| 1176 | @findex vc-root-diff-outgoing | 1190 | @findex vc-root-diff-outgoing |
| 1177 | The closely related commands @code{vc-root-diff-incoming} and | 1191 | The closely related commands @code{vc-root-diff-incoming} and |
| 1178 | @code{vc-root-diff-outgoing} are the diff analogues of | 1192 | @code{vc-root-diff-outgoing} are the diff analogues of |
| 1179 | @code{vc-log-incoming} and @code{vc-log-outgoing}. These display a diff | 1193 | @code{vc-log-incoming} and @code{vc-log-outgoing}. These display diff |
| 1180 | buffer reporting the changes that would be pulled or pushed. You can | 1194 | buffers reporting the changes that would be pulled or pushed. You can |
| 1181 | use a prefix argument here too to specify a particular remote location. | 1195 | use a prefix argument here too to specify a particular remote location. |
| 1182 | @code{vc-root-diff-outgoing} is useful as a way to preview your push and | 1196 | @code{vc-root-diff-outgoing} is useful as a way to preview your push and |
| 1183 | quickly check that all and only the changes you intended to include were | 1197 | quickly check that all and only the changes you intended to include were |
| 1184 | committed and will be pushed. | 1198 | committed and will be pushed. |
| 1185 | 1199 | ||
| 1200 | @findex vc-fileset-diff-incoming | ||
| 1201 | @findex vc-fileset-diff-outgoing | ||
| 1202 | The commands @code{vc-fileset-diff-incoming} and | ||
| 1203 | @code{vc-fileset-diff-outgoing} are very similar. They also display | ||
| 1204 | changes that would be pulled or pushed. The difference is that the | ||
| 1205 | diffs reported are limited to the current fileset. Don't forget that | ||
| 1206 | actual pull and push operations always affect the whole working tree, | ||
| 1207 | not just the current fileset. | ||
| 1208 | |||
| 1186 | @cindex VC log buffer, commands in | 1209 | @cindex VC log buffer, commands in |
| 1187 | @cindex vc-log buffer | 1210 | @cindex vc-log buffer |
| 1188 | In the @file{*vc-change-log*} buffer, you can use the following keys | 1211 | In the @file{*vc-change-log*} buffer, you can use the following keys |
| @@ -2131,15 +2131,19 @@ relevant buffers before generating the contents of a VC Directory buffer | |||
| 2131 | (like the third-party package Magit does with its status buffer). | 2131 | (like the third-party package Magit does with its status buffer). |
| 2132 | 2132 | ||
| 2133 | +++ | 2133 | +++ |
| 2134 | *** New commands 'vc-root-diff-incoming' and 'vc-root-diff-outgoing'. | 2134 | *** New commands to report incoming and outgoing diffs. |
| 2135 | These commands report diffs of all the changes that would be pulled and | 2135 | 'vc-root-diff-incoming' and 'vc-root-diff-outgoing' report diffs of all |
| 2136 | would be pushed, respectively. They are the diff analogues of the | 2136 | the changes that would be pulled and would be pushed, respectively. |
| 2137 | existing commands 'vc-log-incoming' and 'vc-log-outgoing'. | 2137 | They are the diff analogues of the existing commands 'vc-log-incoming' |
| 2138 | and 'vc-log-outgoing'. | ||
| 2138 | 2139 | ||
| 2139 | In particular, 'vc-root-diff-outgoing' is useful as a way to preview | 2140 | In particular, 'vc-root-diff-outgoing' is useful as a way to preview |
| 2140 | your push and ensure that all and only the changes you intended to | 2141 | your push and ensure that all and only the changes you intended to |
| 2141 | include were committed and will be pushed. | 2142 | include were committed and will be pushed. |
| 2142 | 2143 | ||
| 2144 | 'vc-fileset-diff-incoming' and 'vc-fileset-diff-outgoing' are similar | ||
| 2145 | but limited to the current VC fileset. | ||
| 2146 | |||
| 2143 | +++ | 2147 | +++ |
| 2144 | *** New user option 'vc-use-incoming-outgoing-prefixes'. | 2148 | *** New user option 'vc-use-incoming-outgoing-prefixes'. |
| 2145 | If this is customized to non-nil, 'C-x v I' and 'C-x v O' become prefix | 2149 | If this is customized to non-nil, 'C-x v I' and 'C-x v O' become prefix |
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 7d46f9f0ee3..e3b2d207156 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el | |||
| @@ -976,9 +976,11 @@ In the latter case, VC mode is deactivated for this buffer." | |||
| 976 | 976 | ||
| 977 | (defvar-keymap vc-incoming-prefix-map | 977 | (defvar-keymap vc-incoming-prefix-map |
| 978 | "L" #'vc-log-incoming | 978 | "L" #'vc-log-incoming |
| 979 | "=" #'vc-fileset-diff-incoming | ||
| 979 | "D" #'vc-root-diff-incoming) | 980 | "D" #'vc-root-diff-incoming) |
| 980 | (defvar-keymap vc-outgoing-prefix-map | 981 | (defvar-keymap vc-outgoing-prefix-map |
| 981 | "L" #'vc-log-outgoing | 982 | "L" #'vc-log-outgoing |
| 983 | "=" #'vc-fileset-diff-outgoing | ||
| 982 | "D" #'vc-root-diff-outgoing) | 984 | "D" #'vc-root-diff-outgoing) |
| 983 | 985 | ||
| 984 | (defcustom vc-use-incoming-outgoing-prefixes nil | 986 | (defcustom vc-use-incoming-outgoing-prefixes nil |
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 73f4f5d6f1d..6f8985dc0c9 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el | |||
| @@ -2546,12 +2546,27 @@ See `vc-use-incoming-outgoing-prefixes' regarding giving this command a | |||
| 2546 | global binding." | 2546 | global binding." |
| 2547 | (interactive (list (vc--maybe-read-remote-location))) | 2547 | (interactive (list (vc--maybe-read-remote-location))) |
| 2548 | (vc--with-backend-in-rootdir "VC root-diff" | 2548 | (vc--with-backend-in-rootdir "VC root-diff" |
| 2549 | (let ((incoming (vc--incoming-revision backend | 2549 | (vc-fileset-diff-incoming remote-location `(,backend (,rootdir))))) |
| 2550 | (or remote-location "")))) | 2550 | |
| 2551 | (vc-diff-internal vc-allow-async-diff (list backend (list rootdir)) | 2551 | ;;;###autoload |
| 2552 | (vc-call-backend backend 'mergebase incoming) | 2552 | (defun vc-fileset-diff-incoming (&optional remote-location fileset) |
| 2553 | incoming | 2553 | "Report changes to VC fileset that would be pulled from REMOTE-LOCATION. |
| 2554 | (called-interactively-p 'interactive))))) | 2554 | When unspecified REMOTE-LOCATION is the place \\[vc-update] would pull from. |
| 2555 | When called interactively with a prefix argument, prompt for REMOTE-LOCATION. | ||
| 2556 | In some version control systems REMOTE-LOCATION can be a remote branch name. | ||
| 2557 | When called from Lisp optional argument FILESET overrides the VC fileset. | ||
| 2558 | |||
| 2559 | See `vc-use-incoming-outgoing-prefixes' regarding giving this command a | ||
| 2560 | global binding." | ||
| 2561 | (interactive (list (vc--maybe-read-remote-location) nil)) | ||
| 2562 | (let* ((fileset (or fileset (vc-deduce-fileset t))) | ||
| 2563 | (backend (car fileset)) | ||
| 2564 | (incoming (vc--incoming-revision backend | ||
| 2565 | (or remote-location "")))) | ||
| 2566 | (vc-diff-internal vc-allow-async-diff fileset | ||
| 2567 | (vc-call-backend backend 'mergebase incoming) | ||
| 2568 | incoming | ||
| 2569 | (called-interactively-p 'interactive)))) | ||
| 2555 | 2570 | ||
| 2556 | ;;;###autoload | 2571 | ;;;###autoload |
| 2557 | (defun vc-root-diff-outgoing (&optional remote-location) | 2572 | (defun vc-root-diff-outgoing (&optional remote-location) |
| @@ -2562,42 +2577,57 @@ In some version control systems REMOTE-LOCATION can be a remote branch name. | |||
| 2562 | 2577 | ||
| 2563 | See `vc-use-incoming-outgoing-prefixes' regarding giving this command a | 2578 | See `vc-use-incoming-outgoing-prefixes' regarding giving this command a |
| 2564 | global binding." | 2579 | global binding." |
| 2580 | (interactive (list (vc--maybe-read-remote-location))) | ||
| 2581 | (vc--with-backend-in-rootdir "VC root-diff" | ||
| 2582 | (vc-fileset-diff-outgoing remote-location `(,backend (,rootdir))))) | ||
| 2583 | |||
| 2584 | ;;;###autoload | ||
| 2585 | (defun vc-fileset-diff-outgoing (&optional remote-location fileset) | ||
| 2586 | "Report changes to VC fileset that would be pushed to REMOTE-LOCATION. | ||
| 2587 | When unspecified REMOTE-LOCATION is the place \\[vc-push] would push to. | ||
| 2588 | When called interactively with a prefix argument, prompt for REMOTE-LOCATION. | ||
| 2589 | In some version control systems REMOTE-LOCATION can be a remote branch name. | ||
| 2590 | When called from Lisp optional argument FILESET overrides the VC fileset. | ||
| 2591 | |||
| 2592 | See `vc-use-incoming-outgoing-prefixes' regarding giving this command a | ||
| 2593 | global binding." | ||
| 2565 | ;; For this command, for distributed VCS, we want to ignore | 2594 | ;; For this command, for distributed VCS, we want to ignore |
| 2566 | ;; uncommitted changes because those are not outgoing, and the point | 2595 | ;; uncommitted changes because those are not outgoing, and the point |
| 2567 | ;; for those VCS is to make a comparison between locally committed | 2596 | ;; for those VCS is to make a comparison between locally committed |
| 2568 | ;; changes and remote committed changes. | 2597 | ;; changes and remote committed changes. |
| 2569 | ;; (Hence why we don't call `vc-buffer-sync-fileset'.) | 2598 | ;; (Hence why we don't call `vc-buffer-sync-fileset'.) |
| 2570 | (interactive (list (vc--maybe-read-remote-location))) | 2599 | (interactive (list (vc--maybe-read-remote-location))) |
| 2571 | (vc--with-backend-in-rootdir "VC root-diff" | 2600 | (let* ((fileset (or fileset (vc-deduce-fileset t))) |
| 2572 | (let ((incoming (vc--incoming-revision backend | 2601 | (backend (car fileset)) |
| 2573 | (or remote-location "")))) | 2602 | (incoming (vc--incoming-revision backend |
| 2574 | (vc-diff-internal vc-allow-async-diff (list backend (list rootdir)) | 2603 | (or remote-location "")))) |
| 2575 | (vc-call-backend backend 'mergebase incoming) | 2604 | (vc-diff-internal vc-allow-async-diff fileset |
| 2576 | ;; FIXME: In order to exclude uncommitted | 2605 | (vc-call-backend backend 'mergebase incoming) |
| 2577 | ;; changes we need to pass the most recent | 2606 | ;; FIXME: In order to exclude uncommitted |
| 2578 | ;; revision as REV2. Calling `working-revision' | 2607 | ;; changes we need to pass the most recent |
| 2579 | ;; like this works for all the backends we have | 2608 | ;; revision as REV2. Calling `working-revision' |
| 2580 | ;; in core that implement `mergebase' and so can | 2609 | ;; like this works for all the backends we have |
| 2581 | ;; be used with this command (Git and Hg). | 2610 | ;; in core that implement `mergebase' and so can |
| 2582 | ;; However, it is not clearly permitted by the | 2611 | ;; be used with this command (Git and Hg). |
| 2583 | ;; current semantics of `working-revision' to | 2612 | ;; However, it is not clearly permitted by the |
| 2584 | ;; call it on a directory. | 2613 | ;; current semantics of `working-revision' to |
| 2585 | ;; | 2614 | ;; call it on a directory. |
| 2586 | ;; A possible alternative would be something | 2615 | ;; |
| 2587 | ;; like this which effectively falls back to | 2616 | ;; A possible alternative would be something |
| 2588 | ;; including uncommitted changes in the case of | 2617 | ;; like this which effectively falls back to |
| 2589 | ;; an older VCS or where the backend rejects our | 2618 | ;; including uncommitted changes in the case of |
| 2590 | ;; attempt to call `working-revision' on a | 2619 | ;; an older VCS or where the backend rejects our |
| 2591 | ;; directory: | 2620 | ;; attempt to call `working-revision' on a |
| 2592 | ;; (and (eq (vc-call-backend backend | 2621 | ;; directory: |
| 2593 | ;; 'revision-granularity) | 2622 | ;; (and (eq (vc-call-backend backend |
| 2594 | ;; 'repository) | 2623 | ;; 'revision-granularity) |
| 2595 | ;; (ignore-errors | 2624 | ;; 'repository) |
| 2596 | ;; (vc-call-backend backend 'working-revision | 2625 | ;; (ignore-errors |
| 2597 | ;; rootdir))) | 2626 | ;; (vc-call-backend backend 'working-revision |
| 2598 | (vc-call-backend backend 'working-revision | 2627 | ;; (car fileset))) |
| 2599 | rootdir) | 2628 | (vc-call-backend backend 'working-revision |
| 2600 | (called-interactively-p 'interactive))))) | 2629 | (car fileset)) |
| 2630 | (called-interactively-p 'interactive)))) | ||
| 2601 | 2631 | ||
| 2602 | (declare-function ediff-load-version-control "ediff" (&optional silent)) | 2632 | (declare-function ediff-load-version-control "ediff" (&optional silent)) |
| 2603 | (declare-function ediff-vc-internal "ediff-vers" | 2633 | (declare-function ediff-vc-internal "ediff-vers" |