Mercurial > hg
annotate tests/pullext.py @ 40417:49c7b701fdc2 stable
phase: add an archived phase
This phase allows for hidden changesets in the "user space". It differs from
the "internal" phase which is intended for internal by-product only. There
have been discussions at the 4.8 sprint to use such phase to speedup cleanup
after history rewriting operation.
Shipping it in the same release as the 'internal-phase' groups the associated
`requires` entry. The important bit is to have support for this phase in the
earliest version of mercurial possible. Adding the UI to manipulate this new
phase later seems fine.
The current plan for archived usage and user interface are as follow. On a
repository with internal-phase on and evolution off:
* history rewriting command set rewritten changeset in the archived phase.
(This mean updating the cleanupnodes method).
* keep `hg unbundle .hg/strip-backup/X.hg` as a way to restore changeset for
now
(backup bundle need to contains phase data)
* [maybe] add a `hg strip --soft` advance flag
(a light way to expose the feature without getting in the way of a better
UI)
Mercurial 4.8 freeze is too close to get the above in by then.
We don't introduce a new repository `requirement` as we reuse the one
introduced with the 'archived' phase during the 4.8 cycle.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 17 Oct 2018 14:47:01 +0200 |
parents | 229d23cdb203 |
children | 70a00a8cd66e |
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): |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 entry = extensions.wrapcommand(commands.table, 'clone', clonecommand) |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 hasinclude = any(x[1] == 'include' for x in entry[1]) |
40393
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
38 hasdepth = any(x[1] == '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: |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 entry[1].append(('', 'include', [], |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 _('pattern of file/directory to clone'))) |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 entry[1].append(('', 'exclude', [], |
55836a34f41b
exchangev2: recognize narrow patterns when pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 _('pattern of file/directory to not clone'))) |
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: |
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
47 entry[1].append(('', 'depth', '', |
229d23cdb203
exchangev2: support fetching shallow files history
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40327
diff
changeset
|
48 _('ancestry depth of changesets to fetch'))) |
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) |