Mercurial > hg
annotate tests/test-diff-newlines.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 | 3d1f9dcecdea |
children |
rev | line source |
---|---|
2248
b914f0557832
fix diffs containing embedded "\r".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1 adding a |
b914f0557832
fix diffs containing embedded "\r".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
2 diff -r 107ba6f817b5 -r 310ce7989cdc a |
b914f0557832
fix diffs containing embedded "\r".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
3 --- a/a Thu Jan 01 00:00:01 1970 +0000 |
b914f0557832
fix diffs containing embedded "\r".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
4 +++ b/a Thu Jan 01 00:00:02 1970 +0000 |
5863
3d1f9dcecdea
diff: don't show function name by default
Matt Mackall <mpm@selenic.com>
parents:
2248
diff
changeset
|
5 @@ -1,2 +1,3 @@ |
2248
b914f0557832
fix diffs containing embedded "\r".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
6 confuse str.splitlines |
b914f0557832
fix diffs containing embedded "\r".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
7 embedded newline |
b914f0557832
fix diffs containing embedded "\r".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
8 +clean diff |