Mercurial > public > mercurial-scm > hg
diff mercurial/subrepo.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 | aeed2f106213 |
line wrap: on
line diff
--- a/mercurial/subrepo.py Sun Nov 10 07:30:14 2019 -0800 +++ b/mercurial/subrepo.py Fri Nov 08 11:19:20 2019 -0800 @@ -69,8 +69,8 @@ """Exception class used to avoid handling a subrepo error more than once""" def __init__(self, *args, **kw): - self.subrepo = kw.pop(r'subrepo', None) - self.cause = kw.pop(r'cause', None) + self.subrepo = kw.pop('subrepo', None) + self.cause = kw.pop('cause', None) error.Abort.__init__(self, *args, **kw) @@ -969,24 +969,24 @@ # 2. update the subrepo to the revision specified in # the corresponding substate dictionary self.ui.status(_(b'reverting subrepo %s\n') % substate[0]) - if not opts.get(r'no_backup'): + if not opts.get('no_backup'): # Revert all files on the subrepo, creating backups # Note that this will not recursively revert subrepos # We could do it if there was a set:subrepos() predicate opts = opts.copy() - opts[r'date'] = None - opts[r'rev'] = substate[1] + opts['date'] = None + opts['rev'] = substate[1] self.filerevert(*pats, **opts) # Update the repo to the revision specified in the given substate - if not opts.get(r'dry_run'): + if not opts.get('dry_run'): self.get(substate, overwrite=True) def filerevert(self, *pats, **opts): - ctx = self._repo[opts[r'rev']] + ctx = self._repo[opts['rev']] parents = self._repo.dirstate.parents() - if opts.get(r'all'): + if opts.get('all'): pats = [b'set:modified()'] else: pats = [] @@ -1066,7 +1066,7 @@ if not self.ui.interactive(): # Making stdin be a pipe should prevent svn from behaving # interactively even if we can't pass --non-interactive. - extrakw[r'stdin'] = subprocess.PIPE + extrakw['stdin'] = subprocess.PIPE # Starting in svn 1.5 --non-interactive is a global flag # instead of being per-command, but we need to support 1.4 so # we have to be intelligent about what commands take @@ -1125,14 +1125,14 @@ # both. We used to store the working directory one. output, err = self._svncommand([b'info', b'--xml']) doc = xml.dom.minidom.parseString(output) - entries = doc.getElementsByTagName(r'entry') + entries = doc.getElementsByTagName('entry') lastrev, rev = b'0', b'0' if entries: - rev = pycompat.bytestr(entries[0].getAttribute(r'revision')) or b'0' - commits = entries[0].getElementsByTagName(r'commit') + rev = pycompat.bytestr(entries[0].getAttribute('revision')) or b'0' + commits = entries[0].getElementsByTagName('commit') if commits: lastrev = ( - pycompat.bytestr(commits[0].getAttribute(r'revision')) + pycompat.bytestr(commits[0].getAttribute('revision')) or b'0' ) return (lastrev, rev) @@ -1149,23 +1149,23 @@ output, err = self._svncommand([b'status', b'--xml']) externals, changes, missing = [], [], [] doc = xml.dom.minidom.parseString(output) - for e in doc.getElementsByTagName(r'entry'): - s = e.getElementsByTagName(r'wc-status') + for e in doc.getElementsByTagName('entry'): + s = e.getElementsByTagName('wc-status') if not s: continue - item = s[0].getAttribute(r'item') - props = s[0].getAttribute(r'props') - path = e.getAttribute(r'path').encode('utf8') - if item == r'external': + item = s[0].getAttribute('item') + props = s[0].getAttribute('props') + path = e.getAttribute('path').encode('utf8') + if item == 'external': externals.append(path) - elif item == r'missing': + elif item == 'missing': missing.append(path) if item not in ( - r'', - r'normal', - r'unversioned', - r'external', - ) or props not in (r'', r'none', r'normal'): + '', + 'normal', + 'unversioned', + 'external', + ) or props not in ('', 'none', 'normal'): changes.append(path) for path in changes: for ext in externals: @@ -1291,13 +1291,13 @@ output = self._svncommand([b'list', b'--recursive', b'--xml'])[0] doc = xml.dom.minidom.parseString(output) paths = [] - for e in doc.getElementsByTagName(r'entry'): - kind = pycompat.bytestr(e.getAttribute(r'kind')) + for e in doc.getElementsByTagName('entry'): + kind = pycompat.bytestr(e.getAttribute('kind')) if kind != b'file': continue - name = r''.join( + name = ''.join( c.data - for c in e.getElementsByTagName(r'name')[0].childNodes + for c in e.getElementsByTagName('name')[0].childNodes if c.nodeType == c.TEXT_NODE ) paths.append(name.encode('utf8')) @@ -1808,7 +1808,7 @@ if exact: rejected.append(f) continue - if not opts.get(r'dry_run'): + if not opts.get('dry_run'): self._gitcommand(command + [f]) for f in rejected: @@ -1849,7 +1849,7 @@ # This should be much faster than manually traversing the trees # and objects with many subprocess calls. tarstream = self._gitcommand([b'archive', revision], stream=True) - tar = tarfile.open(fileobj=tarstream, mode=r'r|') + tar = tarfile.open(fileobj=tarstream, mode='r|') relpath = subrelpath(self) progress = self.ui.makeprogress( _(b'archiving (%s)') % relpath, unit=_(b'files') @@ -1918,9 +1918,9 @@ deleted, unknown, ignored, clean = [], [], [], [] command = [b'status', b'--porcelain', b'-z'] - if opts.get(r'unknown'): + if opts.get('unknown'): command += [b'--untracked-files=all'] - if opts.get(r'ignored'): + if opts.get('ignored'): command += [b'--ignored'] out = self._gitcommand(command) @@ -1948,7 +1948,7 @@ elif st == b'!!': ignored.append(filename1) - if opts.get(r'clean'): + if opts.get('clean'): out = self._gitcommand([b'ls-files']) for f in out.split(b'\n'): if not f in changedfiles: @@ -1962,7 +1962,7 @@ def diff(self, ui, diffopts, node2, match, prefix, **opts): node1 = self._state[1] cmd = [b'diff', b'--no-renames'] - if opts[r'stat']: + if opts['stat']: cmd.append(b'--stat') else: # for Git, this also implies '-p' @@ -2007,7 +2007,7 @@ @annotatesubrepoerror def revert(self, substate, *pats, **opts): self.ui.status(_(b'reverting subrepo %s\n') % substate[0]) - if not opts.get(r'no_backup'): + if not opts.get('no_backup'): status = self.status(None) names = status.modified for name in names: @@ -2023,7 +2023,7 @@ ) util.rename(self.wvfs.join(name), bakname) - if not opts.get(r'dry_run'): + if not opts.get('dry_run'): self.get(substate, overwrite=True) return []