comparison mercurial/urllibcompat.py @ 43506:9f70512ae2cf

cleanup: remove pointless r-prefixes on single-quoted strings This is the promised second step on single-quoted strings. These had existed because our source transformer didn't turn r'' into b'', so we had tagged some strings as r-strings to get "native" strings on both Pythons. Now that the transformer is gone, we can dispense with this nonsense. Methodology: I ran hg locate 'set:added() or modified() or clean()' | egrep '.*\.py$' | xargs egrep --color=never -n -- \[\^b\]\[\^a-z\]r\'\[\^\'\\\\\]\*\'\[\^\'\ in an emacs grep-mode buffer, and then used a keyboard macro to iterate over the results and remove the r prefix as needed. # skip-blame removing unneeded r prefixes left over from Python 3 migration. Differential Revision: https://phab.mercurial-scm.org/D7306
author Augie Fackler <augie@google.com>
date Fri, 08 Nov 2019 11:19:20 -0800
parents c59eb1560c44
children 89a2afe31e82
comparison
equal deleted inserted replaced
43505:47fac1692ede 43506:9f70512ae2cf
18 18
19 def _registeraliases(self, origin, items): 19 def _registeraliases(self, origin, items):
20 """Add items that will be populated at the first access""" 20 """Add items that will be populated at the first access"""
21 items = map(_sysstr, items) 21 items = map(_sysstr, items)
22 self._aliases.update( 22 self._aliases.update(
23 (item.replace(r'_', r'').lower(), (origin, item)) for item in items 23 (item.replace('_', '').lower(), (origin, item)) for item in items
24 ) 24 )
25 25
26 def _registeralias(self, origin, attr, name): 26 def _registeralias(self, origin, attr, name):
27 """Alias ``origin``.``attr`` as ``name``""" 27 """Alias ``origin``.``attr`` as ``name``"""
28 self._aliases[_sysstr(name)] = (origin, _sysstr(attr)) 28 self._aliases[_sysstr(name)] = (origin, _sysstr(attr))
100 ) 100 )
101 101
102 # urllib.parse.quote() accepts both str and bytes, decodes bytes 102 # urllib.parse.quote() accepts both str and bytes, decodes bytes
103 # (if necessary), and returns str. This is wonky. We provide a custom 103 # (if necessary), and returns str. This is wonky. We provide a custom
104 # implementation that only accepts bytes and emits bytes. 104 # implementation that only accepts bytes and emits bytes.
105 def quote(s, safe=r'/'): 105 def quote(s, safe='/'):
106 # bytestr has an __iter__ that emits characters. quote_from_bytes() 106 # bytestr has an __iter__ that emits characters. quote_from_bytes()
107 # does an iteration and expects ints. We coerce to bytes to appease it. 107 # does an iteration and expects ints. We coerce to bytes to appease it.
108 if isinstance(s, pycompat.bytestr): 108 if isinstance(s, pycompat.bytestr):
109 s = bytes(s) 109 s = bytes(s)
110 s = urllib.parse.quote_from_bytes(s, safe=safe) 110 s = urllib.parse.quote_from_bytes(s, safe=safe)