Mercurial > public > mercurial-scm > hg-stable
diff mercurial/patch.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 | d649de29f1ff |
line wrap: on
line diff
--- a/mercurial/patch.py Sun Nov 10 07:30:14 2019 -0800 +++ b/mercurial/patch.py Fri Nov 08 11:19:20 2019 -0800 @@ -217,7 +217,7 @@ fileobj did not contain a patch. Caller must unlink filename when done.''' fd, tmpname = pycompat.mkstemp(prefix=b'hg-patch-') - tmpfp = os.fdopen(fd, r'wb') + tmpfp = os.fdopen(fd, 'wb') try: yield _extract(ui, fileobj, tmpname, tmpfp) finally: @@ -241,8 +241,8 @@ msg = mail.parse(fileobj) - subject = msg[r'Subject'] and mail.headdecode(msg[r'Subject']) - data[b'user'] = msg[r'From'] and mail.headdecode(msg[r'From']) + subject = msg['Subject'] and mail.headdecode(msg['Subject']) + data[b'user'] = msg['From'] and mail.headdecode(msg['From']) if not subject and not data[b'user']: # Not an email, restore parsed headers if any subject = ( @@ -255,7 +255,7 @@ # should try to parse msg['Date'] parents = [] - nodeid = msg[r'X-Mercurial-Node'] + nodeid = msg['X-Mercurial-Node'] if nodeid: data[b'nodeid'] = nodeid = mail.headdecode(nodeid) ui.debug(b'Node ID: %s\n' % nodeid) @@ -1225,7 +1225,7 @@ ncpatchfp = None try: # Write the initial patch - f = util.nativeeolwriter(os.fdopen(patchfd, r'wb')) + f = util.nativeeolwriter(os.fdopen(patchfd, 'wb')) chunk.header.write(f) chunk.write(f) f.write( @@ -1245,7 +1245,7 @@ ui.warn(_(b"editor exited with exit code %d\n") % ret) continue # Remove comment lines - patchfp = open(patchfn, r'rb') + patchfp = open(patchfn, 'rb') ncpatchfp = stringio() for line in util.iterfile(patchfp): line = util.fromnativeeol(line) @@ -2788,7 +2788,7 @@ def difflabel(func, *args, **kw): '''yields 2-tuples of (output, label) based on the output of func()''' - if kw.get(r'opts') and kw[r'opts'].worddiff: + if kw.get('opts') and kw['opts'].worddiff: dodiffhunk = diffsinglehunkinline else: dodiffhunk = diffsinglehunk