[PATCH 4 of 9 remotefilelog-ext getfile-http] remotefilelogserver: restrict remotefilelog capability to ssh

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


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1435613785 14400
#      Mon Jun 29 17:36:25 2015 -0400
# Node ID c0c90f99906f1ae583b1c717228f6d3235af072d
# Parent  eab49b8ff33a3c6ca9bd3212687a0b26fe03c67b
remotefilelogserver: restrict remotefilelog capability to ssh

This only works over ssh, so let's not pretend otherwise.

A future change will ensure the capability is still advertised via ssh.

diff --git a/remotefilelog/remotefilelogserver.py b/remotefilelog/remotefilelogserver.py
--- a/remotefilelog/remotefilelogserver.py
+++ b/remotefilelog/remotefilelogserver.py
@@ -6,7 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 from mercurial import wireproto, changegroup, match, util, changelog, context
-from mercurial import exchange
+from mercurial import exchange, sshserver
 from mercurial.extensions import wrapfunction
 from mercurial.node import bin, hex, nullid, nullrev
 from mercurial.i18n import _
@@ -153,8 +153,9 @@ def onetimesetup(ui):
     # expose remotefilelog capabilities
     def _capabilities(orig, repo, proto):
         caps = orig(repo, proto)
-        if (shallowrepo.requirement in repo.requirements or
-            ui.configbool('remotefilelog', 'server')):
+        if ((shallowrepo.requirement in repo.requirements or
+            ui.configbool('remotefilelog', 'server'))
+            and isinstance(proto, sshserver.sshserver)):
             caps.append(shallowrepo.requirement)
         return caps
     wrapfunction(wireproto, '_capabilities', _capabilities)
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -19,16 +19,16 @@ remotefilelog requests because it's http
   1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over 0.00s
   abort: HTTP Error 500: Internal Server Error
 
-Bug: remotefilelog capability is advertised over http even though it
-won't work.
+The 'remotefilelog' capability should *not* be exported over http(s),
+as the getfile method it offers doesn't work with http.
   $ get-with-headers.py localhost:$HGPORT '?cmd=capabilities'
   200 Script output follows
   
-  lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream-preferred stream bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 remotefilelog (no-eol)
+  lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream-preferred stream bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 (no-eol)
   $ get-with-headers.py localhost:$HGPORT '?cmd=hello'
   200 Script output follows
   
-  capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream-preferred stream bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 remotefilelog
+  capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream-preferred stream bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024
 
   $ get-with-headers.py localhost:$HGPORT '?cmd=this-command-does-not-exist' | head -n 1
   400 no such method: this-command-does-not-exist


More information about the Mercurial-devel mailing list