Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 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 | 4b06fc1c0f26 |
children | 790a0ff306f2 |
comparison
equal
deleted
inserted
replaced
787:f199e1887889 | 809:d0fb9efa2b2d |
---|---|
337 repo.add(names) | 337 repo.add(names) |
338 | 338 |
339 def addremove(ui, repo, *pats, **opts): | 339 def addremove(ui, repo, *pats, **opts): |
340 """add all new files, delete all missing files""" | 340 """add all new files, delete all missing files""" |
341 q = dict(zip(pats, pats)) | 341 q = dict(zip(pats, pats)) |
342 cwd = repo.getcwd() | 342 add, remove = [], [] |
343 n = (cwd and len(cwd) + 1) or 0 | 343 for src, abs, rel in walk(repo, pats, opts): |
344 c, a, d, u = repo.changes(match = matchpats(cwd, pats, opts)) | 344 if src == 'f': |
345 for f in u: | 345 if repo.dirstate.state(abs) == '?': |
346 if f not in q: | 346 add.append(abs) |
347 ui.status('adding %s\n' % f[n:]) | 347 if rel not in q: ui.status('adding ', rel, '\n') |
348 repo.add(u) | 348 elif repo.dirstate.state(abs) != 'r' and not os.path.exists(rel): |
349 for f in d: | 349 remove.append(abs) |
350 if f not in q: | 350 if rel not in q: ui.status('removing ', rel, '\n') |
351 ui.status('removing %s\n' % f[n:]) | 351 repo.add(add) |
352 repo.remove(d) | 352 repo.remove(remove) |
353 | 353 |
354 def annotate(ui, repo, *pats, **opts): | 354 def annotate(ui, repo, *pats, **opts): |
355 """show changeset information per file line""" | 355 """show changeset information per file line""" |
356 def getnode(rev): | 356 def getnode(rev): |
357 return hg.short(repo.changelog.node(rev)) | 357 return hg.short(repo.changelog.node(rev)) |