# HG changeset patch # User Matt Harbison # Date 1514349649 18000 # Node ID 95a9be56c3bb614fc1334a4cc8ec669f9eb7bc5a # Parent fa865878a849e357daed3f605a5b30685504b777 largefiles: modernize how capabilities are added to the wire protocol See 982f13bef503, which came well after this code was originally written. diff -r fa865878a849 -r 95a9be56c3bb hgext/largefiles/proto.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 diff -r fa865878a849 -r 95a9be56c3bb hgext/largefiles/uisetup.py --- 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