# HG changeset patch # User Pierre-Yves David # Date 2019-11-17 05:06:38 # Node ID 1e87851dba63e6f3ca5e471cedc5be4a76506639 # Parent 1a415548794a5e99a7744116f83f10f966f2c6fa changectx: add a "maybe filtered" filtered attribute There are changeset that we know not to be filtered (eg: `null`). In this case, we could access some information without triggering changelog filtering. We add an attribute to changectx that track this property. Differential Revision: https://phab.mercurial-scm.org/D7483 diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -477,10 +477,17 @@ class changectx(basectx): changeset convenient. It represents a read-only context already present in the repo.""" - def __init__(self, repo, rev, node): + def __init__(self, repo, rev, node, maybe_filtered=True): super(changectx, self).__init__(repo) self._rev = rev self._node = node + # When maybe_filtered is True, the revision might be affected by + # changelog filtering and operation through the filtered changelog must be used. + # + # When maybe_filtered is False, the revision has already been checked + # against filtering and is not filtered. Operation through the + # unfiltered changelog might be used in some case. + self._maybe_filtered = maybe_filtered def __hash__(self): try: @@ -495,7 +502,11 @@ class changectx(basectx): @propertycache def _changeset(self): - return self._repo.changelog.changelogrevision(self.rev()) + if self._maybe_filtered: + repo = self._repo + else: + repo = self._repo.unfiltered() + return repo.changelog.changelogrevision(self.rev()) @propertycache def _manifest(self):