Mercurial > hg
annotate tests/test-interhg @ 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 | 634b0e7561ec |
children |
rev | line source |
---|---|
10473
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
1 #!/bin/sh |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
2 |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
3 hg init test |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
4 cd test |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
5 |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
6 cat > .hg/hgrc <<EOF |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
7 [extensions] |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
8 interhg = |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
9 |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
10 [interhg] |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
11 issues = s|Issue(\d+)|<a href="http://bts.example.org/issue\1">Issue\1</a>| |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
12 |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
13 # yes, 'x' is a weird delimiter... |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
14 markbugs = sxbugx<i class="\x">bug</i>x |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
15 EOF |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
16 |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
17 touch foo |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
18 hg add foo |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
19 hg commit -d '1 0' -m 'Issue123: fixed the bug!' |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
20 |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
21 hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
22 cat hg.pid >> $DAEMON_PIDS |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
23 |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
24 echo % log |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
25 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/' | grep bts |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
26 |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
27 echo % errors |
634b0e7561ec
test-interhg: test the extension
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
28 cat errors.log |