[PATCH 1 of 1] tests: asciify output of tsttest

Yuya Nishihara yuya at tcha.org
Sun Sep 19 09:30:50 CDT 2010

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 [22]: r'\n'
Out[22]: '\\n'
In [25]: r'\n'.encode('string-escape').replace('\\\\', '\\').replace(r'\n', '\n')
Out[25]: '\n'

unescape needs to be done at once.


More information about the Mercurial-devel mailing list