comparison mercurial/keepalive.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 8ff1ecfadcd1
children 49f8ba4febec
comparison
equal deleted inserted replaced
43505:47fac1692ede 43506:9f70512ae2cf
329 headers = util.sortdict(self.parent.addheaders) 329 headers = util.sortdict(self.parent.addheaders)
330 headers.update(sorted(req.headers.items())) 330 headers.update(sorted(req.headers.items()))
331 headers.update(sorted(req.unredirected_hdrs.items())) 331 headers.update(sorted(req.unredirected_hdrs.items()))
332 headers = util.sortdict((n.lower(), v) for n, v in headers.items()) 332 headers = util.sortdict((n.lower(), v) for n, v in headers.items())
333 skipheaders = {} 333 skipheaders = {}
334 for n in (r'host', r'accept-encoding'): 334 for n in ('host', 'accept-encoding'):
335 if n in headers: 335 if n in headers:
336 skipheaders[r'skip_' + n.replace(r'-', r'_')] = 1 336 skipheaders['skip_' + n.replace('-', '_')] = 1
337 try: 337 try:
338 if urllibcompat.hasdata(req): 338 if urllibcompat.hasdata(req):
339 data = urllibcompat.getdata(req) 339 data = urllibcompat.getdata(req)
340 h.putrequest( 340 h.putrequest(
341 req.get_method(), 341 req.get_method(),
342 urllibcompat.getselector(req), 342 urllibcompat.getselector(req),
343 **skipheaders 343 **skipheaders
344 ) 344 )
345 if r'content-type' not in headers: 345 if 'content-type' not in headers:
346 h.putheader( 346 h.putheader(
347 r'Content-type', r'application/x-www-form-urlencoded' 347 'Content-type', 'application/x-www-form-urlencoded'
348 ) 348 )
349 if r'content-length' not in headers: 349 if 'content-length' not in headers:
350 h.putheader(r'Content-length', r'%d' % len(data)) 350 h.putheader('Content-length', '%d' % len(data))
351 else: 351 else:
352 h.putrequest( 352 h.putrequest(
353 req.get_method(), 353 req.get_method(),
354 urllibcompat.getselector(req), 354 urllibcompat.getselector(req),
355 **skipheaders 355 **skipheaders
399 # modification from socket.py 399 # modification from socket.py
400 400
401 def __init__(self, sock, debuglevel=0, strict=0, method=None): 401 def __init__(self, sock, debuglevel=0, strict=0, method=None):
402 extrakw = {} 402 extrakw = {}
403 if not pycompat.ispy3: 403 if not pycompat.ispy3:
404 extrakw[r'strict'] = True 404 extrakw['strict'] = True
405 extrakw[r'buffering'] = True 405 extrakw['buffering'] = True
406 httplib.HTTPResponse.__init__( 406 httplib.HTTPResponse.__init__(
407 self, sock, debuglevel=debuglevel, method=method, **extrakw 407 self, sock, debuglevel=debuglevel, method=method, **extrakw
408 ) 408 )
409 self.fileno = sock.fileno 409 self.fileno = sock.fileno
410 self.code = None 410 self.code = None