[PATCH 1 of 1] tests: asciify output of tsttest
mads at kiilerich.com
Sun Sep 19 09:49:08 CDT 2010
Yuya Nishihara wrote, On 09/19/2010 04:30 PM:
> Martin Geisler wrote:
>> Yuya Nishihara <yuya at tcha.org> writes:
>>> It'll be simple if we can just write s.encode('string-escape') or
>>> repr(s)[1:-1] without re.sub(), but it's necessary to avoid unwanted
>>> escapes like \t, \n, \'.
>> I think the simplest way is to use
>> s.encode('string-escape').replace(r'\'', '\'').replace(r'\n', '\n')
> It breaks edge case:
> In : r'\n'
> Out: '\\n'
> In : r'\n'.encode('string-escape').replace('\\\\', '\\').replace(r'\n', '\n')
> Out: '\n'
> unescape needs to be done at once.
Yes, unescape generally has to be done at once. But we don't want to
unescape backslash. We just want to unescape "'", so I agree with Martin
that it will work in _this_ case.
IIRC unescaping of \n isn't necessary.
I'm a bit in doubt if we should unescape \t too. Having \t in the output
makes it less readable, but it also makes it obvious what the output
More information about the Mercurial-devel