Mercurial > hg
changeset 40692:f3f4d8537b11
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.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 10 Oct 2018 00:49:30 +0200 |
parents | a65fe13de84f |
children | aee94f0a36cd |
files | mercurial/context.py |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Mon Nov 19 14:14:56 2018 +0000 +++ b/mercurial/context.py Wed Oct 10 00:49:30 2018 +0200 @@ -769,10 +769,17 @@ '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()