# HG changeset patch # User Boris Feld # Date 2018-10-09 22:49:30 # Node ID f3f4d8537b11d5ba7c1b6323c784478741e46008 # Parent a65fe13de84f48db9537e7ba03cdb0720042bfb7 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. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -769,10 +769,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()