Commit 7e9c8521 authored by Augie Fackler's avatar Augie Fackler
Browse files

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
parent 47fac1692ede
......@@ -39,7 +39,7 @@ def connectpipe(path=None, extraargs=()):
cmdline.extend(extraargs)
def tonative(cmdline):
if os.name != r'nt':
if os.name != 'nt':
return cmdline
return [arg.decode("utf-8") for arg in cmdline]
......
......@@ -726,8 +726,8 @@ def clearfilecache(obj, attrname):
def clearchangelog(repo):
if repo is not repo.unfiltered():
object.__setattr__(repo, r'_clcachekey', None)
object.__setattr__(repo, r'_clcache', None)
object.__setattr__(repo, '_clcachekey', None)
object.__setattr__(repo, '_clcache', None)
clearfilecache(repo.unfiltered(), 'changelog')
......@@ -1652,12 +1652,12 @@ def perfstartup(ui, repo, **opts):
timer, fm = gettimer(ui, opts)
def d():
if os.name != r'nt':
if os.name != 'nt':
os.system(
b"HGRCPATH= %s version -q > /dev/null" % fsencode(sys.argv[0])
)
else:
os.environ[r'HGRCPATH'] = r' '
os.environ['HGRCPATH'] = r' '
os.system("%s version -q > NUL" % sys.argv[0])
timer(d)
......@@ -1844,7 +1844,7 @@ def perftemplating(ui, repo, testedtemplate=None, **opts):
opts = _byteskwargs(opts)
nullui = ui.copy()
nullui.fout = open(os.devnull, r'wb')
nullui.fout = open(os.devnull, 'wb')
nullui.disablepager()
revs = opts.get(b'rev')
if not revs:
......
......@@ -60,7 +60,7 @@ def main(argv=()):
)
p.add_argument(
'-j',
default=os.sysconf(r'SC_NPROCESSORS_ONLN'),
default=os.sysconf('SC_NPROCESSORS_ONLN'),
type=int,
help='Number of parallel tests to run.',
)
......
......@@ -20,7 +20,7 @@ except ImportError:
# This script is executed during installs and may not have C extensions
# available. Relax C module requirements.
os.environ[r'HGMODULEPOLICY'] = r'allow'
os.environ['HGMODULEPOLICY'] = 'allow'
# import from the live mercurial repo
sys.path.insert(0, "..")
from mercurial import demandimport
......
......@@ -135,8 +135,8 @@ class _demandmod(object):
if locals:
if locals.get(head) is self:
locals[head] = mod
elif locals.get(head + r'mod') is self:
locals[head + r'mod'] = mod
elif locals.get(head + 'mod') is self:
locals[head + 'mod'] = mod
for modname in modrefs:
modref = sys.modules.get(modname, None)
......
......@@ -369,8 +369,8 @@ def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
return
user = None
if source == b'serve' and r'url' in kwargs:
url = kwargs[r'url'].split(b':')
if source == b'serve' and 'url' in kwargs:
url = kwargs['url'].split(b':')
if url[0] == b'remote' and url[1].startswith(b'http'):
user = urlreq.unquote(url[3])
......@@ -386,9 +386,9 @@ def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
def _pkhook(ui, repo, hooktype, node, source, user, **kwargs):
if kwargs[r'namespace'] == b'bookmarks':
bookmark = kwargs[r'key']
ctx = kwargs[r'new']
if kwargs['namespace'] == b'bookmarks':
bookmark = kwargs['key']
ctx = kwargs['new']
allowbookmarks = buildmatch(ui, None, user, b'acl.allow.bookmarks')
denybookmarks = buildmatch(ui, None, user, b'acl.deny.bookmarks')
......
......@@ -94,7 +94,7 @@ def extsetup(ui):
ui.warn(_(b'beautifygraph: unsupported encoding, UTF-8 required\n'))
return
if r'A' in encoding._wide:
if 'A' in encoding._wide:
ui.warn(
_(
b'beautifygraph: unsupported terminal settings, '
......
......@@ -201,7 +201,7 @@ def blackbox(ui, repo, *revs, **opts):
if not repo.vfs.exists(b'blackbox.log'):
return
limit = opts.get(r'limit')
limit = opts.get('limit')
fp = repo.vfs(b'blackbox.log', b'r')
lines = fp.read().split(b'\n')
......
......@@ -101,7 +101,7 @@ def commands_pull(orig, ui, repo, *args, **opts):
def commands_branch(orig, ui, repo, label=None, **opts):
if label and not opts.get(r'clean') and not opts.get(r'rev'):
if label and not opts.get('clean') and not opts.get('rev'):
raise error.Abort(
_(
b"creating named branches is disabled and you should use bookmarks"
......
......@@ -612,7 +612,7 @@ class bzmysql(bzaccess):
self.ui.warn(_(b"Bugzilla/MySQL cannot update bug state\n"))
(user, userid) = self.get_bugzilla_user(committer)
now = time.strftime(r'%Y-%m-%d %H:%M:%S')
now = time.strftime('%Y-%m-%d %H:%M:%S')
self.run(
'''insert into longdescs
(bug_id, who, bug_when, thetext)
......
......@@ -197,7 +197,7 @@ def churn(ui, repo, *pats, **opts):
return s + b" " * (l - encoding.colwidth(s))
amap = {}
aliases = opts.get(r'aliases')
aliases = opts.get('aliases')
if not aliases and os.path.exists(repo.wjoin(b'.hgchurn')):
aliases = repo.wjoin(b'.hgchurn')
if aliases:
......@@ -215,7 +215,7 @@ def churn(ui, repo, *pats, **opts):
if not rate:
return
if opts.get(r'sort'):
if opts.get('sort'):
rate.sort()
else:
rate.sort(key=lambda x: (-sum(x[1]), x))
......@@ -228,7 +228,7 @@ def churn(ui, repo, *pats, **opts):
ui.debug(b"assuming %i character terminal\n" % ttywidth)
width = ttywidth - maxname - 2 - 2 - 2
if opts.get(r'diffstat'):
if opts.get('diffstat'):
width -= 15
def format(name, diffstat):
......
......@@ -58,7 +58,7 @@ def _commit(orig, ui, repo, *pats, **opts):
class repoextra(repo.__class__):
def commit(self, *innerpats, **inneropts):
extras = opts.get(r'extra')
extras = opts.get('extra')
for raw in extras:
if b'=' not in raw:
msg = _(
......@@ -82,7 +82,7 @@ def _commit(orig, ui, repo, *pats, **opts):
b"manually"
)
raise error.Abort(msg % k)
inneropts[r'extra'][k] = v
inneropts['extra'][k] = v
return super(repoextra, self).commit(*innerpats, **inneropts)
repo.__class__ = repoextra
......
......@@ -57,7 +57,7 @@ class _shlexpy3proxy(object):
def shlexer(data=None, filepath=None, wordchars=None, whitespace=None):
if data is None:
if pycompat.ispy3:
data = open(filepath, b'r', encoding=r'latin1')
data = open(filepath, b'r', encoding='latin1')
else:
data = open(filepath, b'r')
else:
......
......@@ -302,25 +302,25 @@ class gnuarch_source(common.converter_source, common.commandline):
# Commit date
self.changes[rev].date = dateutil.datestr(
dateutil.strdate(catlog[r'Standard-date'], b'%Y-%m-%d %H:%M:%S')
dateutil.strdate(catlog['Standard-date'], b'%Y-%m-%d %H:%M:%S')
)
# Commit author
self.changes[rev].author = self.recode(catlog[r'Creator'])
self.changes[rev].author = self.recode(catlog['Creator'])
# Commit description
self.changes[rev].summary = b'\n\n'.join(
(
self.recode(catlog[r'Summary']),
self.recode(catlog['Summary']),
self.recode(catlog.get_payload()),
)
)
self.changes[rev].summary = self.recode(self.changes[rev].summary)
# Commit revision origin when dealing with a branch or tag
if r'Continuation-of' in catlog:
if 'Continuation-of' in catlog:
self.changes[rev].continuationof = self.recode(
catlog[r'Continuation-of']
catlog['Continuation-of']
)
except Exception:
raise error.Abort(_(b'could not parse cat-log of %s') % rev)
......
......@@ -96,7 +96,7 @@ class monotone_source(common.converter_source, common.commandline):
return self.mtnrunsingle(*args, **kwargs)
def mtnrunsingle(self, *args, **kwargs):
kwargs[r'd'] = self.path
kwargs['d'] = self.path
return self.run0(b'automate', *args, **kwargs)
def mtnrunstdio(self, *args, **kwargs):
......
......@@ -1359,11 +1359,11 @@ class svn_sink(converter_sink, commandline):
m = set()
output = self.run0(b'ls', recursive=True, xml=True)
doc = xml.dom.minidom.parseString(output)
for e in doc.getElementsByTagName(r'entry'):
for e in doc.getElementsByTagName('entry'):
for n in e.childNodes:
if n.nodeType != n.ELEMENT_NODE or n.tagName != r'name':
if n.nodeType != n.ELEMENT_NODE or n.tagName != 'name':
continue
name = r''.join(
name = ''.join(
c.data for c in n.childNodes if c.nodeType == c.TEXT_NODE
)
# Entries are compared with names coming from
......@@ -1502,7 +1502,7 @@ class svn_sink(converter_sink, commandline):
self.setexec = []
fd, messagefile = pycompat.mkstemp(prefix=b'hg-convert-')
fp = os.fdopen(fd, r'wb')
fp = os.fdopen(fd, 'wb')
fp.write(util.tonativeeol(commit.desc))
fp.close()
try:
......
......@@ -655,7 +655,7 @@ class savedcmd(object):
# in an unknown encoding anyway), but avoid double separators on
# Windows
docpath = stringutil.escapestr(path).replace(b'\\\\', b'\\')
self.__doc__ %= {r'path': pycompat.sysstr(stringutil.uirepr(docpath))}
self.__doc__ %= {'path': pycompat.sysstr(stringutil.uirepr(docpath))}
self._cmdline = cmdline
self._isgui = isgui
......
......@@ -82,7 +82,7 @@ def _matchpaths(repo, rev, pats, opts, aopts=facontext.defaultopts):
fastannotatecommandargs = {
r'options': [
'options': [
(b'r', b'rev', b'.', _(b'annotate the specified revision'), _(b'REV')),
(b'u', b'user', None, _(b'list the author (long with -v)')),
(b'f', b'file', None, _(b'list the filename')),
......@@ -133,8 +133,8 @@ fastannotatecommandargs = {
+ commands.diffwsopts
+ commands.walkopts
+ commands.formatteropts,
r'synopsis': _(b'[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
r'inferrepo': True,
'synopsis': _(b'[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
'inferrepo': True,
}
......@@ -257,7 +257,7 @@ def fastannotate(ui, repo, *pats, **opts):
_newopts = set()
_knownopts = {
opt[1].replace(b'-', b'_')
for opt in (fastannotatecommandargs[r'options'] + commands.globalopts)
for opt in (fastannotatecommandargs['options'] + commands.globalopts)
}
......@@ -269,10 +269,10 @@ def _annotatewrapper(orig, ui, repo, *pats, **opts):
# treat the file as text (skip the isbinary check)
if ui.configbool(b'fastannotate', b'forcetext'):
opts[r'text'] = True
opts['text'] = True
# check if we need to do prefetch (client-side)
rev = opts.get(r'rev')
rev = opts.get('rev')
if util.safehasattr(repo, 'prefetchfastannotate') and rev is not None:
paths = list(_matchpaths(repo, rev, pats, pycompat.byteskwargs(opts)))
repo.prefetchfastannotate(paths)
......
......@@ -92,9 +92,9 @@ def parseoptions(ui, cmdoptions, args):
except getopt.GetoptError as ex:
if "requires argument" in ex.msg:
raise
if (r'--' + ex.opt) in ex.msg:
if ('--' + ex.opt) in ex.msg:
flag = b'--' + pycompat.bytestr(ex.opt)
elif (r'-' + ex.opt) in ex.msg:
elif ('-' + ex.opt) in ex.msg:
flag = b'-' + pycompat.bytestr(ex.opt)
else:
raise error.Abort(
......
......@@ -69,11 +69,11 @@ class gpg(object):
try:
# create temporary files
fd, sigfile = pycompat.mkstemp(prefix=b"hg-gpg-", suffix=b".sig")
fp = os.fdopen(fd, r'wb')
fp = os.fdopen(fd, 'wb')
fp.write(sig)
fp.close()
fd, datafile = pycompat.mkstemp(prefix=b"hg-gpg-", suffix=b".txt")
fp = os.fdopen(fd, r'wb')
fp = os.fdopen(fd, 'wb')
fp.write(data)
fp.close()
gpgcmd = (
......@@ -121,7 +121,7 @@ class gpg(object):
def newgpg(ui, **opts):
"""create a new gpg instance"""
gpgpath = ui.config(b"gpg", b"cmd")
gpgkey = opts.get(r'key')
gpgkey = opts.get('key')
if not gpgkey:
gpgkey = ui.config(b"gpg", b"key")
return gpg(gpgpath, gpgkey)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment