equal
deleted
inserted
replaced
30 >>> d = {'nl': chr(10), 'bs': chr(92), 'cr': chr(13), 'nul': chr(0)} |
30 >>> d = {'nl': chr(10), 'bs': chr(92), 'cr': chr(13), 'nul': chr(0)} |
31 >>> s = "ab%(nl)scd%(bs)s%(bs)sn%(nul)sab%(cr)scd%(bs)s%(nl)s" % d |
31 >>> s = "ab%(nl)scd%(bs)s%(bs)sn%(nul)sab%(cr)scd%(bs)s%(nl)s" % d |
32 >>> s |
32 >>> s |
33 'ab\\ncd\\\\\\\\n\\x00ab\\rcd\\\\\\n' |
33 'ab\\ncd\\\\\\\\n\\x00ab\\rcd\\\\\\n' |
34 >>> res = _string_escape(s) |
34 >>> res = _string_escape(s) |
35 >>> s == res.decode('string_escape') |
35 >>> s == util.unescapestr(res) |
36 True |
36 True |
37 """ |
37 """ |
38 # subset of the string_escape codec |
38 # subset of the string_escape codec |
39 text = text.replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r') |
39 text = text.replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r') |
40 return text.replace('\0', '\\0') |
40 return text.replace('\0', '\\0') |
55 if '\\0' in l: |
55 if '\\0' in l: |
56 # fix up \0 without getting into trouble with \\0 |
56 # fix up \0 without getting into trouble with \\0 |
57 l = l.replace('\\\\', '\\\\\n') |
57 l = l.replace('\\\\', '\\\\\n') |
58 l = l.replace('\\0', '\0') |
58 l = l.replace('\\0', '\0') |
59 l = l.replace('\n', '') |
59 l = l.replace('\n', '') |
60 k, v = l.decode('string_escape').split(':', 1) |
60 k, v = util.unescapestr(l).split(':', 1) |
61 extra[k] = v |
61 extra[k] = v |
62 return extra |
62 return extra |
63 |
63 |
64 def encodeextra(d): |
64 def encodeextra(d): |
65 # keys must be sorted to produce a deterministic changelog entry |
65 # keys must be sorted to produce a deterministic changelog entry |