diff hgext/mq.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 be384a2052aa
children 2d5b991c2192
line wrap: on
line diff
--- a/hgext/mq.py	Sun Nov 10 07:30:14 2019 -0800
+++ b/hgext/mq.py	Fri Nov 08 11:19:20 2019 -0800
@@ -490,7 +490,7 @@
     def __init__(self, ui, baseui, path, patchdir=None):
         self.basepath = path
         try:
-            with open(os.path.join(path, b'patches.queue'), r'rb') as fh:
+            with open(os.path.join(path, b'patches.queue'), 'rb') as fh:
                 cur = fh.read().rstrip()
 
             if not cur:
@@ -2777,7 +2777,7 @@
 
     This command is deprecated. Without -c, it's implied by other relevant
     commands. With -c, use :hg:`init --mq` instead."""
-    return qinit(ui, repo, create=opts.get(r'create_repo'))
+    return qinit(ui, repo, create=opts.get('create_repo'))
 
 
 @command(
@@ -2933,7 +2933,7 @@
 
     Returns 0 on success."""
     repo.mq.qseries(
-        repo, missing=opts.get(r'missing'), summary=opts.get(r'summary')
+        repo, missing=opts.get('missing'), summary=opts.get('summary')
     )
     return 0
 
@@ -2960,7 +2960,7 @@
             start=t - 1,
             length=1,
             status=b'A',
-            summary=opts.get(r'summary'),
+            summary=opts.get('summary'),
         )
     else:
         ui.write(_(b"no patches applied\n"))
@@ -2982,7 +2982,7 @@
     if end == len(q.series):
         ui.write(_(b"all patches applied\n"))
         return 1
-    q.qseries(repo, start=end, length=1, summary=opts.get(r'summary'))
+    q.qseries(repo, start=end, length=1, summary=opts.get('summary'))
 
 
 @command(
@@ -3005,7 +3005,7 @@
         return 1
     idx = q.series.index(q.applied[-2].name)
     q.qseries(
-        repo, start=idx, length=1, status=b'A', summary=opts.get(r'summary')
+        repo, start=idx, length=1, status=b'A', summary=opts.get('summary')
     )
 
 
@@ -3356,8 +3356,8 @@
     applied = set(p.name for p in q.applied)
     patch = None
     args = list(args)
-    if opts.get(r'list'):
-        if args or opts.get(r'none'):
+    if opts.get('list'):
+        if args or opts.get('none'):
             raise error.Abort(
                 _(b'cannot mix -l/--list with options or arguments')
             )
@@ -3372,7 +3372,7 @@
         patch = args.pop(0)
     if patch is None:
         raise error.Abort(_(b'no patch to work with'))
-    if args or opts.get(r'none'):
+    if args or opts.get('none'):
         idx = q.findseries(patch)
         if idx is None:
             raise error.Abort(_(b'no patch named %s') % patch)
@@ -3634,9 +3634,7 @@
     This command is deprecated, use :hg:`rebase` instead."""
     rev = repo.lookup(rev)
     q = repo.mq
-    q.restore(
-        repo, rev, delete=opts.get(r'delete'), qupdate=opts.get(r'update')
-    )
+    q.restore(repo, rev, delete=opts.get('delete'), qupdate=opts.get('update'))
     q.savedirty()
     return 0
 
@@ -3841,9 +3839,9 @@
 
     Returns 0 on success.
     """
-    if not opts.get(r'applied') and not revrange:
+    if not opts.get('applied') and not revrange:
         raise error.Abort(_(b'no revisions specified'))
-    elif opts.get(r'applied'):
+    elif opts.get('applied'):
         revrange = (b'qbase::qtip',) + revrange
 
     q = repo.mq
@@ -4072,9 +4070,9 @@
 
         def invalidateall(self):
             super(mqrepo, self).invalidateall()
-            if localrepo.hasunfilteredcache(self, r'mq'):
+            if localrepo.hasunfilteredcache(self, 'mq'):
                 # recreate mq in case queue path was changed
-                delattr(self.unfiltered(), r'mq')
+                delattr(self.unfiltered(), 'mq')
 
         def abortifwdirpatched(self, errmsg, force=False):
             if self.mq.applied and self.mq.checkapplied and not force:
@@ -4172,16 +4170,16 @@
 
 def mqimport(orig, ui, repo, *args, **kwargs):
     if util.safehasattr(repo, b'abortifwdirpatched') and not kwargs.get(
-        r'no_commit', False
+        'no_commit', False
     ):
         repo.abortifwdirpatched(
-            _(b'cannot import over an applied patch'), kwargs.get(r'force')
+            _(b'cannot import over an applied patch'), kwargs.get('force')
         )
     return orig(ui, repo, *args, **kwargs)
 
 
 def mqinit(orig, ui, *args, **kwargs):
-    mq = kwargs.pop(r'mq', None)
+    mq = kwargs.pop('mq', None)
 
     if not mq:
         return orig(ui, *args, **kwargs)
@@ -4206,7 +4204,7 @@
     """Add --mq option to operate on patch repository instead of main"""
 
     # some commands do not like getting unknown options
-    mq = kwargs.pop(r'mq', None)
+    mq = kwargs.pop('mq', None)
 
     if not mq:
         return orig(ui, repo, *args, **kwargs)