hgext3rd/topic/topicmap.py
changeset 1950 99c1a26abf3f
parent 1949 79c08d17a3d7
child 1953 bdc5bb223b50
--- 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)