D1554: py3: fix handling of keyword arguments in revert

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Nov 29 18:10:39 EST 2017


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1554

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1089,24 +1089,24 @@
         # 2. update the subrepo to the revision specified in
         #    the corresponding substate dictionary
         self.ui.status(_('reverting subrepo %s\n') % substate[0])
-        if not opts.get('no_backup'):
+        if not opts.get(r'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['date'] = None
-            opts['rev'] = substate[1]
+            opts[r'date'] = None
+            opts[r'rev'] = substate[1]
 
             self.filerevert(*pats, **opts)
 
         # Update the repo to the revision specified in the given substate
-        if not opts.get('dry_run'):
+        if not opts.get(r'dry_run'):
             self.get(substate, overwrite=True)
 
     def filerevert(self, *pats, **opts):
-        ctx = self._repo[opts['rev']]
+        ctx = self._repo[opts[r'rev']]
         parents = self._repo.dirstate.parents()
-        if opts.get('all'):
+        if opts.get(r'all'):
             pats = ['set:modified()']
         else:
             pats = []
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4560,6 +4560,7 @@
     Returns 0 on success.
     """
 
+    opts = pycompat.byteskwargs(opts)
     if opts.get("date"):
         if opts.get("rev"):
             raise error.Abort(_("you can't specify a revision and a date"))
@@ -4595,7 +4596,8 @@
             hint = _("use --all to revert all files")
         raise error.Abort(msg, hint=hint)
 
-    return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
+    return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats,
+                          **pycompat.strkwargs(opts))
 
 @command('rollback', dryrunopts +
          [('f', 'force', False, _('ignore safety measures'))])
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3445,6 +3445,7 @@
     return repo.status(match=scmutil.match(repo[None], pats, opts))
 
 def revert(ui, repo, ctx, parents, *pats, **opts):
+    opts = pycompat.byteskwargs(opts)
     parent, p2 = parents
     node = ctx.node()
 
@@ -3722,7 +3723,8 @@
             # Revert the subrepos on the revert list
             for sub in targetsubs:
                 try:
-                    wctx.sub(sub).revert(ctx.substate[sub], *pats, **opts)
+                    wctx.sub(sub).revert(ctx.substate[sub], *pats,
+                                         **pycompat.strkwargs(opts))
                 except KeyError:
                     raise error.Abort("subrepository '%s' does not exist in %s!"
                                       % (sub, short(ctx.node())))



To: pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list