Subject: bug#5846: 23.1.95.1 problems with mercurial commands in *VC Annotate* buffer on Windows

From: Andy Moreton <[email-masked]>
Date: Tue, 20 Apr 2010 15:13:42 +0100

On Mon 19 Apr 2010, Andy Moreton wrote:

> On Sat 17 Apr 2010, Chong Yidong wrote:
>
>>> In GNU Emacs 23.1.95.1 (i386-mingw-nt5.1.2600)
>>>
>>> Using Mercurial from TortoiseHg 0.9, which contains Mercurial-1.4,
>>> Python-2.5.4, PyGTK-2.12.1, GTK-2.16.1
>>>
>>> Start emacs with "c:\emacs\23.1.95\bin\emacs -Q"
>>> Open a file from a mercurial repository
>>> Type "C-x v g" to annotate the file
>>>
>>> In the *VC Annotate* buffer:
>>> 1) Type "l" (vc-annotate-show-log-revision-at-line)
>>>    The Hg command runs, but the *vc-change-log* buffer is empty
>>>
>>> 2) Type "f" (vc-annotate-find-revision-at-line)
>>>    Emacs displays a message "Cannot open load file: vc-nil"
>>
>> It looks like this is the same bug as the one just fixed in
>>
>>   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5960
>>
>> You can find the patch there, and it will be included in the next
>> pretest.
>>
>> Thanks for the bug report.
>
> I've rebuilt emacs from the emacs-23 branch today, and the problems are
> still there. In addition, the modeline display shows "Hg-" suggesting that
> emacs is not correctly detecting the working revision of the file.

Ive retested with the 23.1.96 pretest tarball, and have found the
problem. In vc-hg-working-revision (in vc-hg.el):

      (let ((process-environment avoid-local-env))
	;; Ignore all errors.
	(process-file
	 "hg" nil t nil
	 "parent" "--template" "{rev}" (file-relative-name file)))

1) TortoiseHg does not seem to honour the "HGRC=" set in
`avoid-local-env'. for local configration it reads some of the 
the following config files:
       %ProgramFiles%\TortoiseHg\Mercurial.ini
       %USERPROFILE%\mercurial.ini
       %HOME%\.hgrc

2) I had the following setting in "~/.hgrc":
   [alias]
   parenttag = parents --template "{latesttag} +{latesttagdistance}\n"

The combined effect is that TortoiseHg read my ~/.hgrc file, thus making
the "hg parent" command ambiguous (could be "parents" or "parenttag").

`vc-hg-working-revision' should use "hg parents" to make the command
unambiguous.

    AndyM