# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2017-04-24 20:22:30 # Node ID a77e61b4538411932600a0bc3c498d8685eedc45 # Parent e807c373846aa816412290042dd5f7ff7eb89e04 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(). diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2279,7 +2279,7 @@ def add(ui, repo, match, prefix, explici 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 @@ def add(ui, repo, match, prefix, explici 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 --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -255,8 +255,7 @@ def add(ui, repo, *pats, **opts): 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 --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -1771,7 +1771,7 @@ class gitsubrepo(abstractsubrepo): 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: