Mercurial > evolve
changeset 6748:c6ff8ae8a752
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.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Mon, 18 Mar 2024 14:01:40 -0300 |
parents | 61a356e23921 |
children | 6adcc5c7c1f1 |
files | hgext3rd/topic/topicmap.py |
diffstat | 1 files changed, 5 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/topicmap.py Sat Jan 13 17:34:37 2024 -0300 +++ b/hgext3rd/topic/topicmap.py Mon Mar 18 14:01:40 2024 -0300 @@ -1,4 +1,3 @@ -import contextlib import functools import hashlib @@ -142,30 +141,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, _oldbranchmap) # help pytype + assert isinstance(self, (branchmap.branchcache, branchmap.remotebranchcache)) # help pytype args = (self._entries, self.tipnode, self.tiprev, self.filteredhash, self._closednodes) if util.safehasattr(self, '_repo'): @@ -179,7 +163,7 @@ """call branchmap.load(), and then transform branch names to be in the new "//" format """ - assert isinstance(self, _oldbranchmap) # help pytype + assert isinstance(self, branchmap.branchcache) # help pytype super(_topiccache, self).load(repo, lineiter) for branch in tuple(self._entries): @@ -192,7 +176,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, _oldbranchmap) # help pytype + assert isinstance(self, (branchmap.branchcache, branchmap.remotebranchcache)) # help pytype valid = super(_topiccache, self).validfor(repo) if not valid: return False @@ -228,7 +212,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, _oldbranchmap) # help pytype + assert isinstance(self, (branchmap.branchcache, branchmap.remotebranchcache)) # help pytype if not istopicfilter(repo.filtername): return super(_topiccache, self).update(repo, revgen)