Mercurial > hg
comparison tests/test-context-metadata.t @ 33999:be814edf3306
metadataonlyctx: don't crash when reusing the manifest with deletions
This was originally fixed by Mateusz Kwapich for the `metaedit` command in
fb-hgext with a test for the `metaedit` command. It didn't get upstreamed
because `metaedit` was not in core.
This patch fixes the crash and adds a test about `metadataonlyctx` to
avoid future regressions.
Differential Revision: https://phab.mercurial-scm.org/D550
author | Jun Wu <quark@fb.com> |
---|---|
date | Mon, 28 Aug 2017 16:58:59 -0700 |
parents | |
children | 11499bad0359 |
comparison
equal
deleted
inserted
replaced
33998:becce02036e1 | 33999:be814edf3306 |
---|---|
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 |