# HG changeset patch # User Anton Shestakov # Date 1710781300 10800 # Node ID 0674b56d352669dec226993eb4c1dcc9e2b2c117 # Parent 9638df99836ff44a2c4296dc82c408d7d9a2461c topic: drop oldbranchmap context manager, _topiccache is now a mixin I think this hack was needed back then in d49f75eab6a3 because _topiccache was a subclass of branchmap.branchcache directly, but now it's a mixin. In any case, I didn't see any failures in the tests, so it should be fine. diff -r 9638df99836f -r 0674b56d3526 hgext3rd/topic/topicmap.py --- a/hgext3rd/topic/topicmap.py Tue Jun 25 17:10:03 2024 +0400 +++ b/hgext3rd/topic/topicmap.py Mon Mar 18 14:01:40 2024 -0300 @@ -1,4 +1,3 @@ -import contextlib import hashlib from mercurial.i18n import _ @@ -151,29 +150,15 @@ finally: repo._autobranchmaptopic = previous -# needed to prevent reference used for 'super()' call using in branchmap.py to -# no go into cycle. (yes, URG) -_oldbranchmap = branchmap.branchcache - -@contextlib.contextmanager -def oldbranchmap(): - previous = branchmap.branchcache - try: - branchmap.branchcache = _oldbranchmap - yield - finally: - branchmap.branchcache = previous - class _topiccache(object): # combine me with branchmap.branchcache def __init__(self, *args, **kwargs): - # super() call may fail otherwise - with oldbranchmap(): - super(_topiccache, self).__init__(*args, **kwargs) + super(_topiccache, self).__init__(*args, **kwargs) self.phaseshash = None def copy(self): """return an deep copy of the branchcache object""" + assert isinstance(self, (branchmap.branchcache, branchmap.remotebranchcache)) # help pytype entries = compat.bcentries(self) args = (entries, self.tipnode, self.tiprev, self.filteredhash, self._closednodes) @@ -188,6 +173,7 @@ """call branchmap.load(), and then transform branch names to be in the new "//" format """ + assert isinstance(self, branchmap.branchcache) # help pytype super(_topiccache, self).load(repo, lineiter) entries = compat.bcentries(self) @@ -201,6 +187,7 @@ - False when cached tipnode is unknown or if we detect a strip. - True when cache is up to date or a subset of current repo.""" + assert isinstance(self, (branchmap.branchcache, branchmap.remotebranchcache)) # help pytype valid = super(_topiccache, self).validfor(repo) if not valid: return False @@ -237,6 +224,7 @@ missing heads, and a generator of nodes that are strictly a superset of heads missing, this function updates self to be correct. """ + assert isinstance(self, (branchmap.branchcache, branchmap.remotebranchcache)) # help pytype if not istopicfilter(repo.filtername): return super(_topiccache, self).update(repo, revgen)