Subject: bug#4642: diff from log-view somtime diffs the wrong file

From: Dan Nicolaescu <[email-masked]>
Date: Mon, 5 Oct 2009 05:43:57 -0700 (PDT)

emacs -Q

C-x v d SOME_DIRECTORY RET

say the above display 2 files a and b

put the cursor on a and do:

C-x v l

put the cursor on b and

switch to the *vc-change-log* buffer.

press d in that buffer

it will show a diff for the file "b", not "a" (or it will give an error
that the diff is not found).

log-view-diff calls vc-version-diff, which calls vc-diff-internal not
using it's arguments, but by calling `vc-deduce-fileset'.  That will
trigger this code in vc-deduce-fileset:

     ((and (buffer-live-p vc-parent-buffer)
           (or (buffer-file-name vc-parent-buffer)
             (with-current-buffer
                  vc-parent-buffer
                          (derived-mode-p 'vc-dir-mode))))

but the selected file in the vc-dir buffer has changed, and this will
return the new selected file, while log-view actually wants the old one.

One way to fix this is to make log-view-diff not call vc-version-diff,
but vc-diff-internal, like so:

--- log-view.el.~1.60.~    2009-10-03 03:20:50.000000000 -0700
+++ log-view.el            2009-10-04 19:20:58.000000000 -0700
@@ -496,11 +496,12 @@ changeset that affected the currently co
         (goto-char end)
         (log-view-msg-next)
         (setq to (log-view-current-tag))))
-    (vc-version-diff
-     (if log-view-per-file-logs
-      (list (log-view-current-file))
-       log-view-vc-fileset)
-       to fr)))
+    (vc-diff-internal
+     t (list log-view-vc-backend
+          (if log-view-per-file-logs
+               (list (log-view-current-file))
+                      log-view-vc-fileset))
+     to fr)))
 
 (declare-function vc-diff-internal "vc"
                    (async vc-fileset rev1 rev2 &optional verbose))

OK to check in?