Subject: bug#5960: 24.0.50; vc-annotate buffer commands fail in subdirectories with Hg

From: Magnus Henoch <[email-masked]>
Date: Fri, 16 Apr 2010 18:44:46 +0100

cd /tmp
hg init reproduce
cd reproduce
mkdir foo
echo foo > foo/foo.txt
hg add foo/foo.txt
hg commit -m "Added foo.txt."
emacs -Q foo/foo.txt

C-x v g
l

Expected result: the *vc-change-log* buffer lists the changeset that added
foo.txt.
Actual result: the *vc-change-log* buffer is empty.

I took a look in the code, and it seems that
vc-hg-annotate-extract-revision-at-line expands filenames against the
current directory, while `hg annotate' displays filenames relative to
the project root.  Thus this patch:

=== modified file 'lisp/vc-hg.el'
--- lisp/vc-hg.el	2010-04-07 05:56:35 +0000
+++ lisp/vc-hg.el	2010-04-16 17:43:15 +0000
@@ -356,7 +356,7 @@
       (if (match-beginning 3)
 	  (match-string-no-properties 1)
 	(cons (match-string-no-properties 1)
-	      (expand-file-name (match-string-no-properties 4)))))))
+              (expand-file-name (match-string-no-properties 4) (vc-hg-root default-directory)))))))
 
 (defun vc-hg-previous-revision (file rev)
   (let ((newrev (1- (string-to-number rev))))

In GNU Emacs 24.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.18.1)
 of 2010-03-18 on linux-b2a3
Windowing system distributor `The X.Org Foundation', version 11.0.10605000
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
  shell-dirtrack-mode: t
  eldoc-mode: t
  show-paren-mode: t
  server-mode: t
  ido-everywhere: 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
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
n n n n e f n a m e <return> q d n n n n n C-x 4 b 
h g <return> <up> <up> <up> C-u C-M-x <C-s-down> q 
d n n n n n n n n n <up> <down> n n n n n n n n n n 
n q C-x b v c - h g <return> <C-end> <up> <up> <up> 
<up> <up> <up> C-f C-f C-f C-f C-c f <return> <down> 
<down> <down> <down> <down> <down> <down> <up> C-f 
C-f C-f C-f C-f C-f C-h f <return> <C-s-down> <tab> 
<return> <s-down> <s-down> <s-down> <s-down> <s-down> 
<s-down> <s-down> <s-down> <s-down> <s-down> <s-down> 
<s-down> <s-down> <s-down> <s-down> <s-down> <s-down> 
<s-down> <s-down> C-x b C-s <return> C-u C-SPC <down> 
<down> <down> C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f 
( e x p a n d - f i l e - n a m e C-f <backspace> SPC 
f C-f C-f C-f C-f ) C-x C-s n o <return> C-u C-M-x 
C-x b C-s C-s <return> d n n n n n n n n n n n n n 
n n n n n n n c <next> <next> <next> <next> <prior> 
<prior> <prior> <prior> <prior> <C-backspace> l c C-x 
b C-s <return> <tab> C-x v = n C-x C-s y e s <return> 
<down> <up> M-x l o c a t e <return> v c - h g . e 
l <return> <C-s-down> M-x d i f f - b a c k <return> 
<return> M-x d i f f - f i l <backspace> <backspace> 
<backspace> <backspace> - s a v <backspace> <backspace> 
<backspace> - w i <backspace> <backspace> <backspace> 
w i t <return> <return> M-x r e m o r <backspace> <backspace> 
<backspace> p o r t - <return>

Recent messages:
vc-deduce-fileset: No fileset is available here
Saving file /usr/local/share/emacs/24.0.50/lisp/vc-hg.el.gz...
Cannot write backup file; backing up in /home/magnus/%backup%~
basic-save-buffer-2: Doing chmod: operation not permitted, /usr/local/share/emacs/24.0.50/lisp/vc-hg.el.gz
diff-backup: No backup found for /usr/local/share/emacs/24.0.50/lisp/vc-hg.el.gz
uncompressing vc-hg.el.gz...done
Auto-saving vc-hg.el.gz: Opening output file: permission denied, /usr/local/share/emacs/24.0.50/lisp/#vc-hg.el.gz#

Load-path shadows:
~/emacs/org-mode/lisp/org-html hides /usr/local/share/emacs/24.0.50/lisp/org/org-html
~/emacs/org-mode/lisp/org-table hides /usr/local/share/emacs/24.0.50/lisp/org/org-table
~/emacs/org-mode/lisp/org-bbdb hides /usr/local/share/emacs/24.0.50/lisp/org/org-bbdb
~/emacs/org-mode/lisp/org-mouse hides /usr/local/share/emacs/24.0.50/lisp/org/org-mouse
~/emacs/org-mode/lisp/org-rmail hides /usr/local/share/emacs/24.0.50/lisp/org/org-rmail
~/emacs/org-mode/lisp/org-compat hides /usr/local/share/emacs/24.0.50/lisp/org/org-compat
~/emacs/org-mode/lisp/org-latex hides /usr/local/share/emacs/24.0.50/lisp/org/org-latex
~/emacs/org-mode/lisp/org-gnus hides /usr/local/share/emacs/24.0.50/lisp/org/org-gnus
~/emacs/org-mode/lisp/org-habit hides /usr/local/share/emacs/24.0.50/lisp/org/org-habit
~/emacs/org-mode/lisp/org-exp hides /usr/local/share/emacs/24.0.50/lisp/org/org-exp
~/emacs/org-mode/lisp/org-src hides /usr/local/share/emacs/24.0.50/lisp/org/org-src
~/emacs/org-mode/lisp/org-plot hides /usr/local/share/emacs/24.0.50/lisp/org/org-plot
~/emacs/org-mode/lisp/org-publish hides /usr/local/share/emacs/24.0.50/lisp/org/org-publish
~/emacs/org-mode/lisp/org-bibtex hides /usr/local/share/emacs/24.0.50/lisp/org/org-bibtex
~/emacs/org-mode/lisp/org-xoxo hides /usr/local/share/emacs/24.0.50/lisp/org/org-xoxo
~/emacs/org-mode/lisp/org-remember hides /usr/local/share/emacs/24.0.50/lisp/org/org-remember
~/emacs/org-mode/lisp/org-crypt hides /usr/local/share/emacs/24.0.50/lisp/org/org-crypt
~/emacs/org-mode/lisp/org-timer hides /usr/local/share/emacs/24.0.50/lisp/org/org-timer
~/emacs/org-mode/lisp/org-vm hides /usr/local/share/emacs/24.0.50/lisp/org/org-vm
~/emacs/org-mode/lisp/org hides /usr/local/share/emacs/24.0.50/lisp/org/org
~/emacs/org-mode/lisp/org-mew hides /usr/local/share/emacs/24.0.50/lisp/org/org-mew
~/emacs/org-mode/lisp/org-archive hides /usr/local/share/emacs/24.0.50/lisp/org/org-archive
~/emacs/org-mode/lisp/org-indent hides /usr/local/share/emacs/24.0.50/lisp/org/org-indent
~/emacs/org-mode/lisp/org-agenda hides /usr/local/share/emacs/24.0.50/lisp/org/org-agenda
~/emacs/org-mode/lisp/org-exp-blocks hides /usr/local/share/emacs/24.0.50/lisp/org/org-exp-blocks
~/emacs/org-mode/lisp/org-id hides /usr/local/share/emacs/24.0.50/lisp/org/org-id
~/emacs/org-mode/lisp/org-install hides /usr/local/share/emacs/24.0.50/lisp/org/org-install
~/emacs/org-mode/lisp/org-datetree hides /usr/local/share/emacs/24.0.50/lisp/org/org-datetree
~/emacs/org-mode/lisp/org-clock hides /usr/local/share/emacs/24.0.50/lisp/org/org-clock
~/emacs/org-mode/lisp/org-w3m hides /usr/local/share/emacs/24.0.50/lisp/org/org-w3m
~/emacs/org-mode/lisp/org-irc hides /usr/local/share/emacs/24.0.50/lisp/org/org-irc
~/emacs/org-mode/lisp/org-inlinetask hides /usr/local/share/emacs/24.0.50/lisp/org/org-inlinetask
~/emacs/org-mode/lisp/org-mac-message hides /usr/local/share/emacs/24.0.50/lisp/org/org-mac-message
~/emacs/org-mode/lisp/org-list hides /usr/local/share/emacs/24.0.50/lisp/org/org-list
~/emacs/org-mode/lisp/org-colview hides /usr/local/share/emacs/24.0.50/lisp/org/org-colview
~/emacs/org-mode/lisp/org-mobile hides /usr/local/share/emacs/24.0.50/lisp/org/org-mobile
~/emacs/org-mode/lisp/org-attach hides /usr/local/share/emacs/24.0.50/lisp/org/org-attach
~/emacs/org-mode/lisp/org-wl hides /usr/local/share/emacs/24.0.50/lisp/org/org-wl
~/emacs/org-mode/lisp/org-info hides /usr/local/share/emacs/24.0.50/lisp/org/org-info
~/emacs/org-mode/lisp/org-macs hides /usr/local/share/emacs/24.0.50/lisp/org/org-macs
~/emacs/org-mode/lisp/org-mhe hides /usr/local/share/emacs/24.0.50/lisp/org/org-mhe
~/emacs/org-mode/lisp/org-jsinfo hides /usr/local/share/emacs/24.0.50/lisp/org/org-jsinfo
~/emacs/org-mode/lisp/org-freemind hides /usr/local/share/emacs/24.0.50/lisp/org/org-freemind
~/emacs/org-mode/lisp/org-icalendar hides /usr/local/share/emacs/24.0.50/lisp/org/org-icalendar
~/emacs/org-mode/lisp/org-feed hides /usr/local/share/emacs/24.0.50/lisp/org/org-feed
~/emacs/org-mode/lisp/org-footnote hides /usr/local/share/emacs/24.0.50/lisp/org/org-footnote
~/emacs/org-mode/lisp/org-protocol hides /usr/local/share/emacs/24.0.50/lisp/org/org-protocol
~/emacs/org-mode/lisp/org-ascii hides /usr/local/share/emacs/24.0.50/lisp/org/org-ascii
~/emacs/org-mode/lisp/org-docbook hides /usr/local/share/emacs/24.0.50/lisp/org/org-docbook
~/emacs/org-mode/lisp/org-faces hides /usr/local/share/emacs/24.0.50/lisp/org/org-faces
~/emacs/emms/lisp/tq hides /usr/local/share/emacs/24.0.50/lisp/emacs-lisp/tq

Features:
(shadow sort gnus-cite gnus-msg emacsbug diff locate log-view cl-specs
edebug jka-compr parse-time vc-annotate sql hippie-exp imenu smerge-mode
find-dired grep log-edit pcvs-util add-log dired-aux diff-mode vc-git
vc-bzr vc-sccs vc-svn vc-cvs vc-rcs vc-dir vc vc-dispatcher man pp etags
org-table cal-china lunar solar cal-dst cal-bahai cal-islam cal-hebrew
holidays hol-loaddefs diary-lib diary-loaddefs cal-iso cal-menu calendar
cal-loaddefs apropos multi-isearch mule-util face-remap w3-style rect
w3-forms url-cache url-http tls w3-hot url-file url-dired w3-toolbar
w3-emacs w3-props url-auth w3 w3-menu url-news nntp url-irc url-gw
cus-edit w3-emulate w3-parse w3-fast-parse xml w3-display w3-mouse
w3-imap url-handlers url url-proxy url-privacy url-expand url-methods
url-history url-cookie w3-widget url-util w3-vars w3-keymap w3-cus
url-parse url-vars css font disp-table devices ange-ftp w3-cfg w3-compat
vc-hg thingatpt find-func org-ascii tabify org-clock tramp-imap assoc
tramp-gw tramp-fish tramp-smb tramp-cache tramp-ftp tramp-cmds tramp
auth-source shell tramp-compat trampver copyright help-mode view eldoc
jabber-console sgml-mode ewoc jabber-keymap org-feed org-w3m org-wl
org-vm org-rmail org-mhe org-mew org-irc org-habit org-jsinfo org-infojs
org-html org-exp org-exp-blocks org-agenda org-info org-gnus org-bibtex
org-bbdb paren server ido icomplete time cus-start cus-load
emms-playlist-sort emms-last-played emms-info-libtag emms-cache
emms-info-ogginfo emms-info-mp3info emms-info later-do
emms-playlist-mode emms-player-vlc emms-player-mplayer
emms-player-simple emms-source-playlist emms-source-file dired
emms-setup emms emms-compat bbdb-gnus gnus-art mm-uu mml2015 epg-config
mm-view smime dig gnus-sum nnoo gnus-group gnus-undo nnmail mail-source
format-spec gnus-start gnus-spec gnus-int gnus-range message sendmail
ecomplete mml mml-sec password-cache mm-decode mm-bodies mm-encode
mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums gmm-utils
mailheader canlock sha1 hex-util hashcash gnus-win gnus gnus-ems
nnheader gnus-util netrc mail-utils mm-util mail-prsvr wid-edit
bbdb-snarf mail-extr rfc822 bbdb-com warnings mailabbrev bbdb-autoloads
bbdb regexp-opt timezone patmatch erl-service derived derl erlext epmd
net-fsm erl wrangler erlang flymake compile comint ring w3-auto edmacro
kmacro remember org-remember org-datetree org byte-opt bytecomp
byte-compile org-footnote org-src org-list org-faces org-compat org-macs
easymenu time-date noutline outline easy-mmode org-redmine cl cl-19
org-install uniquify advice help-fns advice-preload vc-p4 p4-lowlevel
lfe-mode erlang-web-template tempo erlang-start jabber-autoloads
jabber-util tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win
x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind system-font-setting
font-render-setting gtk x-toolkit x multi-tty emacs)

-- 
Magnus Henoch