Mercurial > hg
changeset 35507:95a9be56c3bb
largefiles: modernize how capabilities are added to the wire protocol
See 982f13bef503, which came well after this code was originally written.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 26 Dec 2017 23:40:49 -0500 |
parents | fa865878a849 |
children | 9b3f95d9783d |
files | hgext/largefiles/proto.py hgext/largefiles/uisetup.py |
diffstat | 2 files changed, 6 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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