Show More
@@ -342,7 +342,7 b' class savedcmd(object):' | |||||
342 | def __init__(self, path, cmdline): |
|
342 | def __init__(self, path, cmdline): | |
343 | # We can't pass non-ASCII through docstrings (and path is |
|
343 | # We can't pass non-ASCII through docstrings (and path is | |
344 | # in an unknown encoding anyway) |
|
344 | # in an unknown encoding anyway) | |
345 |
docpath = path |
|
345 | docpath = util.escapestr(path) | |
346 | self.__doc__ = self.__doc__ % {'path': util.uirepr(docpath)} |
|
346 | self.__doc__ = self.__doc__ % {'path': util.uirepr(docpath)} | |
347 | self._cmdline = cmdline |
|
347 | self._cmdline = cmdline | |
348 |
|
348 |
@@ -1300,7 +1300,7 b' class changeset_printer(object):' | |||||
1300 | for key, value in sorted(extra.items()): |
|
1300 | for key, value in sorted(extra.items()): | |
1301 | # i18n: column positioning for "hg log" |
|
1301 | # i18n: column positioning for "hg log" | |
1302 | self.ui.write(_("extra: %s=%s\n") |
|
1302 | self.ui.write(_("extra: %s=%s\n") | |
1303 |
% (key, value |
|
1303 | % (key, util.escapestr(value)), | |
1304 | label='ui.debug log.extra') |
|
1304 | label='ui.debug log.extra') | |
1305 |
|
1305 | |||
1306 | description = ctx.description().strip() |
|
1306 | description = ctx.description().strip() |
@@ -1514,8 +1514,8 b' def debugpushkey(ui, repopath, namespace' | |||||
1514 | return not r |
|
1514 | return not r | |
1515 | else: |
|
1515 | else: | |
1516 | for k, v in sorted(target.listkeys(namespace).iteritems()): |
|
1516 | for k, v in sorted(target.listkeys(namespace).iteritems()): | |
1517 |
ui.write("%s\t%s\n" % (k |
|
1517 | ui.write("%s\t%s\n" % (util.escapestr(k), | |
1518 |
v |
|
1518 | util.escapestr(v))) | |
1519 |
|
1519 | |||
1520 | @command('debugpvec', [], _('A B')) |
|
1520 | @command('debugpvec', [], _('A B')) | |
1521 | def debugpvec(ui, repo, a, b=None): |
|
1521 | def debugpvec(ui, repo, a, b=None): |
@@ -130,7 +130,7 b' def state(ctx, ui):' | |||||
130 | for pattern, repl in p.items('subpaths'): |
|
130 | for pattern, repl in p.items('subpaths'): | |
131 | # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub |
|
131 | # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub | |
132 | # does a string decode. |
|
132 | # does a string decode. | |
133 |
repl = repl |
|
133 | repl = util.escapestr(repl) | |
134 | # However, we still want to allow back references to go |
|
134 | # However, we still want to allow back references to go | |
135 | # through unharmed, so we turn r'\\1' into r'\1'. Again, |
|
135 | # through unharmed, so we turn r'\\1' into r'\1'. Again, | |
136 | # extra escapes are needed because re.sub string decodes. |
|
136 | # extra escapes are needed because re.sub string decodes. |
@@ -345,7 +345,7 b' def splitlines(text):' | |||||
345 |
|
345 | |||
346 | @templatefilter('stringescape') |
|
346 | @templatefilter('stringescape') | |
347 | def stringescape(text): |
|
347 | def stringescape(text): | |
348 | return text.encode('string_escape') |
|
348 | return util.escapestr(text) | |
349 |
|
349 | |||
350 | @templatefilter('stringify') |
|
350 | @templatefilter('stringify') | |
351 | def stringify(thing): |
|
351 | def stringify(thing): |
@@ -2130,6 +2130,9 b' bytecount = unitcountfn(' | |||||
2130 | (1, 1, _('%.0f bytes')), |
|
2130 | (1, 1, _('%.0f bytes')), | |
2131 | ) |
|
2131 | ) | |
2132 |
|
2132 | |||
|
2133 | def escapestr(s): | |||
|
2134 | return s.encode('string_escape') | |||
|
2135 | ||||
2133 | def uirepr(s): |
|
2136 | def uirepr(s): | |
2134 | # Avoid double backslash in Windows path repr() |
|
2137 | # Avoid double backslash in Windows path repr() | |
2135 | return repr(s).replace('\\\\', '\\') |
|
2138 | return repr(s).replace('\\\\', '\\') |
@@ -900,7 +900,7 b' def known(repo, proto, nodes, others):' | |||||
900 | def pushkey(repo, proto, namespace, key, old, new): |
|
900 | def pushkey(repo, proto, namespace, key, old, new): | |
901 | # compatibility with pre-1.8 clients which were accidentally |
|
901 | # compatibility with pre-1.8 clients which were accidentally | |
902 | # sending raw binary nodes rather than utf-8-encoded hex |
|
902 | # sending raw binary nodes rather than utf-8-encoded hex | |
903 |
if len(new) == 20 and new |
|
903 | if len(new) == 20 and util.escapestr(new) != new: | |
904 | # looks like it could be a binary node |
|
904 | # looks like it could be a binary node | |
905 | try: |
|
905 | try: | |
906 | new.decode('utf-8') |
|
906 | new.decode('utf-8') |
General Comments 0
You need to be logged in to leave comments.
Login now