Mercurial > hg
annotate tests/test-mq-qrename.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 | 2963d5c9d90b |
children |
rev | line source |
---|---|
12324
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
1 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
2 $ echo "[extensions]" >> $HGRCPATH |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
3 $ echo "mq=" >> $HGRCPATH |
3083
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
diff
changeset
|
4 |
12324
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
5 $ hg init a |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
6 $ cd a |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
7 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
8 $ echo 'base' > base |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
9 $ hg ci -Ambase |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
10 adding base |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
11 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
12 $ hg qnew -mmqbase mqbase |
3083
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
diff
changeset
|
13 |
12324
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
14 $ hg qrename mqbase renamed |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
15 $ mkdir .hg/patches/foo |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
16 $ hg qrename renamed foo |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
17 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
18 $ hg qseries |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
19 foo/renamed |
3083
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
diff
changeset
|
20 |
12324
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
21 $ ls .hg/patches/foo |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
22 renamed |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
23 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
24 $ mkdir .hg/patches/bar |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
25 $ hg qrename foo/renamed bar |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
26 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
27 $ hg qseries |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
28 bar/renamed |
3083
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
diff
changeset
|
29 |
12324
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
30 $ ls .hg/patches/bar |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
31 renamed |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
32 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
33 $ hg qrename bar/renamed baz |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
34 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
35 $ hg qseries |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
36 baz |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
37 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
38 $ ls .hg/patches/baz |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
39 .hg/patches/baz |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
40 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
41 $ hg qrename baz new/dir |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
42 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
43 $ hg qseries |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
44 new/dir |
3083
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
diff
changeset
|
45 |
12324
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
46 $ ls .hg/patches/new/dir |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
47 .hg/patches/new/dir |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
48 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
49 $ cd .. |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
50 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
51 Test patch being renamed before committed: |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
52 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
53 $ hg init b |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
54 $ cd b |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
55 $ hg qinit -c |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
56 $ hg qnew x |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
57 $ hg qrename y |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
58 $ hg qcommit -m rename |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
59 |
b701610f6c56
tests: unify some of test-mq*
Adrian Buehlmann <adrian@cadifra.com>
parents:
11513
diff
changeset
|
60 $ cd .. |
6649
05a682c8907d
test-mq-qrename: test added patch renaming
Patrick Mezard <pmezard@gmail.com>
parents:
3083
diff
changeset
|
61 |
12361 | 62 Test overlapping renames (issue2388) |
6649
05a682c8907d
test-mq-qrename: test added patch renaming
Patrick Mezard <pmezard@gmail.com>
parents:
3083
diff
changeset
|
63 |
12361 | 64 $ hg init c |
65 $ cd c | |
66 $ hg qinit -c | |
67 $ echo a > a | |
68 $ hg add | |
69 adding a | |
70 $ hg qnew patcha | |
71 $ echo b > b | |
72 $ hg add | |
73 adding b | |
74 $ hg qnew patchb | |
75 $ hg ci --mq -m c1 | |
76 $ hg qrename patchb patchc | |
77 $ hg qrename patcha patchb | |
78 $ hg st --mq | |
23402
2963d5c9d90b
rename: properly report removed and added file as modified (issue4458)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22521
diff
changeset
|
79 M patchb |
12361 | 80 M series |
81 A patchc | |
82 R patcha | |
83 $ cd .. | |
12875
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
84 |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
85 Test renames with mq repo (issue2097) |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
86 |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
87 $ hg init issue2097 |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
88 $ cd issue2097 |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
89 $ hg qnew p0 |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
90 $ (cd .hg/patches && hg init) |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
91 $ hg qren p0 p1 |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
92 $ hg debugstate --mq |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
93 $ hg ci --mq -mq0 |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
94 nothing changed |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
95 [1] |
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12361
diff
changeset
|
96 $ cd .. |
15322
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
97 |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
98 Test renaming to a folded patch (issue3058) |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
99 |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
100 $ hg init issue3058 |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
101 $ cd issue3058 |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
102 $ hg init --mq |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
103 $ echo a > a |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
104 $ hg add a |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
105 $ hg qnew adda |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
106 $ echo b >> a |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
107 $ hg qnew addb |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
108 $ hg qpop |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
109 popping addb |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
110 now at: adda |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
111 $ hg ci --mq -m "save mq" |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
112 $ hg qfold addb |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
113 $ hg qmv addb |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
114 $ cat .hg/patches/addb |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
115 # HG changeset patch |
22521
3f948469bac0
mq: write '# Parent ' lines with two spaces like export does (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
15322
diff
changeset
|
116 # Parent 0000000000000000000000000000000000000000 |
15322
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
117 |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
118 diff -r 000000000000 a |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
119 --- /dev/null * (glob) |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
120 +++ b/a * (glob) |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
121 @@ -0,0 +1,2 @@ |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
122 +a |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
123 +b |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
124 $ cd .. |
c8e2a5ea7062
mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard <pmezard@gmail.com>
parents:
12875
diff
changeset
|
125 |