hgext/largefiles/__init__.py
changeset 41065 0840862977c8
parent 41062 0a7f582f6f1f
child 41067 f2601cbce209
--- a/hgext/largefiles/__init__.py	Mon Dec 24 17:04:37 2018 +0530
+++ b/hgext/largefiles/__init__.py	Sun Dec 23 23:01:51 2018 -0500
@@ -107,10 +107,15 @@
 from __future__ import absolute_import
 
 from mercurial import (
+    cmdutil,
     configitems,
+    extensions,
     exthelper,
     hg,
+    httppeer,
     localrepo,
+    sshpeer,
+    wireprotov1server,
 )
 
 from . import (
@@ -118,7 +123,6 @@
     overrides,
     proto,
     reposetup,
-    uisetup as uisetupmod,
 )
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@@ -156,6 +160,36 @@
 def _uisetup(ui):
     localrepo.featuresetupfuncs.add(featuresetup)
     hg.wirepeersetupfuncs.append(proto.wirereposetup)
-    uisetupmod.uisetup(ui)
+
+    cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
+    cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
+
+    # create the new wireproto commands ...
+    wireprotov1server.wireprotocommand('putlfile', 'sha', permission='push')(
+        proto.putlfile)
+    wireprotov1server.wireprotocommand('getlfile', 'sha', permission='pull')(
+        proto.getlfile)
+    wireprotov1server.wireprotocommand('statlfile', 'sha', permission='pull')(
+        proto.statlfile)
+    wireprotov1server.wireprotocommand('lheads', '', permission='pull')(
+        wireprotov1server.heads)
+
+    extensions.wrapfunction(wireprotov1server.commands['heads'], 'func',
+                            proto.heads)
+    # TODO also wrap wireproto.commandsv2 once heads is implemented there.
+
+    # can't do this in reposetup because it needs to have happened before
+    # wirerepo.__init__ is called
+    proto.ssholdcallstream = sshpeer.sshv1peer._callstream
+    proto.httpoldcallstream = httppeer.httppeer._callstream
+    sshpeer.sshv1peer._callstream = proto.sshrepocallstream
+    httppeer.httppeer._callstream = proto.httprepocallstream
+
+    # override some extensions' stuff as well
+    for name, module in extensions.extensions():
+        if name == 'rebase':
+            # TODO: teach exthelper to handle this
+            extensions.wrapfunction(module, 'rebase',
+                                    overrides.overriderebase)
 
 revsetpredicate = overrides.revsetpredicate