largefiles: modernize how capabilities are added to the wire protocol
authorMatt Harbison <matt_harbison@yahoo.com>
Tue, 26 Dec 2017 23:40:49 -0500
changeset 35507 95a9be56c3bb
parent 35506 fa865878a849
child 35508 9b3f95d9783d
largefiles: modernize how capabilities are added to the wire protocol See 982f13bef503, which came well after this code was originally written.
hgext/largefiles/proto.py
hgext/largefiles/uisetup.py
--- a/hgext/largefiles/proto.py	Sat Dec 23 17:49:12 2017 -0500
+++ b/hgext/largefiles/proto.py	Tue Dec 26 23:40:49 2017 -0500
@@ -28,7 +28,6 @@
                            'file.\n')
 
 # these will all be replaced by largefiles.uisetup
-capabilitiesorig = None
 ssholdcallstream = None
 httpoldcallstream = None
 
@@ -161,9 +160,11 @@
     repo.__class__ = lfileswirerepository
 
 # advertise the largefiles=serve capability
-def capabilities(repo, proto):
-    '''Wrap server command to announce largefile server capability'''
-    return capabilitiesorig(repo, proto) + ' largefiles=serve'
+def _capabilities(orig, repo, proto):
+    '''announce largefile server capability'''
+    caps = orig(repo, proto)
+    caps.append('largefiles=serve')
+    return caps
 
 def heads(repo, proto):
     '''Wrap server command - largefile capable clients will know to call
--- a/hgext/largefiles/uisetup.py	Sat Dec 23 17:49:12 2017 -0500
+++ b/hgext/largefiles/uisetup.py	Tue Dec 26 23:40:49 2017 -0500
@@ -166,7 +166,6 @@
     wireproto.commands['statlfile'] = (proto.statlfile, 'sha')
 
     # ... and wrap some existing ones
-    wireproto.commands['capabilities'] = (proto.capabilities, '')
     wireproto.commands['heads'] = (proto.heads, '')
     wireproto.commands['lheads'] = (wireproto.heads, '')
 
@@ -178,10 +177,7 @@
 
     extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
 
-    # the hello wireproto command uses wireproto.capabilities, so it won't see
-    # our largefiles capability unless we replace the actual function as well.
-    proto.capabilitiesorig = wireproto.capabilities
-    wireproto.capabilities = proto.capabilities
+    extensions.wrapfunction(wireproto, '_capabilities', proto._capabilities)
 
     # can't do this in reposetup because it needs to have happened before
     # wirerepo.__init__ is called