Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.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 |
comparison
equal
deleted
inserted
replaced
12268:83aaeba32b88 | 12269:877236cdd437 |
---|---|
44 A foo.c | 44 A foo.c |
45 | 45 |
46 Returns 0 if all files are successfully added. | 46 Returns 0 if all files are successfully added. |
47 """ | 47 """ |
48 | 48 |
49 bad = [] | |
50 names = [] | |
51 m = cmdutil.match(repo, pats, opts) | 49 m = cmdutil.match(repo, pats, opts) |
52 oldbad = m.bad | 50 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run')) |
53 m.bad = lambda x, y: bad.append(x) or oldbad(x, y) | 51 return rejected and 1 or 0 |
54 | |
55 for f in repo.walk(m): | |
56 exact = m.exact(f) | |
57 if exact or f not in repo.dirstate: | |
58 names.append(f) | |
59 if ui.verbose or not exact: | |
60 ui.status(_('adding %s\n') % m.rel(f)) | |
61 if not opts.get('dry_run'): | |
62 rejected = repo[None].add(names) | |
63 bad += [f for f in rejected if f in m.files()] | |
64 return bad and 1 or 0 | |
65 | 52 |
66 def addremove(ui, repo, *pats, **opts): | 53 def addremove(ui, repo, *pats, **opts): |
67 """add all new files, delete all missing files | 54 """add all new files, delete all missing files |
68 | 55 |
69 Add all new files and remove all missing files from the | 56 Add all new files and remove all missing files from the |