annotate tests/pullext.py @ 43016:92c8bae84e7a

automation: increase size of Linux AMI build volume I ran out of space attempting to build a few AMIs. Let's give the environment an extra 2 GB to utilize. Differential Revision: https://phab.mercurial-scm.org/D6915
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 29 Sep 2019 11:06:45 -0700
parents 268662aac075
children 2372284d9457
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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,
42813
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40983
diff changeset
16 )
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40983
diff changeset
17 from mercurial.interfaces import (
40327
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18 repository,
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
19 )
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
20
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
21 def clonecommand(orig, ui, repo, *args, **kwargs):
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22 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
23 kwargs[r'narrow'] = True
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24
40393
229d23cdb203 exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40327
diff changeset
25 if kwargs.get(r'depth'):
229d23cdb203 exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40327
diff changeset
26 try:
229d23cdb203 exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40327
diff changeset
27 kwargs[r'depth'] = int(kwargs[r'depth'])
229d23cdb203 exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40327
diff changeset
28 except ValueError:
229d23cdb203 exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40327
diff changeset
29 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
30
40327
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
31 return orig(ui, repo, *args, **kwargs)
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
32
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
33 def featuresetup(ui, features):
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34 features.add(repository.NARROW_REQUIREMENT)
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36 def extsetup(ui):
40983
70a00a8cd66e py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40393
diff changeset
37 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
38
40983
70a00a8cd66e py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40393
diff changeset
39 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
40 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
41
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
42 if not hasinclude:
40983
70a00a8cd66e py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40393
diff changeset
43 entry[1].append((b'', b'include', [],
70a00a8cd66e py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40393
diff changeset
44 _(b'pattern of file/directory to clone')))
70a00a8cd66e py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40393
diff changeset
45 entry[1].append((b'', b'exclude', [],
70a00a8cd66e py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40393
diff changeset
46 _(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
47
40393
229d23cdb203 exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40327
diff changeset
48 if not hasdepth:
40983
70a00a8cd66e py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40393
diff changeset
49 entry[1].append((b'', b'depth', b'',
70a00a8cd66e py3: byteify tests/pullext.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40393
diff changeset
50 _(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
51
40327
55836a34f41b exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
52 localrepo.featuresetupfuncs.add(featuresetup)