annotate tests/test-mq-symlinks.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 a387b0390082
children 4d2b9b304ad0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22046
7a9cbb315d84 tests: replace exit 80 with #require
Matt Mackall <mpm@selenic.com>
parents: 18395
diff changeset
1 #require symlink
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
2
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
3 $ echo "[extensions]" >> $HGRCPATH
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
4 $ echo "mq=" >> $HGRCPATH
5157
f6c520fd70cf mq: teach qpop about symlinks
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
5
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
6 $ hg init
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
7 $ hg qinit
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
8 $ hg qnew base.patch
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
9 $ echo aaa > a
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
10 $ echo bbb > b
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
11 $ echo ccc > c
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
12 $ hg add a b c
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
13 $ hg qrefresh
16350
4f795f5fbb0b tests: make tests work if directory contains special characters
Thomas Arendsen Hein <thomas@intevation.de>
parents: 14453
diff changeset
14 $ "$TESTDIR/readlink.py" a
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
15 a -> a not a symlink
6360
95413879bac9 test-mq-symlinks: skip if symlinks are not supported
Patrick Mezard <pmezard@gmail.com>
parents: 5683
diff changeset
16
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
17
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
18 test replacing a file with a symlink
5157
f6c520fd70cf mq: teach qpop about symlinks
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
19
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
20 $ hg qnew symlink.patch
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
21 $ rm a
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
22 $ ln -s b a
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
23 $ hg qrefresh --git
16350
4f795f5fbb0b tests: make tests work if directory contains special characters
Thomas Arendsen Hein <thomas@intevation.de>
parents: 14453
diff changeset
24 $ "$TESTDIR/readlink.py" a
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
25 a -> b
5157
f6c520fd70cf mq: teach qpop about symlinks
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
26
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
27 $ hg qpop
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
28 popping symlink.patch
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
29 now at: base.patch
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
30 $ hg qpush
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
31 applying symlink.patch
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
32 now at: symlink.patch
16350
4f795f5fbb0b tests: make tests work if directory contains special characters
Thomas Arendsen Hein <thomas@intevation.de>
parents: 14453
diff changeset
33 $ "$TESTDIR/readlink.py" a
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
34 a -> b
5157
f6c520fd70cf mq: teach qpop about symlinks
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
35
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
36
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
37 test updating a symlink
7517
49f34b43cf90 patch: handle git patches that remove symlinks (issue1438)
Brendan Cully <brendan@kublai.com>
parents: 6360
diff changeset
38
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
39 $ rm a
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
40 $ ln -s c a
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
41 $ hg qnew --git -f updatelink
16350
4f795f5fbb0b tests: make tests work if directory contains special characters
Thomas Arendsen Hein <thomas@intevation.de>
parents: 14453
diff changeset
42 $ "$TESTDIR/readlink.py" a
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
43 a -> c
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
44 $ hg qpop
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
45 popping updatelink
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
46 now at: symlink.patch
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
47 $ hg qpush --debug
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
48 applying updatelink
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
49 patching file a
23749
a387b0390082 localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents: 22046
diff changeset
50 committing files:
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
51 a
23749
a387b0390082 localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents: 22046
diff changeset
52 committing manifest
a387b0390082 localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents: 22046
diff changeset
53 committing changelog
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
54 now at: updatelink
16350
4f795f5fbb0b tests: make tests work if directory contains special characters
Thomas Arendsen Hein <thomas@intevation.de>
parents: 14453
diff changeset
55 $ "$TESTDIR/readlink.py" a
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
56 a -> c
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
57 $ hg st
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
58
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
59
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
60 test replacing a symlink with a file
9586
d08099e74b81 patch: handle symlink updates/replacements (issue1785)
Patrick Mezard <pmezard@gmail.com>
parents: 9585
diff changeset
61
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
62 $ ln -s c s
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
63 $ hg add s
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
64 $ hg qnew --git -f addlink
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
65 $ rm s
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
66 $ echo sss > s
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
67 $ hg qnew --git -f replacelinkwithfile
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
68 $ hg qpop
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
69 popping replacelinkwithfile
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
70 now at: addlink
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
71 $ hg qpush
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
72 applying replacelinkwithfile
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
73 now at: replacelinkwithfile
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
74 $ cat s
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
75 sss
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
76 $ hg st
9586
d08099e74b81 patch: handle symlink updates/replacements (issue1785)
Patrick Mezard <pmezard@gmail.com>
parents: 9585
diff changeset
77
11908
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
78
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
79 test symlink removal
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
80
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
81 $ hg qnew removesl.patch
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
82 $ hg rm a
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
83 $ hg qrefresh --git
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
84 $ hg qpop
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
85 popping removesl.patch
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
86 now at: replacelinkwithfile
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
87 $ hg qpush
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
88 applying removesl.patch
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
89 now at: removesl.patch
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
90 $ hg st -c
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
91 C b
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
92 C c
7f48f0b188c6 tests: unify test-mq-symlinks
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10397
diff changeset
93 C s
12345
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
94
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
95 replace broken symlink with another broken symlink
12340
b0bb72460c44 patch: fix target when patching broken symlinks (issue2368)
Patrick Mezard <pmezard@gmail.com>
parents: 10397
diff changeset
96
12345
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
97 $ ln -s linka linka
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
98 $ hg add linka
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
99 $ hg qnew link
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
100 $ hg mv linka linkb
12398
2bc926ad65c2 merge with stable
Mads Kiilerich <mads@kiilerich.com>
parents: 12396 12345
diff changeset
101 $ rm linkb
2bc926ad65c2 merge with stable
Mads Kiilerich <mads@kiilerich.com>
parents: 12396 12345
diff changeset
102 $ ln -s linkb linkb
12345
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
103 $ hg qnew movelink
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
104 $ hg qpop
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
105 popping movelink
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
106 now at: link
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
107 $ hg qpush
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
108 applying movelink
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
109 now at: movelink
16350
4f795f5fbb0b tests: make tests work if directory contains special characters
Thomas Arendsen Hein <thomas@intevation.de>
parents: 14453
diff changeset
110 $ "$TESTDIR/readlink.py" linkb
12345
e0ee3e822a9a Merge with stable
Patrick Mezard <pmezard@gmail.com>
parents: 12341 11908
diff changeset
111 linkb -> linkb