changeset 23705:28a302e9225d

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 24 Dec 2014 03:26:48 -0800
parents c624fb2c4239
children 3314664606e6
files mercurial/context.py tests/test-annotate.t
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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 ..