D4014: exchange: move simple narrow changegroup generation from extension
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Wed Aug 1 17:04:28 UTC 2018
indygreg created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
The narrow extension completely replaced the function generating the
changegroup part when a narrow changegroup was requested. Previous
commits have taught the in-core changegroup code how to filter files
based on a matcher. This commit teaches the in-core bundle2 part
generation code to construct a matcher based on arguments. It
will also emit a bundle2 part describing the narrow spec.
I believe the changegroup part generation code in the narrow extension
is now limited to ellipsis serving mode. i.e. core is now capable
of narrow changegroup generation when ellipsis mode is disabled.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4014
AFFECTED FILES
hgext/narrow/narrowbundle2.py
mercurial/exchange.py
CHANGE DETAILS
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -2114,8 +2114,17 @@
if not outgoing.missing:
return
+ if kwargs.get(r'narrow', False):
+ include = sorted(filter(bool, kwargs.get(r'includepats', [])))
+ exclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
+ filematcher = narrowspec.match(repo.root, include=include,
+ exclude=exclude)
+ else:
+ filematcher = None
+
cgstream = changegroup.makestream(repo, outgoing, version, source,
- bundlecaps=bundlecaps)
+ bundlecaps=bundlecaps,
+ filematcher=filematcher)
part = bundler.newpart('changegroup', data=cgstream)
if cgversions:
@@ -2127,6 +2136,15 @@
if 'treemanifest' in repo.requirements:
part.addparam('treemanifest', '1')
+ if kwargs.get(r'narrow', False) and (include or exclude):
+ narrowspecpart = bundler.newpart('narrow:spec')
+ if include:
+ narrowspecpart.addparam(
+ 'include', '\n'.join(include), mandatory=True)
+ if exclude:
+ narrowspecpart.addparam(
+ 'exclude', '\n'.join(exclude), mandatory=True)
+
@getbundle2partsgenerator('bookmarks')
def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None,
b2caps=None, **kwargs):
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -87,6 +87,8 @@
def getbundlechangegrouppart_narrow(bundler, repo, source,
bundlecaps=None, b2caps=None, heads=None,
common=None, **kwargs):
+ assert repo.ui.configbool('experimental', 'narrowservebrokenellipses')
+
cgversions = b2caps.get('changegroup')
if cgversions: # 3.1 and 3.2 ship with an empty value
cgversions = [v for v in cgversions
@@ -101,28 +103,6 @@
include = sorted(filter(bool, kwargs.get(r'includepats', [])))
exclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
newmatch = narrowspec.match(repo.root, include=include, exclude=exclude)
- if not repo.ui.configbool("experimental", "narrowservebrokenellipses"):
- outgoing = exchange._computeoutgoing(repo, heads, common)
- if not outgoing.missing:
- return
-
- cg = changegroup.makestream(repo, outgoing, version, source,
- filematcher=newmatch)
- part = bundler.newpart('changegroup', data=cg)
- part.addparam('version', version)
- if 'treemanifest' in repo.requirements:
- part.addparam('treemanifest', '1')
-
- if include or exclude:
- narrowspecpart = bundler.newpart(_SPECPART)
- if include:
- narrowspecpart.addparam(
- _SPECPART_INCLUDE, '\n'.join(include), mandatory=True)
- if exclude:
- narrowspecpart.addparam(
- _SPECPART_EXCLUDE, '\n'.join(exclude), mandatory=True)
-
- return
depth = kwargs.get(r'depth', None)
if depth is not None:
@@ -311,7 +291,8 @@
if repo.ui.has_section(_NARROWACL_SECTION):
kwargs = exchange.applynarrowacl(repo, kwargs)
- if kwargs.get(r'narrow', False):
+ if (kwargs.get(r'narrow', False) and
+ repo.ui.configbool('experimental', 'narrowservebrokenellipses')):
getbundlechangegrouppart_narrow(*args, **kwargs)
else:
origcgfn(*args, **kwargs)
To: indygreg, durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list