Patchwork [3,of,9,remotefilelog-ext,getfile-http] remotefilelogserver: wrap wireproto._capabilities

login
register
mail settings
Submitter Augie Fackler
Date July 1, 2015, 8:05 p.m.
Message ID <eab49b8ff33a3c6ca9bd.1435781140@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/9856/
State Not Applicable
Headers show

Comments

Augie Fackler - July 1, 2015, 8:05 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1435613732 14400
#      Mon Jun 29 17:35:32 2015 -0400
# Node ID eab49b8ff33a3c6ca9bd3212687a0b26fe03c67b
# Parent  41771848adf150766c9e5169c2787e80715b9116
remotefilelogserver: wrap wireproto._capabilities

If we instead wrap wireproto.capabilities, then our capabilities don't
get transmitted via the hello command, so not all clients will notice
the new capability unless we do the wrapping here.

Test output is in the test that previously demonstrated the
defect. Note that there's still a defect: we're advertising the
capability over http even though we have no hope of the getfiles
method working over http.

Patch

diff --git a/remotefilelog/remotefilelogserver.py b/remotefilelog/remotefilelogserver.py
--- a/remotefilelog/remotefilelogserver.py
+++ b/remotefilelog/remotefilelogserver.py
@@ -151,13 +151,13 @@  def onetimesetup(ui):
     wireproto.commands["getbundle_shallow"] = (getbundleshallow, '*')
 
     # expose remotefilelog capabilities
-    def capabilities(orig, repo, proto):
+    def _capabilities(orig, repo, proto):
         caps = orig(repo, proto)
         if (shallowrepo.requirement in repo.requirements or
             ui.configbool('remotefilelog', 'server')):
-            caps += " " + shallowrepo.requirement
+            caps.append(shallowrepo.requirement)
         return caps
-    wrapfunction(wireproto, 'capabilities', capabilities)
+    wrapfunction(wireproto, '_capabilities', _capabilities)
 
     def _adjustlinkrev(orig, self, path, filelog, fnode, *args, **kwargs):
         # When generating file blobs, taking the real path is too slow on large
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -19,11 +19,12 @@  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 listed for cmd=hello but not cmd=capabilities
+Bug: remotefilelog capability is advertised over http even though it
+won't work.
   $ 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 (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 remotefilelog (no-eol)
   $ get-with-headers.py localhost:$HGPORT '?cmd=hello'
   200 Script output follows