* lisp/vc/vc.el (vc-root-version-diff): New command (bug#33650).

(vc-root-diff): Call it interactively on a prefix argument.
This commit is contained in:
Juri Linkov 2018-12-11 01:54:20 +02:00
parent 0249277925
commit 712e74a9fb
3 changed files with 38 additions and 5 deletions

View file

@ -831,6 +831,14 @@ working tree containing the current VC fileset). If you invoke this
command from a Dired buffer, it applies to the working tree containing
the directory.
@findex vc-root-version-diff
@kindex C-u C-x v D
To compare two arbitrary revisions of the whole trees, call
@code{vc-root-diff} with a prefix argument: @kbd{C-u C-x v D}. This
prompts for two revision IDs (@pxref{VCS Concepts}), and displays a
diff between those versions of the entire version-controlled directory
trees (RCS, SCCS, CVS, and SRC do not support this feature).
@vindex vc-diff-switches
You can customize the @command{diff} options that @kbd{C-x v =} and
@kbd{C-x v D} use for generating diffs. The options used are taken
@ -963,6 +971,7 @@ and the maximum number of revisions to display.
Directory Mode}) or a Dired buffer (@pxref{Dired}), it applies to the
file listed on the current line.
@kindex C-x v L
@findex vc-print-root-log
@findex log-view-toggle-entry-display
@kbd{C-x v L} (@code{vc-print-root-log}) displays a

View file

@ -398,6 +398,10 @@ with conflicts existed in earlier versions of Emacs, but incorrectly
never detected a conflict due to invalid assumptions about cached
values.
+++
*** 'C-u C-x v D' ('vc-root-version-diff') prompts for two revisions
and compares their entire trees.
** Diff mode
*** Hunks are now automatically refined by default.
To disable it, set the new defcustom 'diff-font-lock-refine' to nil.

View file

@ -1817,7 +1817,7 @@ Return t if the buffer had changes, nil otherwise."
;;;###autoload
(defun vc-version-diff (_files rev1 rev2)
"Report diffs between revisions of the fileset in the repository history."
"Report diffs between REV1 and REV2 revisions of the fileset."
(interactive (vc-diff-build-argument-list-internal))
;; All that was just so we could do argument completion!
(when (and (not rev1) rev2)
@ -1827,6 +1827,28 @@ Return t if the buffer had changes, nil otherwise."
(vc-diff-internal t (vc-deduce-fileset t) rev1 rev2
(called-interactively-p 'interactive)))
;;;###autoload
(defun vc-root-version-diff (_files rev1 rev2)
"Report diffs between REV1 and REV2 revisions of the whole tree."
(interactive (vc-diff-build-argument-list-internal))
;; This is a mix of `vc-root-diff' and `vc-version-diff'
(when (and (not rev1) rev2)
(error "Not a valid revision range"))
(let ((backend (vc-deduce-backend))
(default-directory default-directory)
rootdir)
(if backend
(setq rootdir (vc-call-backend backend 'root default-directory))
(setq rootdir (read-directory-name "Directory for VC root-diff: "))
(setq backend (vc-responsible-backend rootdir))
(if backend
(setq default-directory rootdir)
(error "Directory is not version controlled")))
(let ((default-directory rootdir))
(vc-diff-internal
t (list backend (list rootdir)) rev1 rev2
(called-interactively-p 'interactive)))))
;;;###autoload
(defun vc-diff (&optional historic not-urgent)
"Display diffs between file revisions.
@ -1900,10 +1922,8 @@ The optional argument NOT-URGENT non-nil means it is ok to say no to
saving the buffer."
(interactive (list current-prefix-arg t))
(if historic
;; FIXME: this does not work right, `vc-version-diff' ends up
;; calling `vc-deduce-fileset' to find the files to diff, and
;; that's not what we want here, we want the diff for the VC root dir.
(call-interactively 'vc-version-diff)
;; We want the diff for the VC root dir.
(call-interactively 'vc-root-version-diff)
(when buffer-file-name (vc-buffer-sync not-urgent))
(let ((backend (vc-deduce-backend))
(default-directory default-directory)