[PATCH STABLE] log --follow shouldn't depend on the working dir context

Christian Boos cboos at edgewall.org
Mon Jun 11 18:12:14 CDT 2012


On 6/11/2012 11:26 PM, Mads Kiilerich wrote:> Christian Boos wrote, On 
06/11/2012 10:39 PM:
 >> log: --follow shouldn't depend on the the working dir context.
 >>
 >> This is a follow-up to 60101427d618, which broke TracMercurial
 >> and presumably any other tool which expected to be able to use
 >> walkchangerevs without a working copy or which didn't care at
 >> which revision the working copy was.
 >>
 >> Fix suggested by Patrick Mézard on #mercurial.
 >
 > Hi,
 >
 > This patch should include a test that can be used to verify that it is a
 > regression and to ensure it won't happen again.
 >

I added a test for the corrected behavior, right before a test
added in 60101427d618. It shows that we should be able to expect the
same output regardless of the revision at which the working directory
is. The working directory revision should only be used as a default
when no explicit range is given.

However that test also fails with a different error
("cannot follow nonexistent file") in revisions prior to 60101427d618,
so by itself my test doesn't prove that this revision introduced a
regression. I will continue to look for another test that also
demonstrates the regression. There must be one, as with TracMercurial I
can get the log of a file for a repository with the working copy at
revision null if I use Mercurial 2.0.1 or 2.1, but no longer with 2.1.1
(and of course, with 2.1.1 + the present patch, it works again).

-- Christian


# HG changeset patch
# User Christian Boos <cboos at edgewall.org>
# Date 1339440591 -7200
# Branch stable
# Node ID 05afd0bb73fcfe914a961773aadd6e1d28650f0b
# Parent  15159abc5ab68050e9a19cc1c74240a937dd1a85
log: --follow shouldn't depend on the the working dir context.

This is a follow-up to 60101427d618, which broke TracMercurial
and presumably any other tool which expected to be able to use
walkchangerevs without a working copy or which didn't care at
which revision the working copy was.

Fix suggested by Patrick Mézard on #mercurial.

diff -r 15159abc5ab6 -r 05afd0bb73fc mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Wed Jun 06 21:17:20 2012 -0500
+++ b/mercurial/cmdutil.py	Mon Jun 11 20:49:51 2012 +0200
@@ -999,6 +999,7 @@
      revs = scmutil.revrange(repo, opts['rev'] or [defrange])
      if not revs:
          return []
+    pctx = repo[revs[0]]
      wanted = set()
      slowpath = match.anypats() or (match.files() and opts.get('removed'))
      fncache = {}
@@ -1047,7 +1048,6 @@

              return reversed(revs)
          def iterfiles():
-            pctx = repo['.']
              for filename in match.files():
                  if follow:
                      if filename not in pctx:
diff -r 15159abc5ab6 -r 05afd0bb73fc tests/test-log.t
--- a/tests/test-log.t	Wed Jun 06 21:17:20 2012 -0500
+++ b/tests/test-log.t	Mon Jun 11 20:49:51 2012 +0200
@@ -191,6 +191,17 @@



+-f and multile filelog heads, independent of working dir revision
+
+  $ hg up -q null
+  $ hg log -f g --template '{rev}\n' -r2:0
+  2
+  1
+  0
+  $ hg log -f g --template '{rev}\n' -rtip:0
+  3
+  2
+  0

  -f and multiple filelog heads



More information about the Mercurial-devel mailing list