Patchwork D2018: largefiles: register wire protocol commands with modern APIs

login
register
mail settings
Submitter phabricator
Date Feb. 3, 2018, 1:50 a.m.
Message ID <differential-rev-PHID-DREV-n2ro5ugvjdmowy25j3ka-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27248/
State Superseded
Headers show

Comments

phabricator - Feb. 3, 2018, 1:50 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The wireproto.wireprotocommand decorator is the preferred mechanism for
  registering wire protocol commands. In addition, wireproto.commands
  is no longer a 2-tuple and use of that 2-tuple API should be considered
  deprecated.
  
  This commit ports largefiles to use wireproto.wireprotocommand()
  and ports to the "commandentry" API.
  
  As part of this, the definition of the "lheads" wire protocol
  command is moved to the proper stanza.
  
  We stop short of actually using wireprotocommand as a decorator
  in order to minimize churn. We should ideally move wire protocol
  commands to the registrar mechanism. But that's for another
  changeset.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  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
@@ -165,13 +165,13 @@ 
                             overrides.openlargefile)
 
     # create the new wireproto commands ...
-    wireproto.commands['putlfile'] = (proto.putlfile, 'sha')
-    wireproto.commands['getlfile'] = (proto.getlfile, 'sha')
-    wireproto.commands['statlfile'] = (proto.statlfile, 'sha')
+    wireproto.wireprotocommand('putlfile', 'sha')(proto.putlfile)
+    wireproto.wireprotocommand('getlfile', 'sha')(proto.getlfile)
+    wireproto.wireprotocommand('statlfile', 'sha')(proto.statlfile)
+    wireproto.wireprotocommand('lheads', '')(wireproto.heads)
 
     # ... and wrap some existing ones
-    wireproto.commands['heads'] = (proto.heads, '')
-    wireproto.commands['lheads'] = (wireproto.heads, '')
+    wireproto.commands['heads'].func = proto.heads
 
     # make putlfile behave the same as push and {get,stat}lfile behave
     # the same as pull w.r.t. permissions checks