Mercurial > public > mercurial-scm > hg
diff mercurial/cmdutil.py @ 12269:877236cdd437
add: move main part to cmdutil to make it easier to reuse
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Mon, 13 Sep 2010 13:09:11 +0200 |
parents | 00658492e2aa |
children | 166b9866580a |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Mon Sep 13 13:09:09 2010 +0200 +++ b/mercurial/cmdutil.py Mon Sep 13 13:09:11 2010 +0200 @@ -1280,6 +1280,22 @@ yield change(rev) return iterate() +def add(ui, repo, match, dryrun): + bad = [] + oldbad = match.bad + match.bad = lambda x, y: bad.append(x) or oldbad(x, y) + names = [] + for f in repo.walk(match): + exact = match.exact(f) + if exact or f not in repo.dirstate: + names.append(f) + if ui.verbose or not exact: + ui.status(_('adding %s\n') % match.rel(f)) + if not dryrun: + rejected = repo[None].add(names) + bad.extend(f for f in rejected if f in match.files()) + return bad + def commit(ui, repo, commitfunc, pats, opts): '''commit the specified files or all outstanding changes''' date = opts.get('date')