Mercurial > hg
view tests/test-cat.t @ 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 | a3c1234b3761 |
children | fddacca3202e |
line wrap: on
line source
$ mkdir t $ cd t $ hg init $ echo 0 > a $ echo 0 > b $ hg ci -A -m m -d "1000000 0" adding a adding b $ hg rm a $ hg cat a 0 $ hg cat --decode a # more tests in test-encode 0 $ echo 1 > b $ hg ci -m m -d "1000000 0" $ echo 2 > b $ hg cat -r 0 a 0 $ hg cat -r 0 b 0 $ hg cat -r 1 a a: No such file in rev 03f6b0774996 $ hg cat -r 1 b 1