topicmap: move 'cgapply' wrapping into the topicmap module
More gathering of related logic.
--- a/hgext3rd/topic/__init__.py Wed Mar 30 22:25:17 2016 -0700
+++ b/hgext3rd/topic/__init__.py Wed Mar 30 22:31:24 2016 -0700
@@ -17,7 +17,6 @@
from mercurial.i18n import _
from mercurial import (
branchmap,
- changegroup,
cmdutil,
commands,
context,
@@ -91,10 +90,6 @@
discovery.modsetup(ui)
setupimportexport(ui)
-def cgapply(orig, repo, *args, **kwargs):
- with topicmap.usetopicmap(repo):
- return orig(repo, *args, **kwargs)
-
def reposetup(ui, repo):
orig = repo.__class__
if not isinstance(repo, localrepo.localrepository):
@@ -343,6 +338,5 @@
extensions.wrapfunction(cmdutil, 'buildcommittext', committextwrap)
extensions.wrapfunction(merge, 'update', mergeupdatewrap)
-extensions.wrapfunction(changegroup.cg1unpacker, 'apply', cgapply)
cmdutil.summaryhooks.add('topic', summaryhook)
--- a/hgext3rd/topic/topicmap.py Wed Mar 30 22:25:17 2016 -0700
+++ b/hgext3rd/topic/topicmap.py Wed Mar 30 22:31:24 2016 -0700
@@ -3,8 +3,10 @@
from mercurial.node import hex, bin, nullid
from mercurial import (
branchmap,
+ changegroup,
encoding,
error,
+ extensions,
scmutil,
util,
)
@@ -60,6 +62,11 @@
branchmap._filename = oldfilename
branchmap.read = oldread
+def cgapply(orig, repo, *args, **kwargs):
+ """make sure a topicmap is used when applying a changegroup"""
+ with usetopicmap(repo):
+ return orig(repo, *args, **kwargs)
+
class topiccache(oldbranchcache):
def __init__(self, *args, **kwargs):
@@ -225,3 +232,7 @@
repo.ui.debug(msg % inst)
partial = None
return partial
+
+def modsetup(ui):
+ """call at uisetup time to install various wrappings"""
+ extensions.wrapfunction(changegroup.cg1unpacker, 'apply', cgapply)