[PATCH 04 of 10 V4] context: spell out the logic around linkrev adjustement starting point

Boris Feld boris.feld at octobus.net
Thu Oct 4 10:44:38 EDT 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1538609153 -7200
#      Thu Oct 04 01:25:53 2018 +0200
# Node ID 1f9af0d6ead8404e8b9c242691e68a8af703ef0e
# Parent  0b56b3fd5e9fa1125d1d279b668a873b90bed7c9
# EXP-Topic copy-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1f9af0d6ead8
context: spell out the logic around linkrev adjustement starting point

We make the intend of the `_changeid` and `_changectx` check explicit. The
same logic was previously performed by the `self.rev()` call. The new code is
a bit redundant, but much clearer.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -776,11 +776,17 @@ class basefilectx(object):
         'linkrev-shadowing' when a file revision is used by multiple
         changesets.
         """
-        lkr = self.linkrev()
+        toprev = None
         attrs = vars(self)
-        hastoprev = (r'_changeid' in attrs or r'_changectx' in attrs)
-        if hastoprev:
-            return self._adjustlinkrev(self.rev(), inclusive=True)
+        if r'_changeid' in attrs:
+            # We have a cached value already
+            toprev = self._changeid
+        elif r'_changectx' in attrs:
+            # We know which changelog entry we are coming from
+            toprev = self._changectx.rev()
+
+        if toprev is not None:
+            return self._adjustlinkrev(toprev, inclusive=True)
         else:
             return self.linkrev()
 


More information about the Mercurial-devel mailing list