diff 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
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Sep 13 13:09:09 2010 +0200
+++ b/mercurial/commands.py	Mon Sep 13 13:09:11 2010 +0200
@@ -46,22 +46,9 @@
     Returns 0 if all files are successfully added.
     """
 
-    bad = []
-    names = []
     m = cmdutil.match(repo, pats, opts)
-    oldbad = m.bad
-    m.bad = lambda x, y: bad.append(x) or oldbad(x, y)
-
-    for f in repo.walk(m):
-        exact = m.exact(f)
-        if exact or f not in repo.dirstate:
-            names.append(f)
-            if ui.verbose or not exact:
-                ui.status(_('adding %s\n') % m.rel(f))
-    if not opts.get('dry_run'):
-        rejected = repo[None].add(names)
-        bad += [f for f in rejected if f in m.files()]
-    return bad and 1 or 0
+    rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'))
+    return rejected and 1 or 0
 
 def addremove(ui, repo, *pats, **opts):
     """add all new files, delete all missing files