diff -r 54810b543bf4 -r 79c08d17a3d7 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Wed Mar 30 22:05:49 2016 -0700 +++ b/hgext3rd/topic/__init__.py Wed Mar 30 22:25:17 2016 -0700 @@ -12,7 +12,6 @@ """ from __future__ import absolute_import -import contextlib import re from mercurial.i18n import _ @@ -92,28 +91,8 @@ discovery.modsetup(ui) setupimportexport(ui) -@contextlib.contextmanager -def usetopicmap(repo): - """use awful monkey patching to update the topic cache""" - oldbranchcache = branchmap.branchcache - oldfilename = branchmap._filename - oldread = branchmap.read - oldcaches = getattr(repo, '_branchcaches', {}) - try: - branchmap.branchcache = topicmap.topiccache - branchmap._filename = topicmap._filename - branchmap.read = topicmap.readtopicmap - repo._branchcaches = getattr(repo, '_topiccaches', {}) - yield - repo._topiccaches = repo._branchcaches - finally: - repo._branchcaches = oldcaches - branchmap.branchcache = oldbranchcache - branchmap._filename = oldfilename - branchmap.read = oldread - def cgapply(orig, repo, *args, **kwargs): - with usetopicmap(repo): + with topicmap.usetopicmap(repo): return orig(repo, *args, **kwargs) def reposetup(ui, repo): @@ -148,7 +127,7 @@ not self.currenttopic): # we are amending and need to remove a topic del ctx.extra()[constants.extrakey] - with usetopicmap(self): + with topicmap.usetopicmap(self): return orig.commitctx(self, ctx, error=error) @property @@ -166,12 +145,12 @@ def branchmap(self, topic=True): if not topic: super(topicrepo, self).branchmap() - with usetopicmap(self): + with topicmap.usetopicmap(self): branchmap.updatecache(self) return self._topiccaches[self.filtername] def destroyed(self, *args, **kwargs): - with usetopicmap(self): + with topicmap.usetopicmap(self): return super(topicrepo, self).destroyed(*args, **kwargs) def invalidatecaches(self):