unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Christoph Scholtes <cschol2112@googlemail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: New function: vc-ediff
Date: Thu, 07 Apr 2011 19:16:00 -0600	[thread overview]
Message-ID: <4D9E61D0.5020209@gmail.com> (raw)
In-Reply-To: <86d3la8x5p.fsf@gmail.com>

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

Hi Stefan,

Here is a new version of the `vc-ediff' patch. No changes on the `ediff' 
side, all new functions and refactoring in vc.el.

Christoph

[-- Attachment #2: vc-diff_v3.patch --]
[-- Type: text/plain, Size: 8503 bytes --]

=== 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  <cschol2112@googlemail.com>
+
+	* maintaining.texi (Old Revisions): Add paragraph on new function
+	vc-ediff.
+
 2011-03-30  Eli Zaretskii  <eliz@gnu.org>
 
 	* 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.
 
+@findex 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  <cschol2112@googlemail.com>
+
+	* NEWS: Document new function `vc-ediff'.
+
 2011-04-06  Juanma Barranquero  <lekktu@gmail.com>
 
 	* 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  <cschol2112@googlemail.com>
+
+	* 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  <aaron.s.hawley@gmail.com>
 
 	* 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


  parent reply	other threads:[~2011-04-08  1:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-10  4:20 New function: vc-ediff Christoph Scholtes
2011-03-10 16:00 ` Stefan Monnier
2011-03-11  4:38   ` Christoph Scholtes
2011-03-11 20:15     ` Stefan Monnier
2011-03-12  8:38       ` Eli Zaretskii
2011-03-12 15:05         ` Christoph Scholtes
2011-03-12 17:49           ` Eli Zaretskii
2011-03-12 20:44         ` Stefan Monnier
2011-03-12 20:48           ` Eli Zaretskii
2011-03-12 21:27             ` Stefan Monnier
2011-03-19  2:24               ` Christoph Scholtes
2011-03-20  2:45                 ` Stefan Monnier
2011-03-22  4:46                   ` Christoph Scholtes
2011-03-27 16:03                     ` Christoph Scholtes
2011-03-27 20:58                     ` Stefan Monnier
2011-03-29  2:42                       ` Christoph Scholtes
2011-03-29 13:46                         ` Stefan Monnier
2011-03-30  3:02                           ` Christoph Scholtes
2011-04-08  1:16                         ` Christoph Scholtes [this message]
2011-04-17 19:04                           ` Christoph Scholtes
2011-04-20 17:39                             ` Stefan Monnier
2011-04-20 22:20                               ` Christoph Scholtes
2011-03-13 16:16             ` Uday S Reddy
2011-03-13 18:01               ` Eli Zaretskii
2011-03-13 21:35                 ` Stefan Monnier
2011-03-13 22:58                 ` Christoph Scholtes
2011-03-12 15:11       ` Christoph Scholtes
2011-03-12 21:25         ` Stefan Monnier
2011-03-11  4:12 ` Michael Welsh Duggan
2011-03-11  4:44   ` Christoph Scholtes
2011-03-11  7:46   ` Uday S Reddy
2011-03-11  8:16     ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D9E61D0.5020209@gmail.com \
    --to=cschol2112@googlemail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).