author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Sat, 10 Apr 2021 21:55:01 +0200 | |
changeset 46911 | 6071bfab6292 |
parent 45895 | fc4fb2f17dd4 |
permissions | -rw-r--r-- |
34457
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 |
34459
d5c5cc767b7e
extdata: ignore ambiguous identifier as well
Yuya Nishihara <yuya@tcha.org>
parents:
34458
diff
changeset
|
3 |
$ for n in 0 1 2 3 4 5 6 7 8 9 10 11; do |
34457
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 |
34458
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
13 |
> notes = notes.txt |
34457
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
14 |
> shelldata = shell:cat extdata.txt | grep 2 |
34542
153e4e05e9b3
extdata: show debug message if external command exits with non-zero status
Yuya Nishihara <yuya@tcha.org>
parents:
34459
diff
changeset
|
15 |
> emptygrep = shell:cat extdata.txt | grep empty |
42575
eec65b706caf
extdata: demonstrate bad behavior when a subprocess emits garbage
Augie Fackler <augie@google.com>
parents:
37931
diff
changeset
|
16 |
> badparse = shell:cat badparse.txt |
34457
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
17 |
> EOF |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
18 |
$ cat <<'EOF' > extdata.txt |
34458
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
19 |
> 2 another comment on 2 |
34457
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
20 |
> 3 |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
21 |
> EOF |
34458
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
22 |
$ cat <<'EOF' > notes.txt |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
23 |
> f6ed this change is great! |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
24 |
> e834 this is buggy :( |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
25 |
> 0625 first post |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
26 |
> bogusnode gives no error |
34459
d5c5cc767b7e
extdata: ignore ambiguous identifier as well
Yuya Nishihara <yuya@tcha.org>
parents:
34458
diff
changeset
|
27 |
> a ambiguous node gives no error |
34458
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
28 |
> EOF |
34457
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
29 |
|
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
30 |
$ hg log -qr "extdata(filedata)" |
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 |
3:9de260b1e88e |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
33 |
$ hg log -qr "extdata(shelldata)" |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
34 |
2:f6ed99a58333 |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
35 |
|
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
36 |
test weight of extdata() revset |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
37 |
|
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
38 |
$ hg debugrevspec -p optimized "extdata(filedata) & 3" |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
39 |
* optimized: |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
40 |
(andsmally |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
41 |
(func |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
42 |
(symbol 'extdata') |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
43 |
(symbol 'filedata')) |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
44 |
(symbol '3')) |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
45 |
3 |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
46 |
|
34542
153e4e05e9b3
extdata: show debug message if external command exits with non-zero status
Yuya Nishihara <yuya@tcha.org>
parents:
34459
diff
changeset
|
47 |
test non-zero exit of shell command |
153e4e05e9b3
extdata: show debug message if external command exits with non-zero status
Yuya Nishihara <yuya@tcha.org>
parents:
34459
diff
changeset
|
48 |
|
153e4e05e9b3
extdata: show debug message if external command exits with non-zero status
Yuya Nishihara <yuya@tcha.org>
parents:
34459
diff
changeset
|
49 |
$ hg log -qr "extdata(emptygrep)" |
35412
b1959391a088
extdata: abort if external command exits with non-zero status (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
35230
diff
changeset
|
50 |
abort: extdata command 'cat extdata.txt | grep empty' failed: exited with status 1 |
b1959391a088
extdata: abort if external command exits with non-zero status (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
35230
diff
changeset
|
51 |
[255] |
34542
153e4e05e9b3
extdata: show debug message if external command exits with non-zero status
Yuya Nishihara <yuya@tcha.org>
parents:
34459
diff
changeset
|
52 |
|
34457
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
53 |
test bad extdata() revset source |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
54 |
|
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
55 |
$ hg log -qr "extdata()" |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
56 |
hg: parse error: extdata takes at least 1 string argument |
45895
fc4fb2f17dd4
errors: use exit code 10 for parse errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
45839
diff
changeset
|
57 |
[10] |
34457
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
58 |
$ hg log -qr "extdata(unknown)" |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
59 |
abort: unknown extdata source 'unknown' |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
60 |
[255] |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
61 |
|
42575
eec65b706caf
extdata: demonstrate bad behavior when a subprocess emits garbage
Augie Fackler <augie@google.com>
parents:
37931
diff
changeset
|
62 |
test a zero-exiting source that emits garbage to confuse the revset parser |
eec65b706caf
extdata: demonstrate bad behavior when a subprocess emits garbage
Augie Fackler <augie@google.com>
parents:
37931
diff
changeset
|
63 |
|
eec65b706caf
extdata: demonstrate bad behavior when a subprocess emits garbage
Augie Fackler <augie@google.com>
parents:
37931
diff
changeset
|
64 |
$ cat > badparse.txt <<'EOF' |
eec65b706caf
extdata: demonstrate bad behavior when a subprocess emits garbage
Augie Fackler <augie@google.com>
parents:
37931
diff
changeset
|
65 |
> +---------------------------------------+ |
eec65b706caf
extdata: demonstrate bad behavior when a subprocess emits garbage
Augie Fackler <augie@google.com>
parents:
37931
diff
changeset
|
66 |
> 9de260b1e88e |
eec65b706caf
extdata: demonstrate bad behavior when a subprocess emits garbage
Augie Fackler <augie@google.com>
parents:
37931
diff
changeset
|
67 |
> EOF |
eec65b706caf
extdata: demonstrate bad behavior when a subprocess emits garbage
Augie Fackler <augie@google.com>
parents:
37931
diff
changeset
|
68 |
|
42576
ea6558db1011
extdata: avoid crashing inside subprocess when we get a revset parse error
Augie Fackler <augie@google.com>
parents:
42575
diff
changeset
|
69 |
It might be nice if this error message mentioned where the bad string |
ea6558db1011
extdata: avoid crashing inside subprocess when we get a revset parse error
Augie Fackler <augie@google.com>
parents:
42575
diff
changeset
|
70 |
came from (eg line X of extdata source S), but the important thing is |
ea6558db1011
extdata: avoid crashing inside subprocess when we get a revset parse error
Augie Fackler <augie@google.com>
parents:
42575
diff
changeset
|
71 |
that we don't crash before we can print the parse error. |
ea6558db1011
extdata: avoid crashing inside subprocess when we get a revset parse error
Augie Fackler <augie@google.com>
parents:
42575
diff
changeset
|
72 |
$ hg log -qr "extdata(badparse)" |
ea6558db1011
extdata: avoid crashing inside subprocess when we get a revset parse error
Augie Fackler <augie@google.com>
parents:
42575
diff
changeset
|
73 |
hg: parse error at 0: not a prefix: + |
ea6558db1011
extdata: avoid crashing inside subprocess when we get a revset parse error
Augie Fackler <augie@google.com>
parents:
42575
diff
changeset
|
74 |
(+---------------------------------------+ |
ea6558db1011
extdata: avoid crashing inside subprocess when we get a revset parse error
Augie Fackler <augie@google.com>
parents:
42575
diff
changeset
|
75 |
^ here) |
45895
fc4fb2f17dd4
errors: use exit code 10 for parse errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
45839
diff
changeset
|
76 |
[10] |
42575
eec65b706caf
extdata: demonstrate bad behavior when a subprocess emits garbage
Augie Fackler <augie@google.com>
parents:
37931
diff
changeset
|
77 |
|
34458
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
78 |
test template support: |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
79 |
|
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
80 |
$ 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:
34457
diff
changeset
|
81 |
06254b906311 # first post |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
82 |
e8342c9a2ed1 # this is buggy :( |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
83 |
f6ed99a58333 # this change is great! |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
84 |
9de260b1e88e |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
85 |
|
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
86 |
test template cache: |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
87 |
|
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
88 |
$ hg log -r:3 -T '{rev} "{extdata("notes")}" "{extdata("shelldata")}"\n' |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
89 |
0 "first post" "" |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
90 |
1 "this is buggy :(" "" |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
91 |
2 "this change is great!" "another comment on 2" |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
92 |
3 "" "" |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
93 |
|
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
94 |
test bad extdata() template source |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
95 |
|
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
96 |
$ hg log -T "{extdata()}\n" |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
97 |
hg: parse error: extdata expects one argument |
45895
fc4fb2f17dd4
errors: use exit code 10 for parse errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
45839
diff
changeset
|
98 |
[10] |
34458
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
99 |
$ hg log -T "{extdata('unknown')}\n" |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
100 |
abort: unknown extdata source 'unknown' |
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
101 |
[255] |
37931
faa41fd282d1
templatefuncs: show hint if extdata source is evaluated to empty (issue5843)
Yuya Nishihara <yuya@tcha.org>
parents:
35412
diff
changeset
|
102 |
$ hg log -T "{extdata(unknown)}\n" |
faa41fd282d1
templatefuncs: show hint if extdata source is evaluated to empty (issue5843)
Yuya Nishihara <yuya@tcha.org>
parents:
35412
diff
changeset
|
103 |
hg: parse error: empty data source specified |
faa41fd282d1
templatefuncs: show hint if extdata source is evaluated to empty (issue5843)
Yuya Nishihara <yuya@tcha.org>
parents:
35412
diff
changeset
|
104 |
(did you mean extdata('unknown')?) |
45895
fc4fb2f17dd4
errors: use exit code 10 for parse errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
45839
diff
changeset
|
105 |
[10] |
37931
faa41fd282d1
templatefuncs: show hint if extdata source is evaluated to empty (issue5843)
Yuya Nishihara <yuya@tcha.org>
parents:
35412
diff
changeset
|
106 |
$ hg log -T "{extdata('{unknown}')}\n" |
faa41fd282d1
templatefuncs: show hint if extdata source is evaluated to empty (issue5843)
Yuya Nishihara <yuya@tcha.org>
parents:
35412
diff
changeset
|
107 |
hg: parse error: empty data source specified |
45895
fc4fb2f17dd4
errors: use exit code 10 for parse errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
45839
diff
changeset
|
108 |
[10] |
34458
a1b89c8ad32d
templater: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34457
diff
changeset
|
109 |
|
34457
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
110 |
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
|
111 |
|
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
112 |
$ mkdir sub |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
113 |
$ cd sub |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
114 |
$ hg log -qr "extdata(filedata)" |
35230
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
34690
diff
changeset
|
115 |
abort: error: $ENOENT$ |
45839
ebee234d952a
errors: set detailed exit code to 100 for some remote errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
42576
diff
changeset
|
116 |
[100] |
34457
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
117 |
$ hg log -qr "extdata(shelldata)" |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
118 |
2:f6ed99a58333 |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
119 |
|
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
120 |
$ cd .. |