Mercurial > hg
annotate tests/test-convert-darcs.t @ 37048:fc5e261915b9
wireproto: require POST for all HTTPv2 requests
Wire protocol version 1 transfers argument data via request
headers by default. This has historically caused problems because
servers institute limits on the length of individual HTTP headers
as well as the total size of all request headers. Mercurial servers
can advertise the maximum length of an individual header. But
there's no guarantee any intermediate HTTP agents will accept
headers up to that length.
In the existing wire protocol, server operators typically also
key off the HTTP request method to implement authentication.
For example, GET requests translate to read-only requests and
can be allowed. But read-write commands must use POST and require
authentication. This has typically worked because the only wire
protocol commands that use POST modify the repo (e.g. the
"unbundle" command).
There is an experimental feature to enable clients to transmit
argument data via POST request bodies. This is technically a
better and more robust solution. But we can't enable it by default
because of servers assuming POST means write access.
In version 2 of the wire protocol, the permissions of a request
are encoded in the URL. And with it being a new protocol in a new
URL space, we're not constrained by backwards compatibility
requirements.
This commit adopts the technically superior mechanism of using
HTTP request bodies to send argument data by requiring POST for
all commands. Strictly speaking, it may be possible to send
request bodies on GET requests. But my experience is that not all
HTTP stacks support this. POST pretty much always works. Using POST
for read-only operations does sacrifice some RESTful design
purity. But this API cares about practicality, not about being
in Roy T. Fielding's REST ivory tower.
There's a chance we may relax this restriction in the future. But
for now, I want to see how far we can get with a POST only API.
Differential Revision: https://phab.mercurial-scm.org/D2837
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 13 Mar 2018 11:57:43 -0700 |
parents | ab929a174f7b |
children |
rev | line source |
---|---|
22046
7a9cbb315d84
tests: replace exit 80 with #require
Matt Mackall <mpm@selenic.com>
parents:
20117
diff
changeset
|
1 #require darcs |
5413 | 2 |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
3 $ echo "[extensions]" >> $HGRCPATH |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
4 $ echo "convert=" >> $HGRCPATH |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
5 $ DARCS_EMAIL='test@example.org'; export DARCS_EMAIL |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
6 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
7 initialize darcs repo |
5520
cc3af86ab6fe
test-convert-darcs: skip if we can't find the elementtree module
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5442
diff
changeset
|
8 |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
9 $ mkdir darcs-repo |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
10 $ cd darcs-repo |
30296
ab929a174f7b
tests: silence output of darcs command
Yuya Nishihara <yuya@tcha.org>
parents:
22046
diff
changeset
|
11 $ darcs init -q |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
12 $ echo a > a |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
13 $ darcs record -a -l -m p0 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
14 Finished recording patch 'p0' |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
15 $ cd .. |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
16 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
17 branch and update |
12393
84ceedcfeb6a
convert/darcs: improve unsupported format detection (issue2172)
Patrick Mezard <pmezard@gmail.com>
parents:
12252
diff
changeset
|
18 |
16698
26756d9d8143
tests: make test-convert-darcs.t happier with darcs 2.8.0
Bryan O'Sullivan <bryano@fb.com>
parents:
15335
diff
changeset
|
19 $ darcs get -q darcs-repo darcs-clone >/dev/null |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
20 $ cd darcs-clone |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
21 $ echo c >> a |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
22 $ echo c > c |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
23 $ darcs record -a -l -m p1.1 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
24 Finished recording patch 'p1.1' |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
25 $ cd .. |
5413 | 26 |
17448
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
27 skip if we can't import elementtree |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
28 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
29 $ if hg convert darcs-repo darcs-dummy 2>&1 | grep ElementTree > /dev/null; then |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
30 > echo 'skipped: missing feature: elementtree module' |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
31 > exit 80 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
32 > fi |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
33 |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
34 update source |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
35 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
36 $ cd darcs-repo |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
37 $ echo b >> a |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
38 $ echo b > b |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
39 $ darcs record -a -l -m p1.2 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
40 Finished recording patch 'p1.2' |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
41 |
16698
26756d9d8143
tests: make test-convert-darcs.t happier with darcs 2.8.0
Bryan O'Sullivan <bryano@fb.com>
parents:
15335
diff
changeset
|
42 $ darcs pull -q -a --no-set-default ../darcs-clone |
26756d9d8143
tests: make test-convert-darcs.t happier with darcs 2.8.0
Bryan O'Sullivan <bryano@fb.com>
parents:
15335
diff
changeset
|
43 Backing up ./a(*) (glob) |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
44 We have conflicts in the following files: |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
45 ./a |
30296
ab929a174f7b
tests: silence output of darcs command
Yuya Nishihara <yuya@tcha.org>
parents:
22046
diff
changeset
|
46 (?) |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
47 $ sleep 1 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
48 $ echo e > a |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
49 $ echo f > f |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
50 $ mkdir dir |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
51 $ echo d > dir/d |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
52 $ echo d > dir/d2 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
53 $ darcs record -a -l -m p2 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
54 Finished recording patch 'p2' |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
55 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
56 test file and directory move |
5413 | 57 |
30296
ab929a174f7b
tests: silence output of darcs command
Yuya Nishihara <yuya@tcha.org>
parents:
22046
diff
changeset
|
58 $ darcs mv -q f ff |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
59 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
60 Test remove + move |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
61 |
30296
ab929a174f7b
tests: silence output of darcs command
Yuya Nishihara <yuya@tcha.org>
parents:
22046
diff
changeset
|
62 $ darcs remove -q dir/d2 |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
63 $ rm dir/d2 |
30296
ab929a174f7b
tests: silence output of darcs command
Yuya Nishihara <yuya@tcha.org>
parents:
22046
diff
changeset
|
64 $ darcs mv -q dir dir2 |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
65 $ darcs record -a -l -m p3 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
66 Finished recording patch 'p3' |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
67 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
68 The converter does not currently handle patch conflicts very well. |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
69 When they occur, it reverts *all* changes and moves forward, |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
70 letting the conflict resolving patch fix collisions. |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
71 Unfortunately, non-conflicting changes, like the addition of the |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
72 "c" file in p1.1 patch are reverted too. |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
73 Just to say that manifest not listing "c" here is a bug. |
5413 | 74 |
15335
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
75 $ cd .. |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
76 $ hg convert darcs-repo darcs-repo-hg |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
77 initializing destination darcs-repo-hg repository |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
78 scanning source... |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
79 sorting... |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
80 converting... |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
81 4 p0 |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
82 3 p1.2 |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
83 2 p1.1 |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
84 1 p2 |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
85 0 p3 |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
86 $ hg log -R darcs-repo-hg -g --template '{rev} "{desc|firstline}" ({author}) files: {files}\n' "$@" |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
87 4 "p3" (test@example.org) files: dir/d dir/d2 dir2/d f ff |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
88 3 "p2" (test@example.org) files: a dir/d dir/d2 f |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
89 2 "p1.1" (test@example.org) files: |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
90 1 "p1.2" (test@example.org) files: a b |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
91 0 "p0" (test@example.org) files: a |
12718 | 92 |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
93 $ hg up -q -R darcs-repo-hg |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
94 $ hg -R darcs-repo-hg manifest --debug |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
95 7225b30cdf38257d5cc7780772c051b6f33e6d6b 644 a |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
96 1e88685f5ddec574a34c70af492f95b6debc8741 644 b |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
97 37406831adc447ec2385014019599dfec953c806 644 dir2/d |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
98 b783a337463792a5c7d548ad85a7d3253c16ba8c 644 ff |
17448
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
99 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
100 #if no-outer-repo |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
101 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
102 try converting darcs1 repository |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
103 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
104 $ hg clone -q "$TESTDIR/bundles/darcs1.hg" darcs |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
105 $ hg convert -s darcs darcs/darcs1 2>&1 | grep darcs-1.0 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
106 darcs-1.0 repository format is unsupported, please upgrade |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
107 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
108 #endif |