Patchwork D3178: largefiles: wrap heads command handler more directly

login
register
mail settings
Submitter phabricator
Date April 7, 2018, 5:53 a.m.
Message ID <differential-rev-PHID-DREV-2fbncel23fbffau2qwxh-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30524/
State Superseded
Headers show

Comments

phabricator - April 7, 2018, 5:53 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3178

AFFECTED FILES
  hgext/largefiles/proto.py
  hgext/largefiles/uisetup.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

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 @@ 
         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)
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 @@ 
     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'):