Show More
@@ -0,0 +1,10 b'' | |||
|
1 | #!/usr/bin/env python | |
|
2 | # | |
|
3 | ||
|
4 | import doctest | |
|
5 | ||
|
6 | import mercurial.changelog | |
|
7 | # test doctest from changelog | |
|
8 | ||
|
9 | doctest.testmod(mercurial.changelog) | |
|
10 |
@@ -10,6 +10,23 b' from i18n import gettext as _' | |||
|
10 | 10 | from demandload import demandload |
|
11 | 11 | demandload(globals(), "os time util") |
|
12 | 12 | |
|
13 | def _string_escape(text): | |
|
14 | """ | |
|
15 | >>> d = {'nl': chr(10), 'bs': chr(92), 'cr': chr(13), 'nul': chr(0)} | |
|
16 | >>> s = "ab%(nl)scd%(bs)s%(bs)sn%(nul)sab%(cr)scd%(bs)s%(nl)s" % d | |
|
17 | >>> s | |
|
18 | 'ab\\ncd\\\\\\\\n\\x00ab\\rcd\\\\\\n' | |
|
19 | >>> res = _string_escape(s) | |
|
20 | >>> s == _string_unescape(res) | |
|
21 | True | |
|
22 | """ | |
|
23 | # subset of the string_escape codec | |
|
24 | text = text.replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r') | |
|
25 | return text.replace('\0', '\\0') | |
|
26 | ||
|
27 | def _string_unescape(text): | |
|
28 | return text.decode('string_escape') | |
|
29 | ||
|
13 | 30 | class changelog(revlog): |
|
14 | 31 | def __init__(self, opener, defversion=REVLOGV0): |
|
15 | 32 | revlog.__init__(self, opener, "00changelog.i", "00changelog.d", |
General Comments 0
You need to be logged in to leave comments.
Login now