Mercurial > hg
annotate tests/test-hgcia.out @ 11988:8380ed691df8
util: add an interpolate() function to for replacing multiple values
util.interpolate can be used to replace multiple items in a string all at once
(and optionally apply a function to the replacement), without worrying about
recursing:
>>> import util
>>> s = '$foo, $spam'
>>> util.interpolate(r'\$', { 'foo': 'bar', 'spam': 'eggs' }, s)
'bar, eggs'
>>> util.interpolate(r'\$', { 'foo': 'spam', 'spam': 'foo' }, s)
'spam, foo'
>>> util.interpolate(r'\$', { 'foo': 'spam', 'spam': 'foo' }, s, lambda s: s.upper())
'SPAM, FOO'
The patch also changes filemerge.py to use this new function.
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Wed, 18 Aug 2010 18:18:26 -0400 |
parents | b80b944836ec |
children |
rev | line source |
---|---|
7438 | 1 adding foo |
2 pushing to ../cia | |
3 searching for changes | |
4 adding changesets | |
5 adding manifests | |
6 adding file changes | |
7 added 1 changesets with 1 changes to 1 files | |
8 | |
9 <message> | |
10 <generator> | |
11 <name>Mercurial (hgcia)</name> | |
12 <version>0.1</version> | |
13 <url>http://hg.kublai.com/mercurial/hgcia</url> | |
14 <user>testuser</user> | |
15 </generator> | |
16 <source> | |
17 <project>testproject</project> | |
18 <branch>default</branch> | |
19 </source> | |
20 <body> | |
21 <commit> | |
22 <author>test</author> | |
23 <version>0:e63c23eaa88a</version> | |
24 <log>foo</log> | |
25 | |
26 <files><file action="add">foo</file></files> | |
27 </commit> | |
28 </body> | |
29 <timestamp>0</timestamp> | |
30 </message> |