diff mercurial/cmdutil.py @ 16165:60101427d618 stable

log: fix --follow FILE ancestry calculation Currently, --follow FILE looks for a FILE filelog, scans it and collects linkrevs and renames, then filters them. The problem is the filelog scan does not start at FILE filenode in parent revision but at the last filelog revision. So: - Files not in the parent revision can be followed, the starting node is unexpected - Files in the parent revision can be followed from an incorrect starting node. This patch makes log --follow FILE fail if FILE is not in parent revision, and computes ancestors of the parent revision FILE filenode.
author Patrick Mezard <patrick@mezard.eu>
date Fri, 24 Feb 2012 20:57:59 +0100
parents f7e0d95d0a0b
children 6c4dbe28dda3
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Feb 24 20:56:18 2012 +0100
+++ b/mercurial/cmdutil.py	Fri Feb 24 20:57:59 2012 +0100
@@ -1024,8 +1024,15 @@
 
             return reversed(revs)
         def iterfiles():
+            pctx = repo['.']
             for filename in match.files():
-                yield filename, None
+                if follow:
+                    if filename not in pctx:
+                        raise util.Abort(_('cannot follow file not in parent '
+                                           'revision: "%s"') % filename)
+                    yield filename, pctx[filename].filenode()
+                else:
+                    yield filename, None
             for filename_node in copies:
                 yield filename_node
         for file_, node in iterfiles():