[PATCH 9 of 9 remotefilelog-ext getfile-http] remotefilelogserver: prevent getfiles from being called over http at all

Augie Fackler raf at durin42.com
Wed Jul 1 15:05:46 CDT 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1435676687 14400
#      Tue Jun 30 11:04:47 2015 -0400
# Node ID f4d310b5f7fc0213ec07435802e594b807b260f4
# Parent  99e8e62032be03b27e450cfb261a5cd61a960360
remotefilelogserver: prevent getfiles from being called over http at all

This means that even old clients that fail to sniff for capabilities
before trying getfiles will get a sensible error message back from the
server.

diff --git a/remotefilelog/remotefilelogserver.py b/remotefilelog/remotefilelogserver.py
--- a/remotefilelog/remotefilelogserver.py
+++ b/remotefilelog/remotefilelogserver.py
@@ -8,6 +8,7 @@
 from mercurial import wireproto, changegroup, match, util, changelog, context
 from mercurial import exchange, sshserver
 from mercurial.extensions import wrapfunction
+from mercurial.hgweb import protocol as httpprotocol
 from mercurial.node import bin, hex, nullid, nullrev
 from mercurial.i18n import _
 import shallowrepo
@@ -170,6 +171,13 @@ def onetimesetup(ui):
 
     wrapfunction(context.basefilectx, '_adjustlinkrev', _adjustlinkrev)
 
+    def _iscmd(orig, cmd):
+        if cmd == 'getfiles':
+            return False
+        return orig(cmd)
+
+    wrapfunction(httpprotocol, 'iscmd', _iscmd)
+
 def getfiles(repo, proto):
     """A server api for requesting particular versions of particular files.
     """
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -31,6 +31,5 @@ as the getfile method it offers doesn't 
 
   $ get-with-headers.py localhost:$HGPORT '?cmd=this-command-does-not-exist' | head -n 1
   400 no such method: this-command-does-not-exist
-Bug: this should return 400, not 5xx
   $ get-with-headers.py localhost:$HGPORT '?cmd=getfiles' | head -n 1
-  500 Internal Server Error
+  400 no such method: getfiles


More information about the Mercurial-devel mailing list