py3: fix handling of keyword arguments in revert
authorPulkit Goyal <7895pulkit@gmail.com>
Wed, 29 Nov 2017 07:57:17 +0530
changeset 35168 3da4bd50103d
parent 35167 0b5716ec8500
child 35169 d2eff9d4db3f
py3: fix handling of keyword arguments in revert Differential Revision: https://phab.mercurial-scm.org/D1554
mercurial/cmdutil.py
mercurial/commands.py
mercurial/subrepo.py
--- a/mercurial/cmdutil.py	Tue Nov 28 11:00:54 2017 -0500
+++ b/mercurial/cmdutil.py	Wed Nov 29 07:57:17 2017 +0530
@@ -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())))
--- a/mercurial/commands.py	Tue Nov 28 11:00:54 2017 -0500
+++ b/mercurial/commands.py	Wed Nov 29 07:57:17 2017 +0530
@@ -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'))])
--- a/mercurial/subrepo.py	Tue Nov 28 11:00:54 2017 -0500
+++ b/mercurial/subrepo.py	Wed Nov 29 07:57:17 2017 +0530
@@ -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 = []