Mercurial > hg
comparison tests/pullext.py @ 40327:55836a34f41b
exchangev2: recognize narrow patterns when pulling
pulloperation instances were recently taught to record file
include and exclude patterns to facilitate narrow file transfer.
Teaching the exchangev2 code to transfer a subset of files is
as simple as constructing a narrow matcher from these patterns and
filtering all seen file paths through it.
Keep in mind that this change only influences file data: we're
still fetching all changeset and manifest data. So, there's still
a ton of "partial clone" to implement in exchangev2.
On a personal note, I derive gratification that this feature requires
very few lines of new code to implement.
To test this, we implemented a minimal extension which allows us to specify
--include/--exclude to clone. While the narrow extension provides these
arguments, I explicitly wanted to test this functionality without the
narrow extension enabled, as that extension monkeypatches various things
and I want to isolate the behavior of core Mercurial.
Differential Revision: https://phab.mercurial-scm.org/D5132
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 26 Sep 2018 14:38:43 -0700 |
parents | |
children | 229d23cdb203 |
comparison
equal
deleted
inserted
replaced
40326:fed697fa1734 | 40327:55836a34f41b |
---|---|
1 # pullext.py - Simple extension to test pulling | |
2 # | |
3 # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com> | |
4 # | |
5 # This software may be used and distributed according to the terms of the | |
6 # GNU General Public License version 2 or any later version. | |
7 | |
8 from __future__ import absolute_import | |
9 | |
10 from mercurial.i18n import _ | |
11 from mercurial import ( | |
12 commands, | |
13 extensions, | |
14 localrepo, | |
15 repository, | |
16 ) | |
17 | |
18 def clonecommand(orig, ui, repo, *args, **kwargs): | |
19 if kwargs.get(r'include') or kwargs.get(r'exclude'): | |
20 kwargs[r'narrow'] = True | |
21 | |
22 return orig(ui, repo, *args, **kwargs) | |
23 | |
24 def featuresetup(ui, features): | |
25 features.add(repository.NARROW_REQUIREMENT) | |
26 | |
27 def extsetup(ui): | |
28 entry = extensions.wrapcommand(commands.table, 'clone', clonecommand) | |
29 | |
30 hasinclude = any(x[1] == 'include' for x in entry[1]) | |
31 | |
32 if not hasinclude: | |
33 entry[1].append(('', 'include', [], | |
34 _('pattern of file/directory to clone'))) | |
35 entry[1].append(('', 'exclude', [], | |
36 _('pattern of file/directory to not clone'))) | |
37 | |
38 localrepo.featuresetupfuncs.add(featuresetup) |