annotate tests/test-addremove.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 d8e0c591781c
children dd050fc04cc9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11850
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
1 $ hg init rep
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
2 $ cd rep
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
3 $ mkdir dir
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
4 $ touch foo dir/bar
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
5 $ hg -v addremove
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
6 adding dir/bar
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
7 adding foo
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11850
diff changeset
8 $ hg -v commit -m "add 1"
23749
a387b0390082 localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents: 23535
diff changeset
9 committing files:
11850
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
10 dir/bar
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
11 foo
23749
a387b0390082 localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents: 23535
diff changeset
12 committing manifest
a387b0390082 localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents: 23535
diff changeset
13 committing changelog
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11850
diff changeset
14 committed changeset 0:6f7f953567a2
11850
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
15 $ cd dir/
16874
8017ac7a0e8f test-addremove: remove bits about con.xml
Adrian Buehlmann <adrian@cadifra.com>
parents: 15444
diff changeset
16 $ touch ../foo_2 bar_2
11850
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
17 $ hg -v addremove
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
18 adding dir/bar_2
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
19 adding foo_2
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11850
diff changeset
20 $ hg -v commit -m "add 2"
23749
a387b0390082 localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents: 23535
diff changeset
21 committing files:
11850
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
22 dir/bar_2
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
23 foo_2
23749
a387b0390082 localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents: 23535
diff changeset
24 committing manifest
a387b0390082 localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents: 23535
diff changeset
25 committing changelog
16874
8017ac7a0e8f test-addremove: remove bits about con.xml
Adrian Buehlmann <adrian@cadifra.com>
parents: 15444
diff changeset
26 committed changeset 1:e65414bf35c5
23259
9f4778027bc2 addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 16912
diff changeset
27 $ cd ..
9f4778027bc2 addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 16912
diff changeset
28 $ hg forget foo
9f4778027bc2 addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 16912
diff changeset
29 $ hg -v addremove
9f4778027bc2 addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 16912
diff changeset
30 adding foo
23534
83bbedc16b3f addremove: warn when addremove fails to operate on a named path
Matt Harbison <matt_harbison@yahoo.com>
parents: 23427
diff changeset
31 $ hg forget foo
83bbedc16b3f addremove: warn when addremove fails to operate on a named path
Matt Harbison <matt_harbison@yahoo.com>
parents: 23427
diff changeset
32 #if windows
24180
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23749
diff changeset
33 $ hg -v addremove nonexistent
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23749
diff changeset
34 nonexistent: The system cannot find the file specified
23534
83bbedc16b3f addremove: warn when addremove fails to operate on a named path
Matt Harbison <matt_harbison@yahoo.com>
parents: 23427
diff changeset
35 [1]
83bbedc16b3f addremove: warn when addremove fails to operate on a named path
Matt Harbison <matt_harbison@yahoo.com>
parents: 23427
diff changeset
36 #else
24180
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23749
diff changeset
37 $ hg -v addremove nonexistent
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23749
diff changeset
38 nonexistent: No such file or directory
23534
83bbedc16b3f addremove: warn when addremove fails to operate on a named path
Matt Harbison <matt_harbison@yahoo.com>
parents: 23427
diff changeset
39 [1]
83bbedc16b3f addremove: warn when addremove fails to operate on a named path
Matt Harbison <matt_harbison@yahoo.com>
parents: 23427
diff changeset
40 #endif
23259
9f4778027bc2 addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 16912
diff changeset
41 $ cd ..
2958
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
42
23427
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
43 $ hg init subdir
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
44 $ cd subdir
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
45 $ mkdir dir
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
46 $ cd dir
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
47 $ touch a.py
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
48 $ hg addremove 'glob:*.py'
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
49 adding a.py
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
50 $ hg forget a.py
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
51 $ hg addremove -I 'glob:*.py'
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
52 adding a.py
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
53 $ hg forget a.py
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
54 $ hg addremove
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
55 adding dir/a.py
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
56 $ cd ..
3778884197f0 addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 23259
diff changeset
57
11850
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
58 $ hg init sim
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
59 $ cd sim
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
60 $ echo a > a
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
61 $ echo a >> a
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
62 $ echo a >> a
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
63 $ echo c > c
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
64 $ hg commit -Ama
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
65 adding a
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
66 adding c
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
67 $ mv a b
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
68 $ rm c
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
69 $ echo d > d
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
70 $ hg addremove -n -s 50 # issue 1696
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
71 removing a
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
72 adding b
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
73 removing c
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
74 adding d
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
75 recording removal of a as rename to b (100% similar)
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
76 $ hg addremove -s 50
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
77 removing a
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
78 adding b
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
79 removing c
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
80 adding d
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
81 recording removal of a as rename to b (100% similar)
54dbf16b401f tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents: 8990
diff changeset
82 $ hg commit -mb
23259
9f4778027bc2 addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 16912
diff changeset
83 $ cp b c
9f4778027bc2 addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 16912
diff changeset
84 $ hg forget b
9f4778027bc2 addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 16912
diff changeset
85 $ hg addremove -s 50
9f4778027bc2 addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 16912
diff changeset
86 adding b
9f4778027bc2 addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents: 16912
diff changeset
87 adding c
23535
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
88
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
89 $ rm c
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
90 #if windows
24180
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23749
diff changeset
91 $ hg ci -A -m "c" nonexistent
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23749
diff changeset
92 nonexistent: The system cannot find the file specified
23535
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
93 abort: failed to mark all new/missing files as added/removed
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
94 [255]
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
95 #else
24180
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23749
diff changeset
96 $ hg ci -A -m "c" nonexistent
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23749
diff changeset
97 nonexistent: No such file or directory
23535
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
98 abort: failed to mark all new/missing files as added/removed
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
99 [255]
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
100 #endif
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
101 $ hg st
72c23fa4f52f commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents: 23534
diff changeset
102 ! c
16912
6ef3107c661e tests: cleanup of tests that got lost in their own nested directories
Mads Kiilerich <mads@kiilerich.com>
parents: 16874
diff changeset
103 $ cd ..