[PATCH] httprepo: use caps instead of between for compat check
Matt Mackall
mpm at selenic.com
Sat Mar 12 11:58:23 CST 2011
On Sat, 2011-03-12 at 18:30 +0100, Peter Arrenbrecht wrote:
> # HG changeset patch
> # User Peter Arrenbrecht <peter.arrenbrecht at gmail.com>
> # Date 1299950942 -3600
> httprepo: use caps instead of between for compat check
I'm sure this breaks compatibility with some old servers, but I'm not
sure how old.
> We usually query the capabilities at some point anyway so this way the first roundtrip
> actually does useful work.
>
> diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py
> --- a/mercurial/httprepo.py
> +++ b/mercurial/httprepo.py
> @@ -52,10 +52,13 @@
>
> # look up capabilities only when needed
>
> + def _fetchcaps(self):
> + self.caps = set(self._call('capabilities').split())
> +
> def get_caps(self):
> if self.caps is None:
> try:
> - self.caps = set(self._call('capabilities').split())
> + self._fetchcaps()
> except error.RepoError:
> self.caps = set()
> self.ui.debug('capabilities: %s\n' %
> @@ -195,7 +198,13 @@
> inst = httpsrepository(ui, path)
> else:
> inst = httprepository(ui, path)
> - inst.between([(nullid, nullid)])
> + try:
> + # Try to do useful work when checking compatibility.
> + # Usually saves a roundtrip since we want the caps anyway.
> + inst._fetchcaps()
> + except error.RepoError:
> + # No luck, try older compatibility check.
> + inst.between([(nullid, nullid)])
> return inst
> except error.RepoError:
> ui.note('(falling back to static-http)\n')
> diff --git a/tests/test-http-proxy.t b/tests/test-http-proxy.t
> --- a/tests/test-http-proxy.t
> +++ b/tests/test-http-proxy.t
> @@ -98,27 +98,22 @@
> updating to branch default
> 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> $ cat proxy.log
> - * - - [*] "GET http://localhost:$HGPORT/?cmd=between&pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - - (glob)
> - * - - [*] "GET http://localhost:$HGPORT/?cmd=between&pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
> + * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
> + * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
> - * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
> - * - - [*] "GET http://localhost:$HGPORT/?cmd=between&pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
> + * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
> - * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
> - * - - [*] "GET http://localhost:$HGPORT/?cmd=between&pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
> + * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
> - * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
> - * - - [*] "GET http://localhost:$HGPORT/?cmd=between&pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
> - * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
> * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
>
> diff --git a/tests/test-schemes.t b/tests/test-schemes.t
> --- a/tests/test-schemes.t
> +++ b/tests/test-schemes.t
> @@ -25,7 +25,7 @@
>
> $ hg incoming --debug parts://localhost
> using http://localhost:$HGPORT/
> - sending between command
> + sending capabilities command
> comparing with parts://localhost
> sending heads command
> searching for changes
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list