Patchwork D3400: wireproto: rename wireproto to wireprotov1server (API)

login
register
mail settings
Submitter phabricator
Date April 18, 2018, 6:41 p.m.
Message ID <ce46380a3632f33d9bb2f6ad3bec06d4@localhost.localdomain>
Download mbox | patch
Permalink /patch/31187/
State Not Applicable
Headers show

Comments

phabricator - April 18, 2018, 6:41 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb4d85bc122bd: wireproto: rename wireproto to wireprotov1server (API) (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3400?vs=8371&id=8389

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

AFFECTED FILES
  hgext/clonebundles.py
  hgext/infinitepush/__init__.py
  hgext/largefiles/uisetup.py
  hgext/lfs/__init__.py
  mercurial/sshpeer.py
  mercurial/wireproto.py
  mercurial/wireprotoserver.py
  mercurial/wireprotov1server.py
  tests/sshprotoext.py
  tests/test-http-permissions.t
  tests/test-sshserver.py
  tests/test-wireproto.py
  tests/wireprotohelpers.sh

CHANGE DETAILS




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

Patch

diff --git a/tests/wireprotohelpers.sh b/tests/wireprotohelpers.sh
--- a/tests/wireprotohelpers.sh
+++ b/tests/wireprotohelpers.sh
@@ -16,19 +16,19 @@ 
 cat > dummycommands.py << EOF
 from mercurial import (
     wireprototypes,
+    wireprotov1server,
     wireprotov2server,
-    wireproto,
 )
 
-@wireproto.wireprotocommand('customreadonly', permission='pull')
+@wireprotov1server.wireprotocommand('customreadonly', permission='pull')
 def customreadonlyv1(repo, proto):
     return wireprototypes.bytesresponse(b'customreadonly bytes response')
 
 @wireprotov2server.wireprotocommand('customreadonly', permission='pull')
 def customreadonlyv2(repo, proto):
     return wireprototypes.cborresponse(b'customreadonly bytes response')
 
-@wireproto.wireprotocommand('customreadwrite', permission='push')
+@wireprotov1server.wireprotocommand('customreadwrite', permission='push')
 def customreadwrite(repo, proto):
     return wireprototypes.bytesresponse(b'customreadwrite bytes response')
 
diff --git a/tests/test-wireproto.py b/tests/test-wireproto.py
--- a/tests/test-wireproto.py
+++ b/tests/test-wireproto.py
@@ -5,9 +5,9 @@ 
     pycompat,
     ui as uimod,
     util,
-    wireproto,
     wireprototypes,
     wireprotov1peer,
+    wireprotov1server,
 )
 stringio = util.stringio
 
@@ -55,7 +55,7 @@ 
 
     def _call(self, cmd, **args):
         args = pycompat.byteskwargs(args)
-        res = wireproto.dispatch(self.serverrepo, proto(args), cmd)
+        res = wireprotov1server.dispatch(self.serverrepo, proto(args), cmd)
         if isinstance(res, wireprototypes.bytesresponse):
             return res.data
         elif isinstance(res, bytes):
@@ -87,7 +87,7 @@ 
 def greet(repo, proto, name):
     return mangle(repo.greet(unmangle(name)))
 
-wireproto.commands[b'greet'] = (greet, b'name',)
+wireprotov1server.commands[b'greet'] = (greet, b'name')
 
 srv = serverrepo()
 clt = clientpeer(srv, uimod.ui())
diff --git a/tests/test-sshserver.py b/tests/test-sshserver.py
--- a/tests/test-sshserver.py
+++ b/tests/test-sshserver.py
@@ -6,8 +6,8 @@ 
 import silenttestrunner
 
 from mercurial import (
-    wireproto,
     wireprotoserver,
+    wireprotov1server,
 )
 
 from mercurial.utils import (
@@ -29,7 +29,7 @@ 
         proto = wireprotoserver.sshv1protocolhandler(server._ui,
                                                      server._fin,
                                                      server._fout)
-        _func, spec = wireproto.commands[cmd]
+        _func, spec = wireprotov1server.commands[cmd]
         self.assertEqual(proto.getargs(spec), expected)
 
 def mockserver(inbytes):
diff --git a/tests/test-http-permissions.t b/tests/test-http-permissions.t
--- a/tests/test-http-permissions.t
+++ b/tests/test-http-permissions.t
@@ -3,7 +3,7 @@ 
   $ cat > fakeremoteuser.py << EOF
   > import os
   > from mercurial.hgweb import hgweb_mod
-  > from mercurial import wireproto
+  > from mercurial import wireprotov1server
   > class testenvhgweb(hgweb_mod.hgweb):
   >     def __call__(self, env, respond):
   >         # Allow REMOTE_USER to define authenticated user.
@@ -15,16 +15,16 @@ 
   >         return super(testenvhgweb, self).__call__(env, respond)
   > hgweb_mod.hgweb = testenvhgweb
   > 
-  > @wireproto.wireprotocommand('customreadnoperm')
+  > @wireprotov1server.wireprotocommand('customreadnoperm')
   > def customread(repo, proto):
   >     return b'read-only command no defined permissions\n'
-  > @wireproto.wireprotocommand('customwritenoperm')
+  > @wireprotov1server.wireprotocommand('customwritenoperm')
   > def customwritenoperm(repo, proto):
   >     return b'write command no defined permissions\n'
-  > @wireproto.wireprotocommand('customreadwithperm', permission='pull')
+  > @wireprotov1server.wireprotocommand('customreadwithperm', permission='pull')
   > def customreadwithperm(repo, proto):
   >     return b'read-only command w/ defined permissions\n'
-  > @wireproto.wireprotocommand('customwritewithperm', permission='push')
+  > @wireprotov1server.wireprotocommand('customwritewithperm', permission='push')
   > def customwritewithperm(repo, proto):
   >     return b'write command w/ defined permissions\n'
   > EOF
diff --git a/tests/sshprotoext.py b/tests/sshprotoext.py
--- a/tests/sshprotoext.py
+++ b/tests/sshprotoext.py
@@ -15,8 +15,8 @@ 
     extensions,
     registrar,
     sshpeer,
-    wireproto,
     wireprotoserver,
+    wireprotov1server,
 )
 
 configtable = {}
@@ -50,7 +50,7 @@ 
         assert l == b'between\n'
         proto = wireprotoserver.sshv1protocolhandler(self._ui, self._fin,
                                                      self._fout)
-        rsp = wireproto.dispatch(self._repo, proto, b'between')
+        rsp = wireprotov1server.dispatch(self._repo, proto, b'between')
         wireprotoserver._sshv1respondbytes(self._fout, rsp.data)
 
         super(prehelloserver, self).serve_forever()
diff --git a/mercurial/wireproto.py b/mercurial/wireprotov1server.py
rename from mercurial/wireproto.py
rename to mercurial/wireprotov1server.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireprotov1server.py
@@ -1,4 +1,4 @@ 
-# wireproto.py - generic wire protocol support functions
+# wireprotov1server.py - Wire protocol version 1 server functionality
 #
 # Copyright 2005-2010 Matt Mackall <mpm@selenic.com>
 #
diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -24,8 +24,8 @@ 
     hook,
     pycompat,
     util,
-    wireproto,
     wireprototypes,
+    wireprotov1server,
     wireprotov2server,
 )
 from .utils import (
@@ -166,7 +166,7 @@ 
 # there are no other known users, so with any luck we can discard this
 # hook if remotefilelog becomes a first-party extension.
 def iscmd(cmd):
-    return cmd in wireproto.commands
+    return cmd in wireprotov1server.commands
 
 def handlewsgirequest(rctx, req, res, checkperm):
     """Possibly process a wire protocol request.
@@ -329,7 +329,7 @@ 
             return HGTYPE2, util._noopengine(), {}
 
         # Now find an agreed upon compression format.
-        compformats = wireproto.clientcompressionsupport(proto)
+        compformats = wireprotov1server.clientcompressionsupport(proto)
         for engine in wireprototypes.supportedcompengines(ui, util.SERVERROLE):
             if engine.wireprotosupport().name in compformats:
                 opts = {}
@@ -380,7 +380,7 @@ 
 
         descriptors[api] = descriptorfn(req, repo)
 
-    v1caps = wireproto.dispatch(repo, proto, 'capabilities')
+    v1caps = wireprotov1server.dispatch(repo, proto, 'capabilities')
     assert isinstance(v1caps, wireprototypes.bytesresponse)
 
     m = {
@@ -424,21 +424,21 @@ 
         if bodygen is not None:
             res.setbodygen(bodygen)
 
-    if not wireproto.commands.commandavailable(cmd, proto):
+    if not wireprotov1server.commands.commandavailable(cmd, proto):
         setresponse(HTTP_OK, HGERRTYPE,
                     _('requested wire protocol command is not available over '
                       'HTTP'))
         return
 
-    proto.checkperm(wireproto.commands[cmd].permission)
+    proto.checkperm(wireprotov1server.commands[cmd].permission)
 
     # Possibly handle a modern client wanting to switch protocols.
     if (cmd == 'capabilities' and
         processcapabilitieshandshake(repo, req, res, proto)):
 
         return
 
-    rsp = wireproto.dispatch(repo, proto, cmd)
+    rsp = wireprotov1server.dispatch(repo, proto, cmd)
 
     if isinstance(rsp, bytes):
         setresponse(HTTP_OK, HGTYPE, bodybytes=rsp)
@@ -649,15 +649,16 @@ 
                 state = 'upgrade-initial'
                 continue
 
-            available = wireproto.commands.commandavailable(request, proto)
+            available = wireprotov1server.commands.commandavailable(
+                request, proto)
 
             # This command isn't available. Send an empty response and go
             # back to waiting for a new command.
             if not available:
                 _sshv1respondbytes(fout, b'')
                 continue
 
-            rsp = wireproto.dispatch(repo, proto, request)
+            rsp = wireprotov1server.dispatch(repo, proto, request)
 
             if isinstance(rsp, bytes):
                 _sshv1respondbytes(fout, rsp)
@@ -764,7 +765,7 @@ 
         elif state == 'upgrade-v2-finish':
             # Send the upgrade response.
             fout.write(b'upgraded %s %s\n' % (token, SSHV2))
-            servercaps = wireproto.capabilities(repo, proto)
+            servercaps = wireprotov1server.capabilities(repo, proto)
             rsp = b'capabilities: %s' % servercaps.data
             fout.write(b'%d\n%s\n' % (len(rsp), rsp))
             fout.flush()
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -15,10 +15,10 @@ 
     error,
     pycompat,
     util,
-    wireproto,
     wireprotoserver,
     wireprototypes,
     wireprotov1peer,
+    wireprotov1server,
 )
 from .utils import (
     procutil,
@@ -441,7 +441,7 @@ 
                         dbg(line % '  %s-%s: %d' % (key, dk, len(dv)))
         self.ui.debug("sending %s command\n" % cmd)
         self._pipeo.write("%s\n" % cmd)
-        _func, names = wireproto.commands[cmd]
+        _func, names = wireprotov1server.commands[cmd]
         keys = names.split()
         wireargs = {}
         for k in keys:
diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -149,8 +149,8 @@ 
     upgrade,
     util,
     vfs as vfsmod,
-    wireproto,
     wireprotoserver,
+    wireprotov1server,
 )
 
 from . import (
@@ -323,7 +323,7 @@ 
                  wrapper.allsupportedversions)
 
     wrapfunction(exchange, 'push', wrapper.push)
-    wrapfunction(wireproto, '_capabilities', wrapper._capabilities)
+    wrapfunction(wireprotov1server, '_capabilities', wrapper._capabilities)
     wrapfunction(wireprotoserver, 'handlewsgirequest',
                  wireprotolfsserver.handlewsgirequest)
 
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -31,7 +31,7 @@ 
     subrepo,
     upgrade,
     url,
-    wireproto,
+    wireprotov1server,
 )
 
 from . import (
@@ -164,22 +164,24 @@ 
                             overrides.openlargefile)
 
     # create the new wireproto commands ...
-    wireproto.wireprotocommand('putlfile', 'sha', permission='push')(
+    wireprotov1server.wireprotocommand('putlfile', 'sha', permission='push')(
         proto.putlfile)
-    wireproto.wireprotocommand('getlfile', 'sha', permission='pull')(
+    wireprotov1server.wireprotocommand('getlfile', 'sha', permission='pull')(
         proto.getlfile)
-    wireproto.wireprotocommand('statlfile', 'sha', permission='pull')(
+    wireprotov1server.wireprotocommand('statlfile', 'sha', permission='pull')(
         proto.statlfile)
-    wireproto.wireprotocommand('lheads', '', permission='pull')(
-        wireproto.heads)
+    wireprotov1server.wireprotocommand('lheads', '', permission='pull')(
+        wireprotov1server.heads)
 
     # ... and wrap some existing ones
-    extensions.wrapfunction(wireproto.commands['heads'], 'func', proto.heads)
+    extensions.wrapfunction(wireprotov1server.commands['heads'], 'func',
+                            proto.heads)
     # TODO also wrap wireproto.commandsv2 once heads is implemented there.
 
     extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
 
-    extensions.wrapfunction(wireproto, '_capabilities', proto._capabilities)
+    extensions.wrapfunction(wireprotov1server, '_capabilities',
+                            proto._capabilities)
 
     # can't do this in reposetup because it needs to have happened before
     # wirerepo.__init__ is called
diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py
--- a/hgext/infinitepush/__init__.py
+++ b/hgext/infinitepush/__init__.py
@@ -125,9 +125,9 @@ 
     pycompat,
     registrar,
     util,
-    wireproto,
     wireprototypes,
     wireprotov1peer,
+    wireprotov1server,
 )
 
 from . import (
@@ -278,7 +278,7 @@ 
         clientextsetup(ui)
 
 def commonsetup(ui):
-    wireproto.commands['listkeyspatterns'] = (
+    wireprotov1server.commands['listkeyspatterns'] = (
         wireprotolistkeyspatterns, 'namespace patterns')
     scratchbranchpat = ui.config('infinitepush', 'branchpattern')
     if scratchbranchpat:
@@ -302,8 +302,8 @@ 
 
     extensions.wrapfunction(localrepo.localrepository, 'listkeys',
                             localrepolistkeys)
-    wireproto.commands['lookup'] = (
-        _lookupwrap(wireproto.commands['lookup'][0]), 'key')
+    wireprotov1server.commands['lookup'] = (
+        _lookupwrap(wireprotov1server.commands['lookup'][0]), 'key')
     extensions.wrapfunction(exchange, 'getbundlechunks', getbundlechunks)
 
     extensions.wrapfunction(bundle2, 'processparts', processparts)
diff --git a/hgext/clonebundles.py b/hgext/clonebundles.py
--- a/hgext/clonebundles.py
+++ b/hgext/clonebundles.py
@@ -198,7 +198,7 @@ 
 
 from mercurial import (
     extensions,
-    wireproto,
+    wireprotov1server,
 )
 
 testedwith = 'ships-with-hg-core'
@@ -215,4 +215,4 @@ 
     return caps
 
 def extsetup(ui):
-    extensions.wrapfunction(wireproto, '_capabilities', capabilities)
+    extensions.wrapfunction(wireprotov1server, '_capabilities', capabilities)