Mercurial > hg
annotate tests/test-template-engine @ 8820:e8cb1fa0d4a9
test-convert-cvsnt-mergepoints: make it work on OS X.
- don't create file 'cvs' where directory 'CVS' already exists
author | Greg Ward <greg-hg@gerg.ca> |
---|---|
date | Mon, 15 Jun 2009 20:35:19 -0400 |
parents | d8c5a7f25a40 |
children | d4d4da54ab05 |
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(): |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
14 v = templater.stringify(v) |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
15 tmpl = tmpl.replace('{{%s}}' % k, v) |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
16 yield tmpl |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
17 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
18 templater.engines['my'] = mytemplater |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
19 EOF |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
20 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
21 hg init test |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
22 echo '[extensions]' > test/.hg/hgrc |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
23 echo "engine = $PWD/engine.py" >> test/.hg/hgrc |
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 cd test |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
26 cat > mymap << EOF |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
27 changeset = my:changeset.txt |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
28 EOF |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
29 |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
30 cat > changeset.txt << EOF |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
31 {{rev}} {{node}} {{author}} |
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 hg ci -Ama |
d8c5a7f25a40
templater: make the templating engine pluggable to some extent
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
35 hg log --style=./mymap |