largefiles: wrap heads command handler more directly
authorGregory Szorc <gregory.szorc@gmail.com>
Wed, 28 Mar 2018 10:52:40 -0700
changeset 37484 c22fd3c4c23e
parent 37483 61e405fb6372
child 37485 0b7475ea38cf
largefiles: wrap heads command handler more directly extensions.wrapfunction() is a more robust method for wrapping a function, since it allows multiple wrappers. While we're here, wrap the function registered with the command instead of installing a new command handler. Differential Revision: https://phab.mercurial-scm.org/D3178
hgext/largefiles/proto.py
hgext/largefiles/uisetup.py
--- a/hgext/largefiles/proto.py	Wed Mar 28 15:09:34 2018 -0700
+++ b/hgext/largefiles/proto.py	Wed Mar 28 10:52:40 2018 -0700
@@ -168,12 +168,13 @@
     caps.append('largefiles=serve')
     return caps
 
-def heads(repo, proto):
+def heads(orig, repo, proto):
     '''Wrap server command - largefile capable clients will know to call
     lheads instead'''
     if lfutil.islfilesrepo(repo):
         return wireprototypes.ooberror(LARGEFILES_REQUIRED_MSG)
-    return wireproto.heads(repo, proto)
+
+    return orig(repo, proto)
 
 def sshrepocallstream(self, cmd, **args):
     if cmd == 'heads' and self.capable('largefiles'):
--- a/hgext/largefiles/uisetup.py	Wed Mar 28 15:09:34 2018 -0700
+++ b/hgext/largefiles/uisetup.py	Wed Mar 28 10:52:40 2018 -0700
@@ -174,7 +174,7 @@
         wireproto.heads)
 
     # ... and wrap some existing ones
-    wireproto.commands['heads'].func = proto.heads
+    extensions.wrapfunction(wireproto.commands['heads'], 'func', proto.heads)
     # TODO also wrap wireproto.commandsv2 once heads is implemented there.
 
     extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)