Subject: Re: bug#5232: 23.1.90; vc-hg-working-revision always gives latest revision in which file changed

From: Dan Nicolaescu <[email-masked]>
Date: Thu, 17 Dec 2009 08:24:36 -0800 (PST)

Dan Nicolaescu <[email-masked]> writes:

  > Magnus Henoch <[email-masked]> writes:
  > 
  >   > When the revision currently checked out is not the latest revision that
  >   > touched the file in question, vc-hg-working-revision gives the wrong
  >   > result.  This can happen in two cases: you have checked out a non-head
  >   > revision, or the file has been changed in another branch.  Two test
  >   > cases:
  >   > 
  >   > /tmp $ mkdir hgtest
  >   > /tmp $ cd hgtest
  >   > /tmp/hgtest $ hg init
  >   > /tmp/hgtest $ echo foo > foo.txt
  >   > /tmp/hgtest $ hg add foo.txt
  >   > /tmp/hgtest $ hg commit -m "Added foo.txt"
  >   > /tmp/hgtest $ echo bar > foo.txt
  >   > /tmp/hgtest $ hg commit -m "Changed foo to bar"
  >   > /tmp/hgtest $ hg up -r 0
  >   > 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  >   > 
  >   > /tmp $ mkdir hgtest2
  >   > /tmp $ cd hgtest2
  >   > /tmp/hgtest2 $ hg init
  >   > /tmp/hgtest2 $ echo foo > foo.txt
  >   > /tmp/hgtest2 $ hg add foo.txt
  >   > /tmp/hgtest2 $ hg commit -m "Added foo.txt"
  >   > /tmp/hgtest2 $ hg branch bar
  >   > marked working directory as branch bar
  >   > /tmp/hgtest2 $ echo bar > foo.txt
  >   > /tmp/hgtest2 $ hg commit -m "Changed foo to bar"
  >   > /tmp/hgtest2 $ hg update -r default
  >   > 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  >   > /tmp/hgtest2 $ echo frobozz > frobozz.txt
  >   > /tmp/hgtest2 $ hg add frobozz.txt 
  >   > /tmp/hgtest2 $ hg commit -m "Added frobozz.txt"
  >   > created new head
  >   > 
  >   > In either case, the symptoms are the same: if you open foo.txt in emacs,
  >   > the mode line says "Hg-1" instead of the expected "Hg-0", and if you hit
  > 
  > Do you get this behavior with "emacs -Q" ?
  > 
  > I can't reproduce this, I get Hg-0.  And the command used to get the version:
  > hg log -l1 foo.txt 
  > outputs version 0

Doh, never mind, I have my shell set to not clobber files, so
the file was not overwritten.

Your change seems to work fine for /tmp/hgtest/foo.txt

It does not for /tmp/hgtest2/foo.txt.  C-x v g quite likely does not
work because it tries to annotate version "1".

Not sure how to get the correct version.  Can it be obtained with 
"log --template" ?