Mercurial > hg
view tests/test-convert-hg-source.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 | a2f11188e2d2 |
children |
line wrap: on
line source
created new head merging baz and foo to baz 1 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) 1 files updated, 0 files merged, 1 files removed, 0 files unresolved merging foo and baz to baz 1 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) created new head marked working directory as branch foo initializing destination new repository scanning source... sorting... converting... 7 add foo bar 6 change foo 5 make bar and baz copies of foo 4 merge local copy 3 merge remote copy 2 mark baz executable 1 branch foo 0 close comparing with ../orig searching for changes no changes found % check shamap LF and CRLF handling scanning source... sorting... converting... 1 change foo again again 0 change foo again % init broken repository created new head % break it initializing destination fixed repository scanning source... sorting... converting... 4 init ignoring: data/b.i@1e88685f5dde: no match found 3 changeall 2 changebagain 1 merge 0 moveb checking changesets checking manifests crosschecking files in changesets and manifests checking files 3 files, 5 changesets, 5 total revisions % manifest -r 0 a % manifest -r tip a c d