annotate tests/test-context-metadata.t @ 37295:45b39c69fae0

wireproto: separate commands tables for version 1 and 2 commands We can't easily reuse existing command handlers for version 2 commands because the response types will be different. e.g. many commands return nodes encoded as hex. Our new wire protocol is binary safe, so we'll wish to encode nodes as binary. We /could/ teach each command handler to look at the protocol handler and change behavior based on the version in use. However, this would make logic a bit unwieldy over time and would make it harder to design a unified protocol handler interface. I think it's better to create a clean break between version 1 and version 2 of commands on the server. What I imagine happening is we will have separate @wireprotocommand functions for each protocol generation. Those functions will parse the request, dispatch to a common function to process it, then generate the response in its own, transport-specific manner. This commit establishes a separate table for tracking version 1 commands from version 2 commands. The HTTP server pieces have been updated to use this new table. Most commands are marked as both version 1 and version 2, so there is little practical impact to this change. A side-effect of this change is we now rely on transport registration in wireprototypes.TRANSPORTS and certain properties of the protocol interface. So a test had to be updated to conform. Differential Revision: https://phab.mercurial-scm.org/D2982
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 28 Mar 2018 10:40:41 -0700
parents 194463554ba5
children 8327fd79adf8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33999
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
1 Tests about metadataonlyctx
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
2
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
3 $ hg init
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
4 $ echo A > A
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
5 $ hg commit -A A -m 'Add A'
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
6 $ echo B > B
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
7 $ hg commit -A B -m 'Add B'
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
8 $ hg rm A
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
9 $ echo C > C
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
10 $ echo B2 > B
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
11 $ hg add C -q
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
12 $ hg commit -m 'Remove A'
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
13
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
14 $ cat > metaedit.py <<EOF
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
15 > from __future__ import absolute_import
36048
194463554ba5 py3: port metaedit extension to Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34061
diff changeset
16 > from mercurial import context, pycompat, registrar
33999
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
17 > cmdtable = {}
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
18 > command = registrar.command(cmdtable)
36048
194463554ba5 py3: port metaedit extension to Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34061
diff changeset
19 > @command(b'metaedit')
33999
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
20 > def metaedit(ui, repo, arg):
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
21 > # Modify commit message to "FOO"
36048
194463554ba5 py3: port metaedit extension to Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34061
diff changeset
22 > with repo.wlock(), repo.lock(), repo.transaction(b'metaedit'):
194463554ba5 py3: port metaedit extension to Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34061
diff changeset
23 > old = repo[b'.']
194463554ba5 py3: port metaedit extension to Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34061
diff changeset
24 > kwargs = dict(s.split(b'=', 1) for s in arg.split(b';'))
33999
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
25 > if 'parents' in kwargs:
36048
194463554ba5 py3: port metaedit extension to Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34061
diff changeset
26 > kwargs[b'parents'] = kwargs[b'parents'].split(b',')
194463554ba5 py3: port metaedit extension to Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34061
diff changeset
27 > new = context.metadataonlyctx(repo, old,
194463554ba5 py3: port metaedit extension to Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34061
diff changeset
28 > **pycompat.strkwargs(kwargs))
33999
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
29 > new.commit()
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
30 > EOF
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
31 $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'text=Changed'
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
32 $ hg log -r tip
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
33 changeset: 3:ad83e9e00ec9
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
34 tag: tip
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
35 parent: 1:3afb7afe6632
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
36 user: test
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
37 date: Thu Jan 01 00:00:00 1970 +0000
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
38 summary: Changed
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
39
34061
11499bad0359 check-code: forbid "\S" in egrep regular expression
Jun Wu <quark@fb.com>
parents: 33999
diff changeset
40 $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'parents=0' 2>&1 | egrep '^RuntimeError'
33999
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
41 RuntimeError: can't reuse the manifest: its p1 doesn't match the new ctx p1
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
42
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
43 $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'user=foo <foo@example.com>'
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
44 $ hg log -r tip
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
45 changeset: 4:1f86eaeca92b
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
46 tag: tip
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
47 parent: 1:3afb7afe6632
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
48 user: foo <foo@example.com>
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
49 date: Thu Jan 01 00:00:00 1970 +0000
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
50 summary: Remove A
be814edf3306 metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
diff changeset
51