linkrev: also adjust linkrev when bootstrapping annotate (issue4305)
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 24 Dec 2014 03:26:48 -0800
changeset 23705 28a302e9225d
parent 23704 c624fb2c4239
child 23706 3314664606e6
linkrev: also adjust linkrev when bootstrapping annotate (issue4305) The annotate logic now use the new 'introrev' method to bootstrap its traversal. This catches issues from linkrev-shadowing of the changeset introducing the version of a file in source changeset. More tests have been added to display pathological cases.
mercurial/context.py
tests/test-annotate.t
--- a/mercurial/context.py	Mon Dec 29 23:40:24 2014 -0800
+++ b/mercurial/context.py	Wed Dec 24 03:26:48 2014 -0800
@@ -877,10 +877,11 @@
             return pl
 
         # use linkrev to find the first changeset where self appeared
-        if self.rev() != self.linkrev():
-            base = self.filectx(self.filenode())
-        else:
-            base = self
+        base = self
+        introrev = self.introrev()
+        if self.rev() != introrev:
+            base = filectx(self._repo, self._path, filelog=self.filelog(),
+                           fileid=self.filenode(), changeid=introrev)
 
         # This algorithm would prefer to be recursive, but Python is a
         # bit recursion-hostile. Instead we do an iterative
--- a/tests/test-annotate.t	Mon Dec 29 23:40:24 2014 -0800
+++ b/tests/test-annotate.t	Wed Dec 24 03:26:48 2014 -0800
@@ -510,4 +510,10 @@
   3: B
   4: C
 
+Even when the starting revision is the linkrev-shadowed one:
+
+  $ hg annotate a -r 3
+  0: A
+  3: B
+
   $ cd ..