Mercurial > hg
changeset 23885:9994f45ba714
add: pass options via keyword args
The largefiles extensions needs to be able to pass --large, --normal and
--lfsize to subrepos via cmdutil.add() and hgsubrepo.add(). Rather than add
additional special purpose arguments, stop extracting the existing args from the
**opts passed to commands.add() and just pass them along.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 12 Jan 2015 20:59:17 -0500 |
parents | ec2c2e1400f0 |
children | 5ce8dcd05dc4 |
files | mercurial/cmdutil.py mercurial/commands.py mercurial/subrepo.py |
diffstat | 3 files changed, 10 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed Dec 31 18:24:32 2014 -0500 +++ b/mercurial/cmdutil.py Mon Jan 12 20:59:17 2015 -0500 @@ -1979,7 +1979,7 @@ nodes = nodes[:limit] return graphmod.nodes(repo, nodes) -def add(ui, repo, match, dryrun, listsubrepos, prefix, explicitonly): +def add(ui, repo, match, prefix, explicitonly, **opts): join = lambda f: os.path.join(prefix, f) bad = [] oldbad = match.bad @@ -2003,17 +2003,15 @@ sub = wctx.sub(subpath) try: submatch = matchmod.narrowmatcher(subpath, match) - if listsubrepos: - bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix, - False)) + if opts.get('subrepos'): + bad.extend(sub.add(ui, submatch, prefix, False, **opts)) else: - bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix, - True)) + bad.extend(sub.add(ui, submatch, prefix, True, **opts)) except error.LookupError: ui.status(_("skipping missing subrepository: %s\n") % join(subpath)) - if not dryrun: + if not opts.get('dry_run'): rejected = wctx.add(names, prefix) bad.extend(f for f in rejected if f in match.files()) return bad
--- a/mercurial/commands.py Wed Dec 31 18:24:32 2014 -0500 +++ b/mercurial/commands.py Mon Jan 12 20:59:17 2015 -0500 @@ -199,8 +199,7 @@ """ m = scmutil.match(repo[None], pats, opts) - rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'), - opts.get('subrepos'), prefix="", explicitonly=False) + rejected = cmdutil.add(ui, repo, m, "", False, **opts) return rejected and 1 or 0 @command('addremove',
--- a/mercurial/subrepo.py Wed Dec 31 18:24:32 2014 -0500 +++ b/mercurial/subrepo.py Mon Jan 12 20:59:17 2015 -0500 @@ -621,9 +621,10 @@ fp.close() @annotatesubrepoerror - def add(self, ui, match, dryrun, listsubrepos, prefix, explicitonly): - return cmdutil.add(ui, self._repo, match, dryrun, listsubrepos, - os.path.join(prefix, self._path), explicitonly) + def add(self, ui, match, prefix, explicitonly, **opts): + return cmdutil.add(ui, self._repo, match, + os.path.join(prefix, self._path), explicitonly, + **opts) def addremove(self, m, prefix, opts, dry_run, similarity): # In the same way as sub directories are processed, once in a subrepo,