annotate tests/test-merge-internal-tools-pattern.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 b63f6422d2a7
children ff12a6c63c3d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12328
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12316
diff changeset
1 Make sure that the internal merge tools (internal:fail, internal:local, and
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12316
diff changeset
2 internal:other) are used when matched by a merge-pattern in hgrc
6521
a3668330f14a test that internal merge tools are used when set for a merge-pattern in hgrc
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff changeset
3
12257
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
4 Make sure HGMERGE doesn't interfere with the test:
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
5
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
6 $ unset HGMERGE
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
7
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
8 $ hg init
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
9
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
10 Initial file contents:
6521
a3668330f14a test that internal merge tools are used when set for a merge-pattern in hgrc
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff changeset
11
12257
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
12 $ echo "line 1" > f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
13 $ echo "line 2" >> f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
14 $ echo "line 3" >> f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
15 $ hg ci -Am "revision 0"
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
16 adding f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
17
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
18 $ cat f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
19 line 1
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
20 line 2
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
21 line 3
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
22
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
23 Branch 1: editing line 1:
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
24
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
25 $ sed 's/line 1/first line/' f > f.new
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
26 $ mv f.new f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
27 $ hg ci -Am "edited first line"
6521
a3668330f14a test that internal merge tools are used when set for a merge-pattern in hgrc
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff changeset
28
12257
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
29 Branch 2: editing line 3:
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
30
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
31 $ hg update 0
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
32 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
33 $ sed 's/line 3/third line/' f > f.new
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
34 $ mv f.new f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
35 $ hg ci -Am "edited third line"
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
36 created new head
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
37
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
38 Merge using internal:fail tool:
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
39
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
40 $ echo "[merge-patterns]" > .hg/hgrc
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
41 $ echo "* = internal:fail" >> .hg/hgrc
6521
a3668330f14a test that internal merge tools are used when set for a merge-pattern in hgrc
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff changeset
42
12257
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
43 $ hg merge
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
44 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
12314
f2daa6ab514a merge: suggest 'hg up -C .' for discarding changes, not 'hg up -C'
Brodie Rao <brodie@bitheap.org>
parents: 12257
diff changeset
45 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12314
diff changeset
46 [1]
12257
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
47
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
48 $ cat f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
49 line 1
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
50 line 2
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
51 third line
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
52
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
53 $ hg stat
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
54 M f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
55
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
56 Merge using internal:local tool:
6521
a3668330f14a test that internal merge tools are used when set for a merge-pattern in hgrc
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff changeset
57
12257
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
58 $ hg update -C 2
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
59 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
60 $ sed 's/internal:fail/internal:local/' .hg/hgrc > .hg/hgrc.new
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
61 $ mv .hg/hgrc.new .hg/hgrc
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
62
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
63 $ hg merge
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
64 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
65 (branch merge, don't forget to commit)
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
66
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
67 $ cat f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
68 line 1
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
69 line 2
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
70 third line
6521
a3668330f14a test that internal merge tools are used when set for a merge-pattern in hgrc
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff changeset
71
12257
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
72 $ hg stat
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
73 M f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
74
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
75 Merge using internal:other tool:
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
76
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
77 $ hg update -C 2
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
78 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
79 $ sed 's/internal:local/internal:other/' .hg/hgrc > .hg/hgrc.new
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
80 $ mv .hg/hgrc.new .hg/hgrc
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
81
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
82 $ hg merge
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
83 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
84 (branch merge, don't forget to commit)
6521
a3668330f14a test that internal merge tools are used when set for a merge-pattern in hgrc
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff changeset
85
12257
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
86 $ cat f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
87 first line
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
88 line 2
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
89 line 3
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
90
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
91 $ hg stat
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
92 M f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
93
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
94 Merge using default tool:
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
95
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
96 $ hg update -C 2
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
97 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
98 $ rm .hg/hgrc
6521
a3668330f14a test that internal merge tools are used when set for a merge-pattern in hgrc
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff changeset
99
12257
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
100 $ hg merge
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
101 merging f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
102 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
103 (branch merge, don't forget to commit)
6521
a3668330f14a test that internal merge tools are used when set for a merge-pattern in hgrc
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff changeset
104
12257
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
105 $ cat f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
106 first line
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
107 line 2
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
108 third line
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
109
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
110 $ hg stat
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
111 M f
470e0b1ddc6e tests: unify test-merge-internal-tools-pattern
Adrian Buehlmann <adrian@cadifra.com>
parents: 12156
diff changeset
112