Show More
@@ -24,6 +24,7 b' from . import (' | |||
|
24 | 24 | registrar, |
|
25 | 25 | revset as revsetmod, |
|
26 | 26 | revsetlang, |
|
27 | scmutil, | |
|
27 | 28 | templatefilters, |
|
28 | 29 | templatekw, |
|
29 | 30 | util, |
@@ -593,6 +594,22 b' def diff(context, mapping, args):' | |||
|
593 | 594 | |
|
594 | 595 | return ''.join(chunks) |
|
595 | 596 | |
|
597 | @templatefunc('extdata(source)', argspec='source') | |
|
598 | def extdata(context, mapping, args): | |
|
599 | """Show a text read from the specified extdata source. (EXPERIMENTAL)""" | |
|
600 | if 'source' not in args: | |
|
601 | # i18n: "extdata" is a keyword | |
|
602 | raise error.ParseError(_('extdata expects one argument')) | |
|
603 | ||
|
604 | source = evalstring(context, mapping, args['source']) | |
|
605 | cache = mapping['cache'].setdefault('extdata', {}) | |
|
606 | ctx = mapping['ctx'] | |
|
607 | if source in cache: | |
|
608 | data = cache[source] | |
|
609 | else: | |
|
610 | data = cache[source] = scmutil.extdatasource(ctx.repo(), source) | |
|
611 | return data.get(ctx.rev(), '') | |
|
612 | ||
|
596 | 613 | @templatefunc('files(pattern)') |
|
597 | 614 | def files(context, mapping, args): |
|
598 | 615 | """All files of the current changeset matching the pattern. See |
@@ -10,12 +10,19 b' test revset support' | |||
|
10 | 10 | $ cat <<'EOF' >> .hg/hgrc |
|
11 | 11 | > [extdata] |
|
12 | 12 | > filedata = file:extdata.txt |
|
13 | > notes = notes.txt | |
|
13 | 14 | > shelldata = shell:cat extdata.txt | grep 2 |
|
14 | 15 | > EOF |
|
15 | 16 | $ cat <<'EOF' > extdata.txt |
|
16 | > 2 | |
|
17 | > 2 another comment on 2 | |
|
17 | 18 | > 3 |
|
18 | 19 | > EOF |
|
20 | $ cat <<'EOF' > notes.txt | |
|
21 | > f6ed this change is great! | |
|
22 | > e834 this is buggy :( | |
|
23 | > 0625 first post | |
|
24 | > bogusnode gives no error | |
|
25 | > EOF | |
|
19 | 26 | |
|
20 | 27 | $ hg log -qr "extdata(filedata)" |
|
21 | 28 | 2:f6ed99a58333 |
@@ -43,6 +50,31 b' test bad extdata() revset source' | |||
|
43 | 50 | abort: unknown extdata source 'unknown' |
|
44 | 51 | [255] |
|
45 | 52 | |
|
53 | test template support: | |
|
54 | ||
|
55 | $ hg log -r:3 -T "{node|short}{if(extdata('notes'), ' # {extdata('notes')}')}\n" | |
|
56 | 06254b906311 # first post | |
|
57 | e8342c9a2ed1 # this is buggy :( | |
|
58 | f6ed99a58333 # this change is great! | |
|
59 | 9de260b1e88e | |
|
60 | ||
|
61 | test template cache: | |
|
62 | ||
|
63 | $ hg log -r:3 -T '{rev} "{extdata("notes")}" "{extdata("shelldata")}"\n' | |
|
64 | 0 "first post" "" | |
|
65 | 1 "this is buggy :(" "" | |
|
66 | 2 "this change is great!" "another comment on 2" | |
|
67 | 3 "" "" | |
|
68 | ||
|
69 | test bad extdata() template source | |
|
70 | ||
|
71 | $ hg log -T "{extdata()}\n" | |
|
72 | hg: parse error: extdata expects one argument | |
|
73 | [255] | |
|
74 | $ hg log -T "{extdata('unknown')}\n" | |
|
75 | abort: unknown extdata source 'unknown' | |
|
76 | [255] | |
|
77 | ||
|
46 | 78 |
|
|
47 | 79 | |
|
48 | 80 | $ mkdir sub |
General Comments 0
You need to be logged in to leave comments.
Login now