Debian Codegraph @

tests/test-context-metadata.t

raw
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 mercurial import context, pycompat, registrar
16 > cmdtable = {}
17 > command = registrar.command(cmdtable)
18 > @command(b'metaedit')
19 > def metaedit(ui, repo, arg):
20 > # Modify commit message to "FOO"
21 > with repo.wlock(), repo.lock(), repo.transaction(b'metaedit'):
22 > old = repo[b'.']
23 > kwargs = dict(s.split(b'=', 1) for s in arg.split(b';'))
24 > if b'parents' in kwargs:
25 > kwargs[b'parents'] = map(int, kwargs[b'parents'].split(b','))
26 > new = context.metadataonlyctx(repo, old,
27 > **pycompat.strkwargs(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 | grep -E '^RuntimeError'
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 <[email protected]>'
43 $ hg log -r tip
44 changeset: 4:1f86eaeca92b
45 tag: tip
46 parent: 1:3afb7afe6632
47 user: foo <[email protected]>
48 date: Thu Jan 01 00:00:00 1970 +0000
49 summary: Remove A
50