From patchwork Wed Oct 3 19:10:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5, of, 8, V3] context: introduce a `_findchangerev` method to `filectx` From: Boris Feld X-Patchwork-Id: 35420 Message-Id: <964fbe39ab182eb0d658.1538593848@localhost.localdomain> To: mercurial-devel@mercurial-scm.org Cc: gregory.szorc@gmail.com Date: Wed, 03 Oct 2018 21:10:48 +0200 # HG changeset patch # User Boris Feld # Date 1536255775 14400 # Thu Sep 06 13:42:55 2018 -0400 # Node ID 964fbe39ab182eb0d65830dc87ef39d0382a41fa # Parent 759af590645e2f0cc6fbed2b7b97ed718e277dc5 # EXP-Topic copy-perf # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 964fbe39ab18 context: introduce a `_findchangerev` method to `filectx` In the same spirit as `_introrev` we want to introduce a way to limit graph walking when resolving `filectx.rev()`. We introduce a new internal function for this purpose. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -567,16 +567,21 @@ class basefilectx(object): @propertycache def _changeid(self): + return self._findchangerev() + + def _findchangerev(self): if r'_changeid' in self.__dict__: - return self._changeid + changeid = self._changeid elif r'_changectx' in self.__dict__: - return self._changectx.rev() + changeid = self._changectx.rev() elif r'_descendantrev' in self.__dict__: # this file context was created from a revision with a known # descendant, we can (lazily) correct for linkrev aliases - return self._adjustlinkrev(self._descendantrev) + changeid = self._adjustlinkrev(self._descendantrev) else: - return self._filelog.linkrev(self._filerev) + changeid = self._filelog.linkrev(self._filerev) + self._changeid = changeid + return changeid @propertycache def _filenode(self): @@ -810,7 +815,7 @@ class basefilectx(object): else: return self._adjustlinkrev(rev, inclusive=True) else: - return self.rev() + return self._findchangerev() def introfilectx(self): """Return filectx having identical contents, but pointing to the