annotate tests/test-extdata.t @ 34459:a1b89c8ad32d

templater: add experimental support for extdata This is minimal and non-controversial implementation of extdata() template function. Originally extdata sources were exposed to the keyword namespace, but I've changed it to a plain function for simplicity.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 01 Oct 2017 11:13:09 +0100
parents 2c3b8fa3211b
children d5c5cc767b7e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
34458
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
1 $ hg init repo
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
2 $ cd repo
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
3 $ for n in 0 1 2 3; do
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
4 > echo $n > $n
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
5 > hg ci -qAm $n
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
6 > done
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
7
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
8 test revset support
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
9
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
10 $ cat <<'EOF' >> .hg/hgrc
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
11 > [extdata]
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
12 > filedata = file:extdata.txt
34459
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
13 > notes = notes.txt
34458
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
14 > shelldata = shell:cat extdata.txt | grep 2
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
15 > EOF
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
16 $ cat <<'EOF' > extdata.txt
34459
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
17 > 2 another comment on 2
34458
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
18 > 3
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
19 > EOF
34459
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
20 $ cat <<'EOF' > notes.txt
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
21 > f6ed this change is great!
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
22 > e834 this is buggy :(
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
23 > 0625 first post
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
24 > bogusnode gives no error
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
25 > EOF
34458
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
26
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
27 $ hg log -qr "extdata(filedata)"
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
28 2:f6ed99a58333
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
29 3:9de260b1e88e
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
30 $ hg log -qr "extdata(shelldata)"
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
31 2:f6ed99a58333
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
32
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
33 test weight of extdata() revset
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
34
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
35 $ hg debugrevspec -p optimized "extdata(filedata) & 3"
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
36 * optimized:
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
37 (andsmally
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
38 (func
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
39 (symbol 'extdata')
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
40 (symbol 'filedata'))
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
41 (symbol '3'))
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
42 3
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
43
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
44 test bad extdata() revset source
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
45
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
46 $ hg log -qr "extdata()"
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
47 hg: parse error: extdata takes at least 1 string argument
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
48 [255]
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
49 $ hg log -qr "extdata(unknown)"
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
50 abort: unknown extdata source 'unknown'
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
51 [255]
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
52
34459
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
53 test template support:
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
54
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
55 $ hg log -r:3 -T "{node|short}{if(extdata('notes'), ' # {extdata('notes')}')}\n"
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
56 06254b906311 # first post
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
57 e8342c9a2ed1 # this is buggy :(
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
58 f6ed99a58333 # this change is great!
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
59 9de260b1e88e
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
60
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
61 test template cache:
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
62
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
63 $ hg log -r:3 -T '{rev} "{extdata("notes")}" "{extdata("shelldata")}"\n'
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
64 0 "first post" ""
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
65 1 "this is buggy :(" ""
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
66 2 "this change is great!" "another comment on 2"
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
67 3 "" ""
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
68
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
69 test bad extdata() template source
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
70
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
71 $ hg log -T "{extdata()}\n"
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
72 hg: parse error: extdata expects one argument
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
73 [255]
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
74 $ hg log -T "{extdata('unknown')}\n"
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
75 abort: unknown extdata source 'unknown'
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
76 [255]
a1b89c8ad32d templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents: 34458
diff changeset
77
34458
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
78 we don't fix up relative file URLs, but we do run shell commands in repo root
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
79
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
80 $ mkdir sub
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
81 $ cd sub
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
82 $ hg log -qr "extdata(filedata)"
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
83 abort: error: No such file or directory
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
84 [255]
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
85 $ hg log -qr "extdata(shelldata)"
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
86 2:f6ed99a58333
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
87
2c3b8fa3211b revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
88 $ cd ..