Mercurial > hg-stable
changeset 39540:c90514043eaa
narrow: add narrow and ellipses as server capabilities
Right now we don't have a way to differentiate between whether a server can
serve ellipsis or not. The way we check whether a server is narrow enabled is by
checking bundle2 capability which does not scale outside of bundle2 world.
The goal is to use have wireprotocol commands just like remotefilelog for
widening the narrow clone, atleast in non-ellipses cases. Having a server
capability will help there as we can't rely on bundle2 capability there.
Also having a server capability is neat than having a bundle2 capability.
There are lot of things we can optimize locally on the client side by knowing
before hand that whether the server supports ellipses or not.
This will also help us in making sure that a client ellipses repo does not
communicate with a server repo without ellipses.
Differential Revision: https://phab.mercurial-scm.org/D4521
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Mon, 10 Sep 2018 15:55:14 +0300 |
parents | 3ba9ef0fb693 |
children | 294c571490f0 |
files | hgext/narrow/narrowbundle2.py hgext/narrow/narrowwirepeer.py tests/test-narrow-clone-non-narrow-server.t |
diffstat | 3 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/narrow/narrowbundle2.py Thu Aug 23 18:26:14 2018 -0700 +++ b/hgext/narrow/narrowbundle2.py Mon Sep 10 15:55:14 2018 +0300 @@ -32,6 +32,7 @@ ) NARROWCAP = 'narrow' +ELLIPSESCAP = 'ellipses' _NARROWACL_SECTION = 'narrowhgacl' _CHANGESPECPART = NARROWCAP + ':changespec' _SPECPART = NARROWCAP + ':spec'
--- a/hgext/narrow/narrowwirepeer.py Thu Aug 23 18:26:14 2018 -0700 +++ b/hgext/narrow/narrowwirepeer.py Mon Sep 10 15:55:14 2018 +0300 @@ -14,8 +14,11 @@ hg, narrowspec, node, + wireprotov1server, ) +from . import narrowbundle2 + def uisetup(): def peersetup(ui, peer): # We must set up the expansion before reposetup below, since it's used @@ -38,6 +41,16 @@ peer.__class__ = expandingpeer hg.wirepeersetupfuncs.append(peersetup) + extensions.wrapfunction(wireprotov1server, '_capabilities', addnarrowcap) + +def addnarrowcap(orig, repo, proto): + """add the narrow capability to the server""" + caps = orig(repo, proto) + caps.append(narrowbundle2.NARROWCAP) + if repo.ui.configbool('experimental', 'narrowservebrokenellipses'): + caps.append(narrowbundle2.ELLIPSESCAP) + return caps + def reposetup(repo): def wirereposetup(ui, peer): def wrapped(orig, cmd, *args, **kwargs):
--- a/tests/test-narrow-clone-non-narrow-server.t Thu Aug 23 18:26:14 2018 -0700 +++ b/tests/test-narrow-clone-non-narrow-server.t Mon Sep 10 15:55:14 2018 +0300 @@ -33,6 +33,7 @@ $ echo hello | hg -R . serve --stdio | \ > $PYTHON unquote.py | grep narrow narrow=v0 + rev-branch-cache changegroupsubset getbundle known lookup narrow protocaps pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash $ cd ..