Mercurial > hg
changeset 38789:9b64b73d702b
exchange: move disabling of rev-branch-cache bundle part out of narrow
I'm attempting to refactor changegroup code in order to better
support alternate storage backends. The narrow extension is
performing a lot of monkeypatching to this code and it is making
it difficult to reason about how everything works. I'm reasonably
certain I would be unable to abstract storage without requiring
extensive rework of narrow. I believe it is less effort to move
narrow code into core so it can be accounted for when changegroup
code is refactored. So I'll be doing that.
The first part of this is integrating the disabling of the
cache:rev-branch-cache bundle2 part into core. This doesn't seem
like it is related to changegroup, but narrow's modifications to
changegroup are invasive and also require taking its code for
bundle generation and exchange into core in order for the changegroup
code to work.
Differential Revision: https://phab.mercurial-scm.org/D4007
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 28 Jul 2018 10:41:23 -0700 |
parents | a9ff2b0c11dd |
children | 3e7387337a3c |
files | hgext/narrow/narrowbundle2.py mercurial/exchange.py |
diffstat | 2 files changed, 8 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/narrow/narrowbundle2.py Tue Jul 24 10:47:42 2018 -0700 +++ b/hgext/narrow/narrowbundle2.py Sat Jul 28 10:41:23 2018 -0700 @@ -487,19 +487,6 @@ origcgfn(*args, **kwargs) exchange.getbundle2partsmapping['changegroup'] = wrappedcgfn - # disable rev branch cache exchange when serving a narrow bundle - # (currently incompatible with that part) - origrbcfn = exchange.getbundle2partsmapping['cache:rev-branch-cache'] - def wrappedcgfn(*args, **kwargs): - repo = args[1] - if repo.ui.has_section(_NARROWACL_SECTION): - return - elif kwargs.get(r'narrow', False): - return - else: - origrbcfn(*args, **kwargs) - exchange.getbundle2partsmapping['cache:rev-branch-cache'] = wrappedcgfn - # Extend changegroup receiver so client can fixup after widen requests. origcghandler = bundle2.parthandlermapping['changegroup'] def wrappedcghandler(op, inpart):
--- a/mercurial/exchange.py Tue Jul 24 10:47:42 2018 -0700 +++ b/mercurial/exchange.py Sat Jul 28 10:41:23 2018 -0700 @@ -44,6 +44,8 @@ urlerr = util.urlerr urlreq = util.urlreq +_NARROWACL_SECTION = 'narrowhgacl' + # Maps bundle version human names to changegroup versions. _bundlespeccgversions = {'v1': '01', 'v2': '02', @@ -2069,8 +2071,13 @@ # Don't send unless: # - changeset are being exchanged, # - the client supports it. - if not (kwargs.get(r'cg', True)) or 'rev-branch-cache' not in b2caps: + # - narrow bundle isn't in play (not currently compatible). + if (not kwargs.get(r'cg', True) + or 'rev-branch-cache' not in b2caps + or kwargs.get(r'narrow', False) + or repo.ui.has_section(_NARROWACL_SECTION)): return + outgoing = _computeoutgoing(repo, heads, common) bundle2.addpartrevbranchcache(repo, bundler, outgoing)