[PATCH 2 of 2 STABLE] log: fix regression of log -rREV FILE when REV isnt the last file revision

Nicolas Dumazet nicdumz at gmail.com
Wed Nov 10 11:17:16 CST 2010


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1289409037 -32400
# Node ID 93b23735c1dae52f9cc5c10e49f2baeafc23e67e
# Parent  ecf4c5747824d244647cbb44e7f6f681ec0f9e2a
log: fix regression of log -rREV FILE when REV isnt the last file revision

Introduced in 99cafcae25d9. That previous commit is not supposed to affect
log calls without --follow, so we step out of this codepath if follow is
not True, and it's enough to fix the regression.

When --follow is given, we fix the issue by taking into account changesets
that have a rev > maxrev to build the filegraph: even if those files are not
included in the final result, it's still needed to walk correctly the graph
from the end of the filelog to minrev, to track accurately renames.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1185,11 +1185,20 @@
 
             # iterate from latest to oldest revision
             for rev, flparentlinkrevs, copied in filerevgen(filelog, last):
-                if rev > maxrev or rev not in ancestors:
-                    continue
-                # XXX insert 1327 fix here
-                if flparentlinkrevs:
-                    ancestors.update(flparentlinkrevs)
+                if not follow:
+                    if rev > maxrev:
+                        continue
+                else:
+                    # Note that last might not be the first interesting
+                    # rev to us:
+                    # if the file has been changed after maxrev, we'll
+                    # have linkrev(last) > maxrev, and we still need
+                    # to explore the file graph
+                    if rev not in ancestors:
+                        continue
+                    # XXX insert 1327 fix here
+                    if flparentlinkrevs:
+                        ancestors.update(flparentlinkrevs)
 
                 fncache.setdefault(rev, []).append(file_)
                 wanted.add(rev)
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -1020,6 +1020,15 @@
   summary:     add foo, related
   
 
+Also check when maxrev < lastrevfilelog
+
+  $ hg --traceback log -f -r4 foo
+  changeset:   4:88176d361b69
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add foo, related
+  
+
 Issue2383: hg log showing _less_ differences than hg diff
 
   $ hg init issue2383
@@ -1092,3 +1101,19 @@
   +b
   
   $ cd ..
+
+'hg log -r rev fn' when last(filelog(fn)) != rev
+
+  $ hg init simplelog; cd simplelog
+  $ echo f > a
+  $ hg ci -Am'a' -d '0 0'
+  adding a
+  $ echo f >> a
+  $ hg ci -Am'a bis' -d '1 0'
+
+  $ hg log -r0 a
+  changeset:   0:9f758d63dcde
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     a
+  


More information about the Mercurial-devel mailing list