From patchwork Wed Jul 1 20:05:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6, of, 9, remotefilelog-ext, getfile-http] fileserverclient: sniff for remotefilelog capability before using it From: Augie Fackler X-Patchwork-Id: 9857 Message-Id: <5e58703e43ff3ce67f21.1435781143@arthedain.pit.corp.google.com> To: durham@fb.com Cc: mercurial-devel@selenic.com Date: Wed, 01 Jul 2015 16:05:43 -0400 # HG changeset patch # User Augie Fackler # Date 1435613636 14400 # Mon Jun 29 17:33:56 2015 -0400 # Node ID 5e58703e43ff3ce67f212de4c4cbc4231b0cf526 # Parent 9527b11d57224af70ffa4569db04e8d93bde4555 fileserverclient: sniff for remotefilelog capability before using it This prevents clients from causing a server problem on an http server. diff --git a/remotefilelog/fileserverclient.py b/remotefilelog/fileserverclient.py --- a/remotefilelog/fileserverclient.py +++ b/remotefilelog/fileserverclient.py @@ -173,6 +173,10 @@ class fileserverclient(object): raise util.Abort("no remotefilelog server configured - " "is your .hg/hgrc trusted?") remote = hg.peer(self.ui, {}, fallbackpath) + # TODO: deduplicate this with the constant in shallowrepo + if not remote.capable("remotefilelog"): + raise util.Abort("configured remotefilelog server" + " does not support remotefilelog") remote._callstream("getfiles") finally: self.ui.verbose = verbose diff --git a/tests/test-http.t b/tests/test-http.t --- a/tests/test-http.t +++ b/tests/test-http.t @@ -8,8 +8,6 @@ > EOF $ echo x > x $ hg commit -qAm x -Bug: remotefilelog tries to fetch from a server which can't handle -remotefilelog requests because it's http-based: $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log $ cd .. @@ -17,7 +15,8 @@ remotefilelog requests because it's http $ hgcloneshallow http://localhost:$HGPORT/ shallow -q 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over 0.00s - abort: HTTP Error 500: Internal Server Error + abort: configured remotefilelog server does not support remotefilelog + The 'remotefilelog' capability should *not* be exported over http(s), as the getfile method it offers doesn't work with http.