=== modified file 'doc/emacs/ChangeLog' --- doc/emacs/ChangeLog 2011-04-06 12:18:10 +0000 +++ doc/emacs/ChangeLog 2011-04-08 01:10:01 +0000 @@ -1,3 +1,8 @@ +2011-04-08 Christoph Scholtes + + * maintaining.texi (Old Revisions): Add paragraph on new function + vc-ediff. + 2011-03-30 Eli Zaretskii * display.texi (Auto Scrolling): Document the limit of 100 lines === modified file 'doc/emacs/maintaining.texi' --- doc/emacs/maintaining.texi 2011-03-01 04:14:00 +0000 +++ doc/emacs/maintaining.texi 2011-04-08 01:09:15 +0000 @@ -744,6 +744,13 @@ buffer, these commands generate a diff of all registered files in the current directory and its subdirectories. address@hidden vc-ediff +The function @code{vc-ediff} works like @code{vc-diff} and provides a way to +visually compare two revisions of a file an Ediff session, @pxref{Top, Ediff, +ediff, The Ediff Manual}. It compares the file associated with the current +buffer with the last repository revision. To compare two arbitrary revisions +of the current file, call @code{vc-ediff} with a prefix argument. + @vindex vc-diff-switches @vindex vc-rcs-diff-switches @kbd{C-x v =} works by running a variant of the @code{diff} utility === modified file 'etc/ChangeLog' --- etc/ChangeLog 2011-04-06 19:38:46 +0000 +++ etc/ChangeLog 2011-04-08 01:06:15 +0000 @@ -1,3 +1,7 @@ +2011-04-08 Christoph Scholtes + + * NEWS: Document new function `vc-ediff'. + 2011-04-06 Juanma Barranquero * NEWS: New variable `revert-buffer-in-progress-p'. === modified file 'etc/NEWS' --- etc/NEWS 2011-04-06 20:10:51 +0000 +++ etc/NEWS 2011-04-08 01:05:55 +0000 @@ -670,6 +670,9 @@ **** Packages using Log View mode can enable this functionality by binding `log-view-expanded-log-entry-function' to a suitable function. +*** New command `vc-ediff' allows visual comparison of two revisions +of a file similar to `vc-diff', but using ediff backend. + ** Miscellaneous --- === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-07 03:27:15 +0000 +++ lisp/ChangeLog 2011-04-08 00:55:54 +0000 @@ -1,3 +1,9 @@ +2011-04-08 Christoph Scholtes + + * vc/vc.el (vc-diff-build-argument-list-internal) + (vc-version-ediff, vc-ediff): New functions. + (vc-version-diff): Use vc-diff-build-argument-list-internal. + 2011-04-07 Aaron S. Hawley * play/morse.el (denato-region): Handle varying case. (Bug#8386) === modified file 'lisp/vc/vc.el' --- lisp/vc/vc.el 2011-03-07 08:56:30 +0000 +++ lisp/vc/vc.el 2011-04-08 00:57:37 +0000 @@ -653,6 +653,7 @@ (require 'vc-hooks) (require 'vc-dispatcher) +(require 'ediff) (eval-when-compile (require 'cl) @@ -1617,45 +1618,48 @@ nil nil initial-input nil default) (read-string prompt initial-input nil default)))) +(defun vc-diff-build-argument-list-internal () + "Build argument list for calling internal diff functions." + (let* ((vc-fileset (vc-deduce-fileset t)) ;FIXME: why t? --Stef + (files (cadr vc-fileset)) + (backend (car vc-fileset)) + (first (car files)) + (rev1-default nil) + (rev2-default nil)) + (cond + ;; someday we may be able to do revision completion on non-singleton + ;; filesets, but not yet. + ((/= (length files) 1) + nil) + ;; if it's a directory, don't supply any revision default + ((file-directory-p first) + nil) + ;; if the file is not up-to-date, use working revision as older revision + ((not (vc-up-to-date-p first)) + (setq rev1-default (vc-working-revision first))) + ;; if the file is not locked, use last and previous revisions as defaults + (t + (setq rev1-default (vc-call-backend backend 'previous-revision first + (vc-working-revision first))) + (when (string= rev1-default "") (setq rev1-default nil)) + (setq rev2-default (vc-working-revision first)))) + ;; construct argument list + (let* ((rev1-prompt (if rev1-default + (concat "Older revision (default " + rev1-default "): ") + "Older revision: ")) + (rev2-prompt (concat "Newer revision (default " + (or rev2-default "current source") "): ")) + (rev1 (vc-read-revision rev1-prompt files backend rev1-default)) + (rev2 (vc-read-revision rev2-prompt files backend rev2-default))) + (when (string= rev1 "") (setq rev1 nil)) + (when (string= rev2 "") (setq rev2 nil)) + (list files rev1 rev2)))) + ;;;###autoload (defun vc-version-diff (files rev1 rev2) "Report diffs between revisions of the fileset in the repository history." - (interactive - (let* ((vc-fileset (vc-deduce-fileset t)) ;FIXME: why t? --Stef - (files (cadr vc-fileset)) - (backend (car vc-fileset)) - (first (car files)) - (rev1-default nil) - (rev2-default nil)) - (cond - ;; someday we may be able to do revision completion on non-singleton - ;; filesets, but not yet. - ((/= (length files) 1) - nil) - ;; if it's a directory, don't supply any revision default - ((file-directory-p first) - nil) - ;; if the file is not up-to-date, use working revision as older revision - ((not (vc-up-to-date-p first)) - (setq rev1-default (vc-working-revision first))) - ;; if the file is not locked, use last and previous revisions as defaults - (t - (setq rev1-default (vc-call-backend backend 'previous-revision first - (vc-working-revision first))) - (when (string= rev1-default "") (setq rev1-default nil)) - (setq rev2-default (vc-working-revision first)))) - ;; construct argument list - (let* ((rev1-prompt (if rev1-default - (concat "Older revision (default " - rev1-default "): ") - "Older revision: ")) - (rev2-prompt (concat "Newer revision (default " - (or rev2-default "current source") "): ")) - (rev1 (vc-read-revision rev1-prompt files backend rev1-default)) - (rev2 (vc-read-revision rev2-prompt files backend rev2-default))) - (when (string= rev1 "") (setq rev1 nil)) - (when (string= rev2 "") (setq rev2 nil)) - (list files rev1 rev2)))) + (interactive (vc-diff-build-argument-list-internal)) ;; All that was just so we could do argument completion! (when (and (not rev1) rev2) (error "Not a valid revision range")) @@ -1681,6 +1685,48 @@ (called-interactively-p 'interactive)))) ;;;###autoload +(defun vc-version-ediff (files rev1 rev2) + "Show differences between revisions of the fileset in the +repository history using ediff." + (interactive (vc-diff-build-argument-list-internal)) + ;; All that was just so we could do argument completion! + (when (and (not rev1) rev2) + (error "Not a valid revision range")) + + (message "%s" (format "Finding changes in %s..." (vc-delistify files))) + + ;; Functions ediff-(vc|rcs)-internal use "" instead of nil. + (when (null rev1) (setq rev1 "")) + (when (null rev2) (setq rev2 "")) + + (cond + ;; FIXME We only support running ediff on one file for now. + ;; We could spin off an ediff session per file in the file set. + ((= (length files) 1) + (ediff-load-version-control) + (find-file (car files)) + (funcall + (intern (format "ediff-%S-internal" ediff-version-control-package)) + rev1 rev2 nil)) + (t + (error "More than one file is not supported")))) + +;;;###autoload +(defun vc-ediff (historic &optional not-urgent) + "Display diffs between file revisions using ediff. +Normally this compares the currently selected fileset with their +working revisions. With a prefix argument HISTORIC, it reads two revision +designators specifying which revisions to compare. + +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 + (call-interactively 'vc-version-ediff) + (when buffer-file-name (vc-buffer-sync not-urgent)) + (vc-version-ediff (cadr (vc-deduce-fileset t)) nil nil))) + +;;;###autoload (defun vc-root-diff (historic &optional not-urgent) "Display diffs between VC-controlled whole tree revisions. Normally, this compares the tree corresponding to the current