##// END OF EJS Templates
tests: pass parent revision as integer to repo[x] in test-context-metadata.t...
Martin von Zweigbergk -
r37870:8327fd79 default
parent child Browse files
Show More
@@ -1,51 +1,51
1 Tests about metadataonlyctx
1 Tests about metadataonlyctx
2
2
3 $ hg init
3 $ hg init
4 $ echo A > A
4 $ echo A > A
5 $ hg commit -A A -m 'Add A'
5 $ hg commit -A A -m 'Add A'
6 $ echo B > B
6 $ echo B > B
7 $ hg commit -A B -m 'Add B'
7 $ hg commit -A B -m 'Add B'
8 $ hg rm A
8 $ hg rm A
9 $ echo C > C
9 $ echo C > C
10 $ echo B2 > B
10 $ echo B2 > B
11 $ hg add C -q
11 $ hg add C -q
12 $ hg commit -m 'Remove A'
12 $ hg commit -m 'Remove A'
13
13
14 $ cat > metaedit.py <<EOF
14 $ cat > metaedit.py <<EOF
15 > from __future__ import absolute_import
15 > from __future__ import absolute_import
16 > from mercurial import context, pycompat, registrar
16 > from mercurial import context, pycompat, registrar
17 > cmdtable = {}
17 > cmdtable = {}
18 > command = registrar.command(cmdtable)
18 > command = registrar.command(cmdtable)
19 > @command(b'metaedit')
19 > @command(b'metaedit')
20 > def metaedit(ui, repo, arg):
20 > def metaedit(ui, repo, arg):
21 > # Modify commit message to "FOO"
21 > # Modify commit message to "FOO"
22 > with repo.wlock(), repo.lock(), repo.transaction(b'metaedit'):
22 > with repo.wlock(), repo.lock(), repo.transaction(b'metaedit'):
23 > old = repo[b'.']
23 > old = repo[b'.']
24 > kwargs = dict(s.split(b'=', 1) for s in arg.split(b';'))
24 > kwargs = dict(s.split(b'=', 1) for s in arg.split(b';'))
25 > if 'parents' in kwargs:
25 > if 'parents' in kwargs:
26 > kwargs[b'parents'] = kwargs[b'parents'].split(b',')
26 > kwargs[b'parents'] = map(int, kwargs[b'parents'].split(b','))
27 > new = context.metadataonlyctx(repo, old,
27 > new = context.metadataonlyctx(repo, old,
28 > **pycompat.strkwargs(kwargs))
28 > **pycompat.strkwargs(kwargs))
29 > new.commit()
29 > new.commit()
30 > EOF
30 > EOF
31 $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'text=Changed'
31 $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'text=Changed'
32 $ hg log -r tip
32 $ hg log -r tip
33 changeset: 3:ad83e9e00ec9
33 changeset: 3:ad83e9e00ec9
34 tag: tip
34 tag: tip
35 parent: 1:3afb7afe6632
35 parent: 1:3afb7afe6632
36 user: test
36 user: test
37 date: Thu Jan 01 00:00:00 1970 +0000
37 date: Thu Jan 01 00:00:00 1970 +0000
38 summary: Changed
38 summary: Changed
39
39
40 $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'parents=0' 2>&1 | egrep '^RuntimeError'
40 $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'parents=0' 2>&1 | egrep '^RuntimeError'
41 RuntimeError: can't reuse the manifest: its p1 doesn't match the new ctx p1
41 RuntimeError: can't reuse the manifest: its p1 doesn't match the new ctx p1
42
42
43 $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'user=foo <foo@example.com>'
43 $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'user=foo <foo@example.com>'
44 $ hg log -r tip
44 $ hg log -r tip
45 changeset: 4:1f86eaeca92b
45 changeset: 4:1f86eaeca92b
46 tag: tip
46 tag: tip
47 parent: 1:3afb7afe6632
47 parent: 1:3afb7afe6632
48 user: foo <foo@example.com>
48 user: foo <foo@example.com>
49 date: Thu Jan 01 00:00:00 1970 +0000
49 date: Thu Jan 01 00:00:00 1970 +0000
50 summary: Remove A
50 summary: Remove A
51
51
General Comments 0
You need to be logged in to leave comments. Login now