Mercurial > hg
annotate tests/pullext.py @ 42071:db72f9f6580e
interactive: do not prompt about files given in command line
For commit and revert commands with --interactive and explicit files
given in the command line, we now skip the invite to "examine changes to
<file> ? [Ynesfdaq?]". The reason for this is that, if <file> is
specified by the user, asking for confirmation is redundant.
In patch.filterpatch(), we now use an optional "match" argument to
conditionally call the prompt() function when entering a new "header"
item. We use .exact() method to compare with files from the "header" in
order to only consider (rel)path patterns.
Add tests with glob patterns for commit and revert, to make sure we
still ask to examine files in these cases.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Thu, 04 Apr 2019 11:35:18 +0200 |
parents | 70a00a8cd66e |
children | 268662aac075 |
rev | line source |
---|---|
40327
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # pullext.py - Simple extension to test pulling |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 # |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com> |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 from __future__ import absolute_import |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 from mercurial.i18n import _ |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 from mercurial import ( |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 commands, |
40393
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
13 error, |
40327
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 extensions, |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 localrepo, |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 repository, |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 ) |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 def clonecommand(orig, ui, repo, *args, **kwargs): |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 if kwargs.get(r'include') or kwargs.get(r'exclude'): |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 kwargs[r'narrow'] = True |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 |
40393
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
23 if kwargs.get(r'depth'): |
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
24 try: |
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
25 kwargs[r'depth'] = int(kwargs[r'depth']) |
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
26 except ValueError: |
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
27 raise error.Abort(_('--depth must be an integer')) |
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
28 |
40327
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 return orig(ui, repo, *args, **kwargs) |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 def featuresetup(ui, features): |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 features.add(repository.NARROW_REQUIREMENT) |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 def extsetup(ui): |
40983
70a00a8cd66e
py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40393
diff
changeset
|
35 entry = extensions.wrapcommand(commands.table, b'clone', clonecommand) |
40327
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 |
40983
70a00a8cd66e
py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40393
diff
changeset
|
37 hasinclude = any(x[1] == b'include' for x in entry[1]) |
70a00a8cd66e
py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40393
diff
changeset
|
38 hasdepth = any(x[1] == b'depth' for x in entry[1]) |
40327
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 if not hasinclude: |
40983
70a00a8cd66e
py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40393
diff
changeset
|
41 entry[1].append((b'', b'include', [], |
70a00a8cd66e
py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40393
diff
changeset
|
42 _(b'pattern of file/directory to clone'))) |
70a00a8cd66e
py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40393
diff
changeset
|
43 entry[1].append((b'', b'exclude', [], |
70a00a8cd66e
py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40393
diff
changeset
|
44 _(b'pattern of file/directory to not clone'))) |
40327
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 |
40393
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
46 if not hasdepth: |
40983
70a00a8cd66e
py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40393
diff
changeset
|
47 entry[1].append((b'', b'depth', b'', |
70a00a8cd66e
py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40393
diff
changeset
|
48 _(b'ancestry depth of changesets to fetch'))) |
40393
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
49 |
40327
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 localrepo.featuresetupfuncs.add(featuresetup) |