Patchwork D2285: wireprotoserver: return to using iscmd() method

login
register
mail settings
Submitter phabricator
Date Feb. 15, 2018, 10:31 p.m.
Message ID <differential-rev-PHID-DREV-c4xaqmv2owz7l7u7rtrz-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27986/
State Superseded
Headers show

Comments

phabricator - Feb. 15, 2018, 10:31 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This was teased out in part so remotefilelog could disable an old
  protocol method over http. It got dropped accidentally in the recent
  refactor, but the code was all still present so it's easy to support
  for now.
  
  I think once we land remotefilelog, we should probably inline this
  function.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/wireprotoserver.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 15, 2018, 11:21 p.m.
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  FWIW, I plan to add a mechanism to `@wireprotocommand` to declare which protocols the command is enabled for. I'll likely have those patches within a week. But until then, we can restore this.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -170,6 +170,10 @@ 
             urlreq.quote(self._req.env.get('REMOTE_HOST', '')),
             urlreq.quote(self._req.env.get('REMOTE_USER', '')))
 
+# This method exists mostly so that extensions like remotefilelog can
+# disable a kludgey legacy method only over http. As of early 2018,
+# 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
 
@@ -198,7 +202,7 @@ 
     # wire protocol requests to hgweb because it prevents hgweb from using
     # known wire protocol commands and it is less confusing for machine
     # clients.
-    if cmd not in wireproto.commands:
+    if not iscmd(cmd):
         return None
 
     proto = httpv1protocolhandler(req, repo.ui)