Subject: bug#13004: 24.2; vc-diff from vc-log doesn't show diff before renames (for Mercurial backend).

From: Oleksandr Gavenko <[email-masked]>
Date: Tue, 27 Nov 2012 22:51:50 +0200

On 2012-11-27, Glenn Morris wrote:

> Oleksandr Gavenko wrote:
>
>>   md /tmp/test
>>   hg init
>>   echo xxx >>README
>>   hg add
>>   hg ci -m init
>>   echo yyy >>README
>>   hg ci -m before
>>   hg mv README INSTALL
>>   hg ci -m rename
>>   echo zzz >>INSTALL
>>   hg ci -m after
>
> Perfect, thanks. (Assuming md == mkdir && cd)
>
>> Open INSTALL file in Emacs. "C-x v l" ("vc-print-log"). You get (I drop some
>> output):
>
> I had to add -f to vc-hg-log-switches. I'm guessing you have it in .hgrc
> maybe.
>
Yes.

>> In changeset 2 "d" (log-view-diff) fine:
>>
>>   diff --git a/README b/INSTALL
>>   copy from README
>>   copy to INSTALL
>
> I had to add --git to vc-hg-diff-switches.
>
>> In changeset 1 "d" (log-view-diff) fail: empty *vc-diff* buffer and message:
>>
>>   Finding changes in /tmp/test/INSTALL...
>>   No changes between 0 and 1
> [...]
>>   $ hg diff -r 1 -r 2 INSTALL
>>   diff --git a/README b/INSTALL
>>   copy from README
>>   copy to INSTALL
>
> Obviously to compare with what you are asking Emacs to do, you need to run:
>
> hg diff -r 0 -r 1 INSTALL
>
> This prints nothing for me.
>
> So I don't see any Emacs issue here.

Sorry. My fail. I understand that...

I put proxy utility to logging Emacs calls to 'hg':

  #!/bin/sh
  echo "$@" >>~/tmp/hg.log
  /usr/bin/hg "$@"

so seen:

  "diff" "-r" "0" "-r" "1" "INSTALL"

Next I reread "hg help diff". Previously I make call:

  $ hg diff -r 1 INSTALL

but actually mean with "-c":

  $ hg diff -c 1 INSTALL

But that command print nothing... So you right that I misunderstand.

I surprised that Mercurial doesn't allow follow history per file. Actually it
handle renames as special case for merges.

In case of SVN - Emacs work as I expect (more precisely I hoped that HG work
as SVN):

  mkdir /tmp/test-svn
  cd /tmp/test-svn
  svnadmin create server-repo
  svn co file:///tmp/test-svn/server-repo/ local-repo
  cd local-repo
  echo xxx >>README
  svn add README
  svn ci -m init
  echo yyy >>README
  svn ci -m before1
  echo mmm >>README
  svn ci -m before2
  svn mv README INSTALL
  svn ci -m rename
  echo zzz >>INSTALL
  svn ci -m after

So for revision r3 "before2" I get diff:

  Index: README
  ===================================================================
  --- README	(revision 2)
  +++ README	(revision 3)
  @@ -1,2 +1,3 @@
   xxx
   yyy
  +mmm

  "svn"  "diff" "-r" "2:3" "INSTALL"

So for revision r2 "before1" I get diff:

  Index: README
  ===================================================================
  --- README	(revision 1)
  +++ README	(revision 2)
  @@ -1 +1,2 @@
   xxx
  +yyy

  svn "diff" "-r" "1:2" "INSTALL"

**PS** Why Emacs uses -r R1 -r R2 for HG? "-c" - do job more better as it
       actually compares to its first parent.

-- 
Best regards!