mercurial/urllibcompat.py
changeset 43506 9f70512ae2cf
parent 43089 c59eb1560c44
child 45942 89a2afe31e82
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)