Debian Codegraph @

tests/test-extdata.t

raw
1 $ hg init repo
2 $ cd repo
3 $ for n in 0 1 2 3 4 5 6 7 8 9 10 11; do
4 > echo $n > $n
5 > hg ci -qAm $n
6 > done
7
8 test revset support
9
10 $ cat <<'EOF' >> .hg/hgrc
11 > [extdata]
12 > filedata = file:extdata.txt
13 > notes = notes.txt
14 > shelldata = shell:cat extdata.txt | grep 2
15 > emptygrep = shell:cat extdata.txt | grep empty
16 > badparse = shell:cat badparse.txt
17 > EOF
18 $ cat <<'EOF' > extdata.txt
19 > 2 another comment on 2
20 > 3
21 > EOF
22 $ cat <<'EOF' > notes.txt
23 > f6ed this change is great!
24 > e834 this is buggy :(
25 > 0625 first post
26 > bogusnode gives no error
27 > a ambiguous node gives no error
28 > EOF
29
30 $ hg log -qr "extdata(filedata)"
31 2:f6ed99a58333
32 3:9de260b1e88e
33 $ hg log -qr "extdata(shelldata)"
34 2:f6ed99a58333
35
36 test weight of extdata() revset
37
38 $ hg debugrevspec -p optimized "extdata(filedata) & 3"
39 * optimized:
40 (andsmally
41 (func
42 (symbol 'extdata')
43 (symbol 'filedata'))
44 (symbol '3'))
45 3
46
47 test non-zero exit of shell command
48
49 $ hg log -qr "extdata(emptygrep)"
50 abort: extdata command 'cat extdata.txt | grep empty' failed: exited with status 1
51 [255]
52
53 test bad extdata() revset source
54
55 $ hg log -qr "extdata()"
56 hg: parse error: extdata takes at least 1 string argument
57 [10]
58 $ hg log -qr "extdata(unknown)"
59 abort: unknown extdata source 'unknown'
60 [255]
61
62 test a zero-exiting source that emits garbage to confuse the revset parser
63
64 $ cat > badparse.txt <<'EOF'
65 > +---------------------------------------+
66 > 9de260b1e88e
67 > EOF
68
69 It might be nice if this error message mentioned where the bad string
70 came from (eg line X of extdata source S), but the important thing is
71 that we don't crash before we can print the parse error.
72 $ hg log -qr "extdata(badparse)"
73 hg: parse error at 0: not a prefix: +
74 (+---------------------------------------+
75 ^ here)
76 [10]
77
78 test template support:
79
80 $ hg log -r:3 -T "{node|short}{if(extdata('notes'), ' # {extdata('notes')}')}\n"
81 06254b906311 # first post
82 e8342c9a2ed1 # this is buggy :(
83 f6ed99a58333 # this change is great!
84 9de260b1e88e
85
86 test template cache:
87
88 $ hg log -r:3 -T '{rev} "{extdata("notes")}" "{extdata("shelldata")}"\n'
89 0 "first post" ""
90 1 "this is buggy :(" ""
91 2 "this change is great!" "another comment on 2"
92 3 "" ""
93
94 test bad extdata() template source
95
96 $ hg log -T "{extdata()}\n"
97 hg: parse error: extdata expects one argument
98 [10]
99 $ hg log -T "{extdata('unknown')}\n"
100 abort: unknown extdata source 'unknown'
101 [255]
102 $ hg log -T "{extdata(unknown)}\n"
103 hg: parse error: empty data source specified
104 (did you mean extdata('unknown')?)
105 [10]
106 $ hg log -T "{extdata('{unknown}')}\n"
107 hg: parse error: empty data source specified
108 [10]
109
110 we don't fix up relative file URLs, but we do run shell commands in repo root
111
112 $ mkdir sub
113 $ cd sub
114 $ hg log -qr "extdata(filedata)"
115 abort: error: $ENOENT$
116 [100]
117 $ hg log -qr "extdata(shelldata)"
118 2:f6ed99a58333
119
120 $ cd ..