Mercurial > hg
annotate tests/test-audit-path.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 | ef60083b5536 |
children | 15c6eb0a51bd |
rev | line source |
---|---|
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
1 $ hg init |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
2 |
16908
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
3 audit of .hg |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
4 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
5 $ hg add .hg/00changelog.i |
15447
9910f60a37ee
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
15441
diff
changeset
|
6 abort: path contains illegal component: .hg/00changelog.i (glob) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11855
diff
changeset
|
7 [255] |
5158
d316124ebbea
Make audit_path more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
8 |
16908
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
9 #if symlink |
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
10 |
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
11 Symlinks |
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
12 |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
13 $ mkdir a |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
14 $ echo a > a/a |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
15 $ hg ci -Ama |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
16 adding a/a |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
17 $ ln -s a b |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
18 $ echo b > a/b |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
19 $ hg add b/b |
15447
9910f60a37ee
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
15441
diff
changeset
|
20 abort: path 'b/b' traverses symbolic link 'b' (glob) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11855
diff
changeset
|
21 [255] |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
22 $ hg add b |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
23 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
24 should still fail - maybe |
5158
d316124ebbea
Make audit_path more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
25 |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
26 $ hg add b/b |
15447
9910f60a37ee
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
15441
diff
changeset
|
27 abort: path 'b/b' traverses symbolic link 'b' (glob) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11855
diff
changeset
|
28 [255] |
5158
d316124ebbea
Make audit_path more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
29 |
16908
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
30 #endif |
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
31 |
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
32 |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
33 unbundle tampered bundle |
5158
d316124ebbea
Make audit_path more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
34 |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
35 $ hg init target |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
36 $ cd target |
16350
4f795f5fbb0b
tests: make tests work if directory contains special characters
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15521
diff
changeset
|
37 $ hg unbundle "$TESTDIR/bundles/tampered.hg" |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
38 adding changesets |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
39 adding manifests |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
40 adding file changes |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
41 added 5 changesets with 6 changes to 6 files (+4 heads) |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
42 (run 'hg heads' to see heads, 'hg merge' to merge) |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
43 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
44 attack .hg/test |
7554
11a4eb81fb4f
test-audit-path: add more tests (issue 1450)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5158
diff
changeset
|
45 |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
46 $ hg manifest -r0 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
47 .hg/test |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
48 $ hg update -Cr0 |
16908
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
49 abort: path contains illegal component: .hg/test (glob) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11855
diff
changeset
|
50 [255] |
7554
11a4eb81fb4f
test-audit-path: add more tests (issue 1450)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5158
diff
changeset
|
51 |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
52 attack foo/.hg/test |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
53 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
54 $ hg manifest -r1 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
55 foo/.hg/test |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
56 $ hg update -Cr1 |
16908
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
57 abort: path 'foo/.hg/test' is inside nested repo 'foo' (glob) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11855
diff
changeset
|
58 [255] |
7554
11a4eb81fb4f
test-audit-path: add more tests (issue 1450)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5158
diff
changeset
|
59 |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
60 attack back/test where back symlinks to .. |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
61 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
62 $ hg manifest -r2 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
63 back |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
64 back/test |
16908
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
65 #if symlink |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
66 $ hg update -Cr2 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
67 abort: path 'back/test' traverses symbolic link 'back' |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11855
diff
changeset
|
68 [255] |
16908
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
69 #else |
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
70 ('back' will be a file and cause some other system specific error) |
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
71 $ hg update -Cr2 |
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
72 abort: * (glob) |
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
73 [255] |
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
74 #endif |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
75 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
76 attack ../test |
7554
11a4eb81fb4f
test-audit-path: add more tests (issue 1450)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5158
diff
changeset
|
77 |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
78 $ hg manifest -r3 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
79 ../test |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
80 $ hg update -Cr3 |
16908
6a997aacba5d
tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16350
diff
changeset
|
81 abort: path contains illegal component: ../test (glob) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11855
diff
changeset
|
82 [255] |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
83 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
84 attack /tmp/test |
7554
11a4eb81fb4f
test-audit-path: add more tests (issue 1450)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5158
diff
changeset
|
85 |
11855
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
86 $ hg manifest -r4 |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
87 /tmp/test |
054b0d9c3f0c
tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents:
7681
diff
changeset
|
88 $ hg update -Cr4 |
18506
ef60083b5536
tests: fix for windows - slashes and no serve
Mads Kiilerich <madski@unity3d.com>
parents:
18336
diff
changeset
|
89 abort: path contains illegal component: /tmp/test (glob) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11855
diff
changeset
|
90 [255] |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
16908
diff
changeset
|
91 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
16908
diff
changeset
|
92 $ cd .. |