changeset 1950:99c1a26abf3f

topicmap: move 'cgapply' wrapping into the topicmap module More gathering of related logic.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 30 Mar 2016 22:31:24 -0700
parents 79c08d17a3d7
children 0309cac5d91d
files hgext3rd/topic/__init__.py hgext3rd/topic/topicmap.py
diffstat 2 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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)