Patchwork [3,of,8,V6] context: spell out the logic around linkrev adjustement starting point

login
register
mail settings
Submitter Boris Feld
Date Nov. 19, 2018, 4:49 p.m.
Message ID <7c37df72e30462089a76.1542646182@localhost.localdomain>
Download mbox | patch
Permalink /patch/36649/
State Accepted
Headers show

Comments

Boris Feld - Nov. 19, 2018, 4:49 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1539125370 -7200
#      Wed Oct 10 00:49:30 2018 +0200
# Node ID 7c37df72e30462089a76be6f3b752f4e374d949b
# Parent  633fcd53410ff023898f19539f1e5fe50edfd68d
# EXP-Topic copy-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 7c37df72e304
context: spell out the logic around linkrev adjustement starting point

We make the intent of the `_changeid` and `_changectx` checks 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
@@ -771,10 +771,17 @@  class basefilectx(object):
         'linkrev-shadowing' when a file revision is used by multiple
         changesets.
         """
+        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()