Mercurial > public > mercurial-scm > hg-stable
diff mercurial/httppeer.py @ 43554: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 | 313e3a279828 |
children | 89a2afe31e82 |
line wrap: on
line diff
--- a/mercurial/httppeer.py Sun Nov 10 07:30:14 2019 -0800 +++ b/mercurial/httppeer.py Fri Nov 08 11:19:20 2019 -0800 @@ -63,7 +63,7 @@ # and using an r-string to make it portable between Python 2 and 3 # doesn't work because then the \r is a literal backslash-r # instead of a carriage return. - valuelen = limit - len(fmt % r'000') - len(b': \r\n') + valuelen = limit - len(fmt % '000') - len(b': \r\n') result = [] n = 0 @@ -158,7 +158,7 @@ argsio = io.BytesIO(strargs) argsio.length = len(strargs) data = _multifile(argsio, data) - headers[r'X-HgArgs-Post'] = len(strargs) + headers['X-HgArgs-Post'] = len(strargs) elif args: # Calling self.capable() can infinite loop if we are calling # "capabilities". But that command should never accept wire @@ -187,8 +187,8 @@ size = data.length elif data is not None: size = len(data) - if data is not None and r'Content-Type' not in headers: - headers[r'Content-Type'] = r'application/mercurial-0.1' + if data is not None and 'Content-Type' not in headers: + headers['Content-Type'] = 'application/mercurial-0.1' # Tell the server we accept application/mercurial-0.2 and multiple # compression formats if the server is capable of emitting those @@ -228,17 +228,17 @@ varyheaders = [] for header in headers: - if header.lower().startswith(r'x-hg'): + if header.lower().startswith('x-hg'): varyheaders.append(header) if varyheaders: - headers[r'Vary'] = r','.join(sorted(varyheaders)) + headers['Vary'] = ','.join(sorted(varyheaders)) req = requestbuilder(pycompat.strurl(cu), data, headers) if data is not None: ui.debug(b"sending %d bytes\n" % size) - req.add_unredirected_header(r'Content-Length', r'%d' % size) + req.add_unredirected_header('Content-Length', '%d' % size) return req, cu, qs @@ -348,9 +348,9 @@ ui.warn(_(b'real URL is %s\n') % respurl) try: - proto = pycompat.bytesurl(resp.getheader(r'content-type', r'')) + proto = pycompat.bytesurl(resp.getheader('content-type', '')) except AttributeError: - proto = pycompat.bytesurl(resp.headers.get(r'content-type', r'')) + proto = pycompat.bytesurl(resp.headers.get('content-type', '')) safeurl = util.hidepassword(baseurl) if proto.startswith(b'application/hg-error'): @@ -517,7 +517,7 @@ tempname = bundle2.writebundle(self.ui, cg, None, type) fp = httpconnection.httpsendfile(self.ui, tempname, b"rb") - headers = {r'Content-Type': r'application/mercurial-0.1'} + headers = {'Content-Type': 'application/mercurial-0.1'} try: r = self._call(cmd, data=fp, headers=headers, **args) @@ -550,7 +550,7 @@ d = fp.read(4096) # start http push with httpconnection.httpsendfile(self.ui, filename, b"rb") as fp_: - headers = {r'Content-Type': r'application/mercurial-0.1'} + headers = {'Content-Type': 'application/mercurial-0.1'} return self._callstream(cmd, data=fp_, headers=headers, **args) finally: if filename is not None: @@ -621,12 +621,12 @@ # TODO modify user-agent to reflect v2 headers = { - r'Accept': wireprotov2server.FRAMINGTYPE, - r'Content-Type': wireprotov2server.FRAMINGTYPE, + 'Accept': wireprotov2server.FRAMINGTYPE, + 'Content-Type': wireprotov2server.FRAMINGTYPE, } req = requestbuilder(pycompat.strurl(url), body, headers) - req.add_unredirected_header(r'Content-Length', r'%d' % len(body)) + req.add_unredirected_header('Content-Length', '%d' % len(body)) try: res = opener.open(req) @@ -965,7 +965,7 @@ if advertisev2: args[b'headers'] = { - r'X-HgProto-1': r'cbor', + 'X-HgProto-1': 'cbor', } args[b'headers'].update(