Mercurial > public > mercurial-scm > hg
comparison mercurial/url.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 | d783f945a701 |
children | 9d2b2df2c2ba |
comparison
equal
deleted
inserted
replaced
43505:47fac1692ede | 43506:9f70512ae2cf |
---|---|
145 self.no_list = no_list | 145 self.no_list = no_list |
146 | 146 |
147 # Keys and values need to be str because the standard library | 147 # Keys and values need to be str because the standard library |
148 # expects them to be. | 148 # expects them to be. |
149 proxyurl = str(proxy) | 149 proxyurl = str(proxy) |
150 proxies = {r'http': proxyurl, r'https': proxyurl} | 150 proxies = {'http': proxyurl, 'https': proxyurl} |
151 ui.debug(b'proxying through %s\n' % util.hidepassword(bytes(proxy))) | 151 ui.debug(b'proxying through %s\n' % util.hidepassword(bytes(proxy))) |
152 else: | 152 else: |
153 proxies = {} | 153 proxies = {} |
154 | 154 |
155 urlreq.proxyhandler.__init__(self, proxies) | 155 urlreq.proxyhandler.__init__(self, proxies) |
202 # Large parts of this function have their origin from before Python 2.6 | 202 # Large parts of this function have their origin from before Python 2.6 |
203 # and could potentially be removed. | 203 # and could potentially be removed. |
204 def _generic_start_transaction(handler, h, req): | 204 def _generic_start_transaction(handler, h, req): |
205 tunnel_host = req._tunnel_host | 205 tunnel_host = req._tunnel_host |
206 if tunnel_host: | 206 if tunnel_host: |
207 if tunnel_host[:7] not in [r'http://', r'https:/']: | 207 if tunnel_host[:7] not in ['http://', 'https:/']: |
208 tunnel_host = r'https://' + tunnel_host | 208 tunnel_host = 'https://' + tunnel_host |
209 new_tunnel = True | 209 new_tunnel = True |
210 else: | 210 else: |
211 tunnel_host = urllibcompat.getselector(req) | 211 tunnel_host = urllibcompat.getselector(req) |
212 new_tunnel = False | 212 new_tunnel = False |
213 | 213 |
226 def _generic_proxytunnel(self): | 226 def _generic_proxytunnel(self): |
227 proxyheaders = dict( | 227 proxyheaders = dict( |
228 [ | 228 [ |
229 (x, self.headers[x]) | 229 (x, self.headers[x]) |
230 for x in self.headers | 230 for x in self.headers |
231 if x.lower().startswith(r'proxy-') | 231 if x.lower().startswith('proxy-') |
232 ] | 232 ] |
233 ) | 233 ) |
234 self.send(b'CONNECT %s HTTP/1.0\r\n' % self.realhostport) | 234 self.send(b'CONNECT %s HTTP/1.0\r\n' % self.realhostport) |
235 for header in pycompat.iteritems(proxyheaders): | 235 for header in pycompat.iteritems(proxyheaders): |
236 self.send(b'%s: %s\r\n' % header) | 236 self.send(b'%s: %s\r\n' % header) |
520 user, pw = self.passwd.find_user_password( | 520 user, pw = self.passwd.find_user_password( |
521 realm, urllibcompat.getfullurl(req) | 521 realm, urllibcompat.getfullurl(req) |
522 ) | 522 ) |
523 if pw is not None: | 523 if pw is not None: |
524 raw = b"%s:%s" % (pycompat.bytesurl(user), pycompat.bytesurl(pw)) | 524 raw = b"%s:%s" % (pycompat.bytesurl(user), pycompat.bytesurl(pw)) |
525 auth = r'Basic %s' % pycompat.strurl(base64.b64encode(raw).strip()) | 525 auth = 'Basic %s' % pycompat.strurl(base64.b64encode(raw).strip()) |
526 if req.get_header(self.auth_header, None) == auth: | 526 if req.get_header(self.auth_header, None) == auth: |
527 return None | 527 return None |
528 self.auth = auth | 528 self.auth = auth |
529 req.add_unredirected_header(self.auth_header, auth) | 529 req.add_unredirected_header(self.auth_header, auth) |
530 return self.parent.open(req) | 530 return self.parent.open(req) |
653 # | 653 # |
654 # The custom user agent is for lfs, because unfortunately some servers | 654 # The custom user agent is for lfs, because unfortunately some servers |
655 # do look at this value. | 655 # do look at this value. |
656 if not useragent: | 656 if not useragent: |
657 agent = b'mercurial/proto-1.0 (Mercurial %s)' % util.version() | 657 agent = b'mercurial/proto-1.0 (Mercurial %s)' % util.version() |
658 opener.addheaders = [(r'User-agent', pycompat.sysstr(agent))] | 658 opener.addheaders = [('User-agent', pycompat.sysstr(agent))] |
659 else: | 659 else: |
660 opener.addheaders = [(r'User-agent', pycompat.sysstr(useragent))] | 660 opener.addheaders = [('User-agent', pycompat.sysstr(useragent))] |
661 | 661 |
662 # This header should only be needed by wire protocol requests. But it has | 662 # This header should only be needed by wire protocol requests. But it has |
663 # been sent on all requests since forever. We keep sending it for backwards | 663 # been sent on all requests since forever. We keep sending it for backwards |
664 # compatibility reasons. Modern versions of the wire protocol use | 664 # compatibility reasons. Modern versions of the wire protocol use |
665 # X-HgProto-<N> for advertising client support. | 665 # X-HgProto-<N> for advertising client support. |
666 if sendaccept: | 666 if sendaccept: |
667 opener.addheaders.append((r'Accept', r'application/mercurial-0.1')) | 667 opener.addheaders.append(('Accept', 'application/mercurial-0.1')) |
668 | 668 |
669 return opener | 669 return opener |
670 | 670 |
671 | 671 |
672 def open(ui, url_, data=None, sendaccept=True): | 672 def open(ui, url_, data=None, sendaccept=True): |