Subject: 23.0.60; vc-hg-diff fails for files in different directories

From: Magnus Henoch <[email-masked]>
Date: Wed, 14 Jan 2009 17:58:31 +0000

Using vc-dir on a Mercurial working directory, when marking edited files
in different directories and typing C-x v =, hg complains about not
finding some of the files.  This is because vc-hg-diff uses the
directory of the first file for the --cwd switch, and then discards the
directory of all other files.

This patch seems to fix the problem, but I'm not sure why the code jumps
through the hoops of using relative filenames at all.

2009-01-14  Magnus Henoch  <[email-masked]>

	* vc-hg.el (vc-hg-diff): Use relative filenames instead of
	discarding the directory part.

diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el
index 05a1ae5..c5da02a 100644
--- a/lisp/vc-hg.el
+++ b/lisp/vc-hg.el
@@ -265,7 +265,9 @@ If nil, use the value of `vc-diff-switches'.  If t, use no switches."
     (when (and (not oldvers) newvers)
       (setq oldvers working))
     (apply #'vc-hg-command (or buffer "*vc-diff*") nil
-	   (mapcar (lambda (file) (file-name-nondirectory file)) files)
+	   (mapcar (lambda (file)
+                     (file-relative-name file (file-name-directory firstfile)))
+                   files)
 	   "--cwd" (or (when firstfile (file-name-directory firstfile))
 		       (expand-file-name default-directory))
 	   "diff"

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/local/share/emacs/23.0.60/etc/DEBUG for instructions.

In GNU Emacs 23.0.60.3 (i686-pc-linux-gnu, GTK+ Version 2.12.9)
 of 2009-01-13 on linux-b2a3
Windowing system distributor `The X.Org Foundation', version 11.0.10400090
configured using `configure  '--enable-maintainer-mode''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  jabber-activity-mode: t
  jabber-mode-line-mode: t
  eldoc-mode: t
  show-paren-mode: t
  server-mode: t
  iswitchb-mode: t
  icomplete-mode: t
  display-time-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <next> <next> <up> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<s-right> <up> <up> l C-s 5 f 1 2 2 <return> <C-s-down> 
d <next> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <down> <down> <s-right> C-h f f i l 
e - e <backspace> r e l a <tab> <return> <down> <return> 
<return> C-c C-c C-x b C-s <return> <up> C-e <left> 
<left> <left> <left> <left> <left> <left> <left> <left> 
<left> <left> <left> <left> <left> <left> <left> <left> 
<left> <left> <left> <left> <left> <M-backspace> M-d 
r e l a t i v e - n a m e C-/ C-/ C-/ <up> <up> <up> 
<up> <up> <down> <down> <down> <down> <left> <left> 
<left> <left> <left> <left> <left> <left> <left> <M-backspace> 
r e l a t i v e - n a m e M-d M-f <return> <tab> <backspace> 
<backspace> C-M-b <return> <tab> <up> <left> <backspace> 
<return> <tab> <down> <up> C-e C-d C-d C-d M-f M-b 
<backspace> SPC M-f SPC ( f l <backspace> i l e - n 
a m e - d i r e c t o r y SPC f i r s t f i l e ) ) 
<right> <right> <backspace> <return> <tab> C-x C-s 
C-c c M-x e m a c s - l i - b y - - - <return> C-x 
b v c - d i r <return> C-x v = C-x 1 <next> <next> 
<next> <prior> <prior> <prior> C-x b <return> C-x b 
C-s <return> M-x r e p o r t - e <return>

Recent messages:
Type C-x 4 C-o RET to restore the other window.
Buffer is read-only: #<buffer *Annotate vc-hg.el (rev master)*> [2 times]
Undo! [3 times]
Wrote /home/magnus/src/emacs/lisp/vc-hg.el
Compiling /home/magnus/src/emacs/lisp/vc-hg.el...
Fontifying *Compile-Log*... (regexps........................................................)
Compiling /home/magnus/src/emacs/lisp/vc-hg.el...done
Wrote /home/magnus/src/emacs/lisp/vc-hg.elc
Loading /home/magnus/src/emacs/lisp/vc-hg.elc...done
Finding changes in /home/magnus/raven/make/apps-common.mk /home/magnus/raven/make/apps-defs.mk /home/magnus/raven/utils/new-app.sh /home/magnus/raven/utils/app-skeleton/Makefile /home/magnus/raven/utils/app-skeleton/vsn.mk /home/magnus/raven/utils/app-skeleton/doc/overview.edoc /home/magnus/raven/utils/app-skeleton/src/skeleton.app.src /home/magnus/raven/utils/app-skeleton/test/skeleton_suite.erl.src...done