filectx: use _descendantrev in parents() stable
authorMatt Mackall <mpm@selenic.com>
Sun, 01 Feb 2015 16:33:45 -0600
branchstable
changeset 23984 2896f53509a7
parent 23983 ff070a53ee74
child 23987 fbdd5195528f
filectx: use _descendantrev in parents() This lets us be lazy about linkrev adjustments when tracing history.
mercurial/context.py
--- a/mercurial/context.py	Sun Feb 01 16:26:35 2015 -0600
+++ b/mercurial/context.py	Sun Feb 01 16:33:45 2015 -0600
@@ -835,11 +835,15 @@
                 # If self is associated with a changeset (probably explicitly
                 # fed), ensure the created filectx is associated with a
                 # changeset that is an ancestor of self.changectx.
-                rev = self._adjustlinkrev(path, l, fnode, self.rev())
-                fctx = filectx(self._repo, path, fileid=fnode, filelog=l,
-                               changeid=rev)
+                # This lets us later use _adjustlinkrev to get a correct link.
+                fctx = filectx(self._repo, path, fileid=fnode, filelog=l)
+                fctx._descendantrev = self.rev()
                 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None)
-
+            elif '_descendantrev' in vars(self):
+                # Otherwise propagate _descendantrev if we have one associated.
+                fctx = filectx(self._repo, path, fileid=fnode, filelog=l)
+                fctx._descendantrev = self._descendantrev
+                fctx._ancestrycontext = getattr(self, '_ancestrycontext', None)
             else:
                 fctx = filectx(self._repo, path, fileid=fnode, filelog=l)
             ret.append(fctx)