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

login
register
mail settings
Submitter Boris Feld
Date Oct. 4, 2018, 2:44 p.m.
Message ID <1f9af0d6ead8404e8b9c.1538664278@localhost.localdomain>
Download mbox | patch
Permalink /patch/35452/
State Accepted
Headers show

Comments

Boris Feld - Oct. 4, 2018, 2:44 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@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.

Patch

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()