From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Christoph Scholtes Newsgroups: gmane.emacs.devel Subject: Re: New function: vc-ediff Date: Thu, 07 Apr 2011 19:16:00 -0600 Message-ID: <4D9E61D0.5020209@gmail.com> References: <4D785193.3030201@gmail.com> <4D79A736.6080707@gmail.com> <831v2cu40y.fsf@gnu.org> <838vwkrroz.fsf@gnu.org> <86r5a3j1a1.fsf@gmail.com> <86ipvbdaoq.fsf@gmail.com> <86d3la8x5p.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070202020409000502090106" X-Trace: dough.gmane.org 1302225384 8487 80.91.229.12 (8 Apr 2011 01:16:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 8 Apr 2011 01:16:24 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 08 03:16:20 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q80J6-0003QO-As for ged-emacs-devel@m.gmane.org; Fri, 08 Apr 2011 03:16:18 +0200 Original-Received: from localhost ([127.0.0.1]:48108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q80J4-0000Lv-PY for ged-emacs-devel@m.gmane.org; Thu, 07 Apr 2011 21:16:14 -0400 Original-Received: from [140.186.70.92] (port=48171 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q80Ix-0000Ln-N9 for emacs-devel@gnu.org; Thu, 07 Apr 2011 21:16:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q80Iv-0007qM-I1 for emacs-devel@gnu.org; Thu, 07 Apr 2011 21:16:07 -0400 Original-Received: from mail-gy0-f169.google.com ([209.85.160.169]:48871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q80Iv-0007ps-9E for emacs-devel@gnu.org; Thu, 07 Apr 2011 21:16:05 -0400 Original-Received: by gyd8 with SMTP id 8so1531547gyd.0 for ; Thu, 07 Apr 2011 18:16:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=pZ8PL53ZkprRJiWbDEGOe53BQkiKU4F6RngBZIWhOvA=; b=PH0UnJRr+753ANUyXddZ7uVQMgxnV+qHJgud51iC40OW4rBfvu5s2noenezpRhyZgA EU0YsKRgfNa8e1IoKZEz8MTObRbh3y1AknL5IfnBWwN8L7mIffgRcKvyIChxmcnV/UGk mo0ClX72cgapj/OyWWuYoi+iblJFsNCsPXNaY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; b=JyC5Te2AesZnT6Xskq3YMMZic4P9S5i/q2QB4xR2S4iTQZS3Ziu7XktZMQyizZZDF9 aTlKUK9wUcF4pqPmNZo5iKRUjKYtFt+nDG92eE9ob6VzO+z/k1bzj0WePgBEwMJKbekn DVZ6V+M1XDQ1Jl3ZEEKAvgQrgNUWwDxifIomQ= Original-Received: by 10.236.115.137 with SMTP id e9mr1982944yhh.416.1302225363737; Thu, 07 Apr 2011 18:16:03 -0700 (PDT) Original-Received: from [192.168.1.4] (70-59-0-207.hlrn.qwest.net [70.59.0.207]) by mx.google.com with ESMTPS id u40sm1015410yhn.74.2011.04.07.18.16.01 (version=SSLv3 cipher=OTHER); Thu, 07 Apr 2011 18:16:02 -0700 (PDT) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: <86d3la8x5p.fsf@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.160.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138298 Archived-At: This is a multi-part message in MIME format. --------------070202020409000502090106 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------070202020409000502090106 Content-Type: text/plain; name="vc-diff_v3.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vc-diff_v3.patch" === 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. +@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 + + * 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 --------------070202020409000502090106--