Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/parser.py @ 37087:f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
This might conflict with other patches floating around, sorry.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 22 Mar 2018 21:56:20 +0900 |
parents | 7840d8bd0558 |
children | 0a2ce5b43574 |
comparison
equal
deleted
inserted
replaced
37086:f99d64e8a4e4 | 37087:f0b6fbea00cf |
---|---|
22 from . import ( | 22 from . import ( |
23 encoding, | 23 encoding, |
24 error, | 24 error, |
25 pycompat, | 25 pycompat, |
26 util, | 26 util, |
27 ) | |
28 from .utils import ( | |
29 stringutil, | |
27 ) | 30 ) |
28 | 31 |
29 class parser(object): | 32 class parser(object): |
30 def __init__(self, elements, methods=None): | 33 def __init__(self, elements, methods=None): |
31 self._elements = elements | 34 self._elements = elements |
188 d[k] = x[2] | 191 d[k] = x[2] |
189 return args | 192 return args |
190 | 193 |
191 def unescapestr(s): | 194 def unescapestr(s): |
192 try: | 195 try: |
193 return util.unescapestr(s) | 196 return stringutil.unescapestr(s) |
194 except ValueError as e: | 197 except ValueError as e: |
195 # mangle Python's exception into our format | 198 # mangle Python's exception into our format |
196 raise error.ParseError(pycompat.bytestr(e).lower()) | 199 raise error.ParseError(pycompat.bytestr(e).lower()) |
197 | 200 |
198 def _brepr(obj): | 201 def _brepr(obj): |
199 if isinstance(obj, bytes): | 202 if isinstance(obj, bytes): |
200 return b"'%s'" % util.escapestr(obj) | 203 return b"'%s'" % stringutil.escapestr(obj) |
201 return encoding.strtolocal(repr(obj)) | 204 return encoding.strtolocal(repr(obj)) |
202 | 205 |
203 def _prettyformat(tree, leafnodes, level, lines): | 206 def _prettyformat(tree, leafnodes, level, lines): |
204 if not isinstance(tree, tuple): | 207 if not isinstance(tree, tuple): |
205 lines.append((level, _brepr(tree))) | 208 lines.append((level, _brepr(tree))) |