comparison mercurial/context.py @ 43760:1e87851dba63

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
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 17 Nov 2019 06:06:38 +0100
parents e035a8f71d52
children f9068413bd0c
comparison
equal deleted inserted replaced
43759:1a415548794a 43760:1e87851dba63
475 class changectx(basectx): 475 class changectx(basectx):
476 """A changecontext object makes access to data related to a particular 476 """A changecontext object makes access to data related to a particular
477 changeset convenient. It represents a read-only context already present in 477 changeset convenient. It represents a read-only context already present in
478 the repo.""" 478 the repo."""
479 479
480 def __init__(self, repo, rev, node): 480 def __init__(self, repo, rev, node, maybe_filtered=True):
481 super(changectx, self).__init__(repo) 481 super(changectx, self).__init__(repo)
482 self._rev = rev 482 self._rev = rev
483 self._node = node 483 self._node = node
484 # When maybe_filtered is True, the revision might be affected by
485 # changelog filtering and operation through the filtered changelog must be used.
486 #
487 # When maybe_filtered is False, the revision has already been checked
488 # against filtering and is not filtered. Operation through the
489 # unfiltered changelog might be used in some case.
490 self._maybe_filtered = maybe_filtered
484 491
485 def __hash__(self): 492 def __hash__(self):
486 try: 493 try:
487 return hash(self._rev) 494 return hash(self._rev)
488 except AttributeError: 495 except AttributeError:
493 500
494 __bool__ = __nonzero__ 501 __bool__ = __nonzero__
495 502
496 @propertycache 503 @propertycache
497 def _changeset(self): 504 def _changeset(self):
498 return self._repo.changelog.changelogrevision(self.rev()) 505 if self._maybe_filtered:
506 repo = self._repo
507 else:
508 repo = self._repo.unfiltered()
509 return repo.changelog.changelogrevision(self.rev())
499 510
500 @propertycache 511 @propertycache
501 def _manifest(self): 512 def _manifest(self):
502 return self._manifestctx.read() 513 return self._manifestctx.read()
503 514