Show More
@@ -0,0 +1,50 | |||||
|
1 | Tests about metadataonlyctx | |||
|
2 | ||||
|
3 | $ hg init | |||
|
4 | $ echo A > A | |||
|
5 | $ hg commit -A A -m 'Add A' | |||
|
6 | $ echo B > B | |||
|
7 | $ hg commit -A B -m 'Add B' | |||
|
8 | $ hg rm A | |||
|
9 | $ echo C > C | |||
|
10 | $ echo B2 > B | |||
|
11 | $ hg add C -q | |||
|
12 | $ hg commit -m 'Remove A' | |||
|
13 | ||||
|
14 | $ cat > metaedit.py <<EOF | |||
|
15 | > from __future__ import absolute_import | |||
|
16 | > from mercurial import context, registrar | |||
|
17 | > cmdtable = {} | |||
|
18 | > command = registrar.command(cmdtable) | |||
|
19 | > @command('metaedit') | |||
|
20 | > def metaedit(ui, repo, arg): | |||
|
21 | > # Modify commit message to "FOO" | |||
|
22 | > with repo.wlock(), repo.lock(), repo.transaction('metaedit'): | |||
|
23 | > old = repo['.'] | |||
|
24 | > kwargs = dict(s.split('=', 1) for s in arg.split(';')) | |||
|
25 | > if 'parents' in kwargs: | |||
|
26 | > kwargs['parents'] = kwargs['parents'].split(',') | |||
|
27 | > new = context.metadataonlyctx(repo, old, **kwargs) | |||
|
28 | > new.commit() | |||
|
29 | > EOF | |||
|
30 | $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'text=Changed' | |||
|
31 | $ hg log -r tip | |||
|
32 | changeset: 3:ad83e9e00ec9 | |||
|
33 | tag: tip | |||
|
34 | parent: 1:3afb7afe6632 | |||
|
35 | user: test | |||
|
36 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
37 | summary: Changed | |||
|
38 | ||||
|
39 | $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'parents=0' 2>&1 | egrep '^\S*Error' | |||
|
40 | RuntimeError: can't reuse the manifest: its p1 doesn't match the new ctx p1 | |||
|
41 | ||||
|
42 | $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'user=foo <foo@example.com>' | |||
|
43 | $ hg log -r tip | |||
|
44 | changeset: 4:1f86eaeca92b | |||
|
45 | tag: tip | |||
|
46 | parent: 1:3afb7afe6632 | |||
|
47 | user: foo <foo@example.com> | |||
|
48 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
49 | summary: Remove A | |||
|
50 |
@@ -2371,7 +2371,7 class metadataonlyctx(committablectx): | |||||
2371 | for f in self._files: |
|
2371 | for f in self._files: | |
2372 | if not managing(f): |
|
2372 | if not managing(f): | |
2373 | added.append(f) |
|
2373 | added.append(f) | |
2374 |
elif self |
|
2374 | elif f in self: | |
2375 | modified.append(f) |
|
2375 | modified.append(f) | |
2376 | else: |
|
2376 | else: | |
2377 | removed.append(f) |
|
2377 | removed.append(f) |
General Comments 0
You need to be logged in to leave comments.
Login now