comparison mercurial/exchange.py @ 38808:d99083996398

exchange: move simple narrow changegroup generation from extension 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. Differential Revision: https://phab.mercurial-scm.org/D4014
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 28 Jul 2018 17:42:36 -0700
parents 98df52d5042c
children a232e6744ba3
comparison
equal deleted inserted replaced
38807:98df52d5042c 38808:d99083996398
2112 2112
2113 outgoing = _computeoutgoing(repo, heads, common) 2113 outgoing = _computeoutgoing(repo, heads, common)
2114 if not outgoing.missing: 2114 if not outgoing.missing:
2115 return 2115 return
2116 2116
2117 if kwargs.get(r'narrow', False):
2118 include = sorted(filter(bool, kwargs.get(r'includepats', [])))
2119 exclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
2120 filematcher = narrowspec.match(repo.root, include=include,
2121 exclude=exclude)
2122 else:
2123 filematcher = None
2124
2117 cgstream = changegroup.makestream(repo, outgoing, version, source, 2125 cgstream = changegroup.makestream(repo, outgoing, version, source,
2118 bundlecaps=bundlecaps) 2126 bundlecaps=bundlecaps,
2127 filematcher=filematcher)
2119 2128
2120 part = bundler.newpart('changegroup', data=cgstream) 2129 part = bundler.newpart('changegroup', data=cgstream)
2121 if cgversions: 2130 if cgversions:
2122 part.addparam('version', version) 2131 part.addparam('version', version)
2123 2132
2124 part.addparam('nbchanges', '%d' % len(outgoing.missing), 2133 part.addparam('nbchanges', '%d' % len(outgoing.missing),
2125 mandatory=False) 2134 mandatory=False)
2126 2135
2127 if 'treemanifest' in repo.requirements: 2136 if 'treemanifest' in repo.requirements:
2128 part.addparam('treemanifest', '1') 2137 part.addparam('treemanifest', '1')
2138
2139 if kwargs.get(r'narrow', False) and (include or exclude):
2140 narrowspecpart = bundler.newpart('narrow:spec')
2141 if include:
2142 narrowspecpart.addparam(
2143 'include', '\n'.join(include), mandatory=True)
2144 if exclude:
2145 narrowspecpart.addparam(
2146 'exclude', '\n'.join(exclude), mandatory=True)
2129 2147
2130 @getbundle2partsgenerator('bookmarks') 2148 @getbundle2partsgenerator('bookmarks')
2131 def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None, 2149 def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None,
2132 b2caps=None, **kwargs): 2150 b2caps=None, **kwargs):
2133 """add a bookmark part to the requested bundle""" 2151 """add a bookmark part to the requested bundle"""