changeset 809:d0fb9efa2b2d

Fix performance regression in addremove command. When I rewrote addremove, I lazily put a call to repo.changes in, which was unnecessary and slow. This is a new rewrite, preserving the file name behaviour, but replacing the call to repo.changes with a walk, which is much cheaper, and avoids calls to os.stat on all but files that have probably been deleted.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri, 29 Jul 2005 08:42:28 -0800
parents f199e1887889
children 790a0ff306f2
files mercurial/commands.py
diffstat 1 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Jul 28 07:46:08 2005 -0800
+++ b/mercurial/commands.py	Fri Jul 29 08:42:28 2005 -0800
@@ -339,17 +339,17 @@
 def addremove(ui, repo, *pats, **opts):
     """add all new files, delete all missing files"""
     q = dict(zip(pats, pats))
-    cwd = repo.getcwd()
-    n = (cwd and len(cwd) + 1) or 0
-    c, a, d, u = repo.changes(match = matchpats(cwd, pats, opts))
-    for f in u:
-        if f not in q:
-            ui.status('adding %s\n' % f[n:])
-    repo.add(u)
-    for f in d:
-        if f not in q:
-            ui.status('removing %s\n' % f[n:])
-    repo.remove(d)
+    add, remove = [], []
+    for src, abs, rel in walk(repo, pats, opts):
+        if src == 'f':
+            if repo.dirstate.state(abs) == '?':
+                add.append(abs)
+                if rel not in q: ui.status('adding ', rel, '\n')
+        elif repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
+            remove.append(abs)
+            if rel not in q: ui.status('removing ', rel, '\n')
+    repo.add(add)
+    repo.remove(remove)
 
 def annotate(ui, repo, *pats, **opts):
     """show changeset information per file line"""