Patchwork [6,of,7] py3: handle opts correctly for `hg add`

login
register
mail settings
Submitter Pulkit Goyal
Date May 4, 2017, 3:16 a.m.
Message ID <ce1a68eb8ccfaccd9c07.1493867808@pulkit-goyal>
Download mbox | patch
Permalink /patch/20419/
State Accepted
Headers show

Comments

Pulkit Goyal - May 4, 2017, 3:16 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1493065350 -19800
#      Tue Apr 25 01:52:30 2017 +0530
# Node ID ce1a68eb8ccfaccd9c0786f4c46eeba768f27f21
# Parent  0eb19bf539912f8d2b07d93ef3feb22c177cd938
py3: handle opts correctly for `hg add`

opts in add command were passed again to cmdutil.add() as kwargs so we need
to convert them again to str. Intstead we convert them to bytes when passing
scmutil.match(). Opts handling is also corrected for all the functions which
are called from cmdutil.add().

Patch

diff -r 0eb19bf53991 -r ce1a68eb8ccf mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Mon Apr 24 04:32:04 2017 +0530
+++ b/mercurial/cmdutil.py	Tue Apr 25 01:52:30 2017 +0530
@@ -2279,7 +2279,7 @@ 
         sub = wctx.sub(subpath)
         try:
             submatch = matchmod.subdirmatcher(subpath, match)
-            if opts.get('subrepos'):
+            if opts.get(r'subrepos'):
                 bad.extend(sub.add(ui, submatch, prefix, False, **opts))
             else:
                 bad.extend(sub.add(ui, submatch, prefix, True, **opts))
@@ -2287,7 +2287,7 @@ 
             ui.status(_("skipping missing subrepository: %s\n")
                            % join(subpath))
 
-    if not opts.get('dry_run'):
+    if not opts.get(r'dry_run'):
         rejected = wctx.add(names, prefix)
         bad.extend(f for f in rejected if f in match.files())
     return bad
diff -r 0eb19bf53991 -r ce1a68eb8ccf mercurial/commands.py
--- a/mercurial/commands.py	Mon Apr 24 04:32:04 2017 +0530
+++ b/mercurial/commands.py	Tue Apr 25 01:52:30 2017 +0530
@@ -255,8 +255,7 @@ 
     Returns 0 if all files are successfully added.
     """
 
-    opts = pycompat.byteskwargs(opts)
-    m = scmutil.match(repo[None], pats, opts)
+    m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts))
     rejected = cmdutil.add(ui, repo, m, "", False, **opts)
     return rejected and 1 or 0
 
diff -r 0eb19bf53991 -r ce1a68eb8ccf mercurial/subrepo.py
--- a/mercurial/subrepo.py	Mon Apr 24 04:32:04 2017 +0530
+++ b/mercurial/subrepo.py	Tue Apr 25 01:52:30 2017 +0530
@@ -1771,7 +1771,7 @@ 
                 if exact:
                     rejected.append(f)
                 continue
-            if not opts.get('dry_run'):
+            if not opts.get(r'dry_run'):
                 self._gitcommand(command + [f])
 
         for f in rejected: