Mercurial > hg
annotate tests/test-convert-darcs.t @ 24545:9e0c67e84896
json: implement {tags} template
Tags is pretty easy to implement. Let's start there.
The output is slightly different from `hg tags -Tjson`. For reference,
the CLI has the following output:
[
{
"node": "e2049974f9a23176c2addb61d8f5b86e0d620490",
"rev": 29880,
"tag": "tip",
"type": ""
},
...
]
Our output has the format:
{
"node": "0aeb19ea57a6d223bacddda3871cb78f24b06510",
"tags": [
{
"node": "e2049974f9a23176c2addb61d8f5b86e0d620490",
"tag": "tag1",
"date": [1427775457.0, 25200]
},
...
]
}
"rev" is omitted because it isn't a reliable identifier. We shouldn't
be exposing them in web APIs and giving the impression it remotely
resembles a stable identifier. Perhaps we could one day hide this behind
a config option (it might be useful to expose when running servers
locally).
The "type" of the tag isn't defined because this information isn't yet
exposed to the hgweb templater (it could be in a follow-up) and because
it is questionable whether different types should be exposed at all.
(Should the web interface really be exposing "local" tags?)
We use an object for the outer type instead of Array for a few reasons.
First, it is extensible. If we ever need to throw more global properties
into the output, we can do that without breaking backwards compatibility
(property additions should be backwards compatible). Second, uniformity
in web APIs is nice. Having everything return objects seems much saner than
a mix of array and object. Third, there are security issues with arrays
in older browsers. The JSON web services world almost never uses arrays
as the main type for this reason.
Another possibly controversial part about this patch is how dates are
defined. While JSON has a Date type, it is based on the JavaScript Date
type, which is widely considered a pile of garbage. It is a non-starter
for this reason.
Many of Mercurial's built-in date filters drop seconds resolution. So
that's a non-starter as well, since we want the API to be lossless where
possible. rfc3339date, rfc822date, isodatesec, and date are all lossless.
However, they each require the client to perform string parsing on top of
JSON decoding. While date parsing libraries are pretty ubiquitous, some
languages don't have them out of the box. However, pretty much every
programming language can deal with UNIX timestamps (which are just
integers or floats). So, we choose to use Mercurial's internal date
representation, which in JSON is modeled as float seconds since UNIX
epoch and an integer timezone offset from UTC (keep in mind
JavaScript/JSON models all "Numbers" as double prevision floating point
numbers, so there isn't a difference between ints and floats in JSON).
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 31 Mar 2015 14:52:21 -0700 |
parents | 7a9cbb315d84 |
children | ab929a174f7b |
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 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
11 $ darcs init |
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 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
46 $ sleep 1 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
47 $ echo e > a |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
48 $ echo f > f |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
49 $ mkdir dir |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
50 $ echo d > dir/d |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
51 $ echo d > dir/d2 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
52 $ darcs record -a -l -m p2 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
53 Finished recording patch 'p2' |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
54 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
55 test file and directory move |
5413 | 56 |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
57 $ darcs mv f ff |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
58 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
59 Test remove + move |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
60 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
61 $ darcs remove dir/d2 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
62 $ rm dir/d2 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
63 $ darcs mv dir dir2 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
64 $ darcs record -a -l -m p3 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
65 Finished recording patch 'p3' |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
66 |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
67 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
|
68 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
|
69 letting the conflict resolving patch fix collisions. |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
70 Unfortunately, non-conflicting changes, like the addition of the |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
71 "c" file in p1.1 patch are reverted too. |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
72 Just to say that manifest not listing "c" here is a bug. |
5413 | 73 |
15335
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
74 $ cd .. |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
75 $ 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
|
76 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
|
77 scanning source... |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
78 sorting... |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
79 converting... |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
80 4 p0 |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
81 3 p1.2 |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
82 2 p1.1 |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
83 1 p2 |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
84 0 p3 |
52a137edc060
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests
Matt Mackall <mpm@selenic.com>
parents:
14116
diff
changeset
|
85 $ 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 0 "p0" (test@example.org) files: a |
12718 | 91 |
12524
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
92 $ hg up -q -R darcs-repo-hg |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
93 $ hg -R darcs-repo-hg manifest --debug |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
94 7225b30cdf38257d5cc7780772c051b6f33e6d6b 644 a |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
95 1e88685f5ddec574a34c70af492f95b6debc8741 644 b |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
96 37406831adc447ec2385014019599dfec953c806 644 dir2/d |
8773cac3a455
tests: unify test-convert-darcs
Matt Mackall <mpm@selenic.com>
parents:
12407
diff
changeset
|
97 b783a337463792a5c7d548ad85a7d3253c16ba8c 644 ff |
17448
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
98 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
99 #if no-outer-repo |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
100 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
101 try converting darcs1 repository |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
102 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
103 $ 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
|
104 $ 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
|
105 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
|
106 |
507e8f94b26a
test-convert-darcs.t: fix elementtree test
Patrick Mezard <patrick@mezard.eu>
parents:
17015
diff
changeset
|
107 #endif |