# HG changeset patch # User Gregory Szorc # Date 2018-03-28 17:52:40 # Node ID c22fd3c4c23ee3cd91a9756a4f803fd4fd9ffa43 # Parent 61e405fb63724605f83c210117f1e19a5aaae24e 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 diff --git a/hgext/largefiles/proto.py b/hgext/largefiles/proto.py --- a/hgext/largefiles/proto.py +++ b/hgext/largefiles/proto.py @@ -168,12 +168,13 @@ def _capabilities(orig, repo, proto): 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'): diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py --- a/hgext/largefiles/uisetup.py +++ b/hgext/largefiles/uisetup.py @@ -174,7 +174,7 @@ def uisetup(ui): 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)