Mercurial > public > mercurial-scm > hg
comparison mercurial/sshpeer.py @ 38475:67dc32d4e790
cleanup: migrate from re.escape to stringutil.reescape
This has consistent behavior on Python 2.7, 3.6, and 3.7 and has the
benefit of probably being a little faster. Test output changes are
largely because / used to be pointlessly escaped.
Differential Revision: https://phab.mercurial-scm.org/D3842
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 26 Jun 2018 10:36:23 -0400 |
parents | 58bbd14b0c62 |
children | 27391d74aaa2 |
comparison
equal
deleted
inserted
replaced
38474:96f65bdf0bf4 | 38475:67dc32d4e790 |
---|---|
20 wireprotov1peer, | 20 wireprotov1peer, |
21 wireprotov1server, | 21 wireprotov1server, |
22 ) | 22 ) |
23 from .utils import ( | 23 from .utils import ( |
24 procutil, | 24 procutil, |
25 stringutil, | |
25 ) | 26 ) |
26 | 27 |
27 def _serverquote(s): | 28 def _serverquote(s): |
28 """quote a string for the remote shell ... which we assume is sh""" | 29 """quote a string for the remote shell ... which we assume is sh""" |
29 if not s: | 30 if not s: |
271 except IOError: | 272 except IOError: |
272 badresponse() | 273 badresponse() |
273 | 274 |
274 # Assume version 1 of wire protocol by default. | 275 # Assume version 1 of wire protocol by default. |
275 protoname = wireprototypes.SSHV1 | 276 protoname = wireprototypes.SSHV1 |
276 reupgraded = re.compile(b'^upgraded %s (.*)$' % re.escape(token)) | 277 reupgraded = re.compile(b'^upgraded %s (.*)$' % stringutil.reescape(token)) |
277 | 278 |
278 lines = ['', 'dummy'] | 279 lines = ['', 'dummy'] |
279 max_noise = 500 | 280 max_noise = 500 |
280 while lines[-1] and max_noise: | 281 while lines[-1] and max_noise: |
281 try: | 282 try: |