Mercurial > hg
annotate tests/test-issue1175.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 | a43fdf33a6be |
children | 2fc86d92c4a9 |
rev | line source |
---|---|
12328
b63f6422d2a7
tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents:
12195
diff
changeset
|
1 http://mercurial.selenic.com/bts/issue1175 |
12195
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
2 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
3 $ hg init |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
4 $ touch a |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
5 $ hg ci -Am0 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
6 adding a |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
7 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
8 $ hg mv a a1 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
9 $ hg ci -m1 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
10 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
11 $ hg co 0 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
12 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
13 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
14 $ hg mv a a2 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
15 $ hg up |
12757
62c8f7691bc3
merge: make 'diverging renames' diagnostic a more helpful note.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12328
diff
changeset
|
16 note: possible conflict - a was renamed multiple times to: |
12195
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
17 a2 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
18 a1 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
20 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
21 $ hg ci -m2 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
22 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
23 $ touch a |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
24 $ hg ci -Am3 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
25 adding a |
6875 | 26 |
12195
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
27 $ hg mv a b |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
28 $ hg ci -Am4 a |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
29 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
30 $ hg ci --debug --traceback -Am5 b |
23749
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
18743
diff
changeset
|
31 committing files: |
12195
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
32 b |
23929
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
33 warning: can't find ancestor for 'b' copied from 'a'! |
23749
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
18743
diff
changeset
|
34 committing manifest |
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
18743
diff
changeset
|
35 committing changelog |
23929
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
36 committed changeset 5:83a687e8a97c80992ba385bbfd766be181bfb1d1 |
12195
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
37 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
38 $ hg verify |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
39 checking changesets |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
40 checking manifests |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
41 crosschecking files in changesets and manifests |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
42 checking files |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
43 4 files, 6 changesets, 4 total revisions |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
44 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
45 $ hg export --git tip |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
46 # HG changeset patch |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
47 # User test |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
48 # Date 0 0 |
18648
76b69cccb07a
export: show 'Date' header in a format that also is readable for humans
Mads Kiilerich <mads@kiilerich.com>
parents:
12757
diff
changeset
|
49 # Thu Jan 01 00:00:00 1970 +0000 |
23929
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
50 # Node ID 83a687e8a97c80992ba385bbfd766be181bfb1d1 |
18739
5b7175377bab
setparents: drop copies from dropped p2 (issue3843)
Matt Mackall <mpm@selenic.com>
parents:
12757
diff
changeset
|
51 # Parent 1d1625283f71954f21d14c3d44d0ad3c019c597f |
12195
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
52 5 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
53 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
54 diff --git a/b b/b |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
55 new file mode 100644 |
ee41be2bbf5a
tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents:
6875
diff
changeset
|
56 |
23929
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
57 http://bz.selenic.com/show_bug.cgi?id=4476 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
58 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
59 $ hg init foo |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
60 $ cd foo |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
61 $ touch a && hg ci -Aqm a |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
62 $ hg mv a b |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
63 $ echo b1 >> b |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
64 $ hg ci -Aqm b1 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
65 $ hg up 0 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
66 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
67 $ hg mv a b |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
68 $ echo b2 >> b |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
69 $ hg ci -Aqm b2 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
70 $ hg graft 1 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
71 grafting 1:5974126fad84 "b1" |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
72 merging b |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
73 warning: conflicts during merge. |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
74 merging b incomplete! (edit conflicts, then use 'hg resolve --mark') |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
75 abort: unresolved conflicts, can't continue |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
76 (use hg resolve and hg graft --continue) |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
77 [255] |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
78 $ echo a > b |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
79 $ echo b3 >> b |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
80 $ hg resolve --mark b |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
81 (no more unresolved files) |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
82 $ hg graft --continue |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
83 grafting 1:5974126fad84 "b1" |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
84 warning: can't find ancestor for 'b' copied from 'a'! |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
85 $ hg log -f b -T 'changeset: {rev}:{node|short}\nsummary: {desc}\n\n' |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
86 changeset: 3:376d30ccffc0 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
87 summary: b1 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
88 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
89 changeset: 2:416baaa2e5e4 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
90 summary: b2 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
91 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
92 changeset: 0:3903775176ed |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
93 summary: a |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
94 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
95 |
a43fdf33a6be
commit: remove reverse search for copy source when not in parent (issue4476)
Ryan McElroy <rmcelroy@fb.com>
parents:
23749
diff
changeset
|
96 |