unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33650: 27.0.50; Root diffs between revisions
@ 2018-12-06 21:54 Juri Linkov
  2018-12-07  6:41 ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2018-12-06 21:54 UTC (permalink / raw)
  To: 33650

[-- Attachment #1: Type: text/plain, Size: 577 bytes --]

A VC command that still doesn't allow using diff-mode automatically
thus preventing proper fontification and all other related features
is `vc-root-diff' with a prefix argument HISTORIC.  It has such comment:

      ;; 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.

This patch fixes this omission by implementing `vc-root-version-diff'
that is able to compare two revisions even on separate branches from
their roots:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: vc-root-version-diff.patch --]
[-- Type: text/x-diff, Size: 1911 bytes --]

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index de43544864..74979e7381 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1827,6 +1827,28 @@ vc-version-diff
   (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 revisions of the whole tree in the repository history."
+  (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 @@ vc-root-diff
 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)

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-12-10 23:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-06 21:54 bug#33650: 27.0.50; Root diffs between revisions Juri Linkov
2018-12-07  6:41 ` Eli Zaretskii
2018-12-08 23:32   ` Juri Linkov
2018-12-09  8:22     ` Eli Zaretskii
2018-12-10  0:04       ` Juri Linkov
2018-12-10  0:59         ` Dmitry Gutov
2018-12-10  6:30           ` Eli Zaretskii
2018-12-10 23:55           ` Juri Linkov
2018-12-10  6:29         ` Eli Zaretskii
2018-12-10 23:55           ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).