Mercurial > hg
annotate tests/test-template-engine @ 12252:4481f8a93c7a stable
convert/darcs: handle non-ASCII metadata in darcs changelog (issue2354)
Given a commit author or message with non-ASCII characters in a darcs
repo, convert would raise a UnicodeEncodeError when adding changesets
to the hg changelog.
This happened because etree returns back unicode objects for any text
it can't encode into ASCII. convert was passing these objects to
changelog.add(), which would then attempt encoding.fromlocal() on
them.
This patch ensures converter_source.recode() is called on each piece
of commit data returned by etree.
(Also note that darcs is currently encoding agnostic and will print
out whatever is in a patch's metadata byte-for-byte, even in the XML
changelog.)
author | Brodie Rao <brodie@bitheap.org> |
---|---|
date | Fri, 10 Sep 2010 09:30:50 -0500 |
parents | babc00a82c5e |
children |
rev | line source |
---|---|
8361
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1 #!/bin/sh |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
2 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
3 cat > engine.py << EOF |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
4 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
5 from mercurial import templater |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
6 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
7 class mytemplater(object): |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
8 def __init__(self, loader, filters, defaults): |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
9 self.loader = loader |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
10 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
11 def process(self, t, map): |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
12 tmpl = self.loader(t) |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
13 for k, v in map.iteritems(): |
10057
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
14 if k in ('templ', 'ctx', 'repo', 'revcache', 'cache'): |
10054
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
9044
diff
changeset
|
15 continue |
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
9044
diff
changeset
|
16 if hasattr(v, '__call__'): |
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
9044
diff
changeset
|
17 v = v(**map) |
8361
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
18 v = templater.stringify(v) |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
19 tmpl = tmpl.replace('{{%s}}' % k, v) |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
20 yield tmpl |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
21 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
22 templater.engines['my'] = mytemplater |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
23 EOF |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
24 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
25 hg init test |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
26 echo '[extensions]' > test/.hg/hgrc |
9044
d4d4da54ab05
Bourne shells do not maintain $PWD; update tests accordingly
David Champion <dgc@uchicago.edu>
parents:
8361
diff
changeset
|
27 echo "engine = `pwd`/engine.py" >> test/.hg/hgrc |
8361
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
28 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
29 cd test |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
30 cat > mymap << EOF |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
31 changeset = my:changeset.txt |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
32 EOF |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
33 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
34 cat > changeset.txt << EOF |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
35 {{rev}} {{node}} {{author}} |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
36 EOF |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
37 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
38 hg ci -Ama |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
39 hg log --style=./mymap |