comparison mercurial/commands.py @ 1712:21dcf38e5d7d

Allow callers to pass in the dirstate lock in most localrepo.py funcs. This makes it possible to take the lock once and commit a large number of patches, without having to read and write the dirstate for each patch.
author mason@suse.com
date Thu, 09 Feb 2006 17:18:43 -0600
parents c65113f3627a
children 55017891051b 284fc722c342
comparison
equal deleted inserted replaced
1711:8959700c2b19 1712:21dcf38e5d7d
517 Add all new files and remove all missing files from the repository. 517 Add all new files and remove all missing files from the repository.
518 518
519 New files are ignored if they match any of the patterns in .hgignore. As 519 New files are ignored if they match any of the patterns in .hgignore. As
520 with add, these changes take effect at the next commit. 520 with add, these changes take effect at the next commit.
521 """ 521 """
522 return addremove_lock(ui, repo, pats, opts)
523
524 def addremove_lock(ui, repo, pats, opts, wlock=None):
522 add, remove = [], [] 525 add, remove = [], []
523 for src, abs, rel, exact in walk(repo, pats, opts): 526 for src, abs, rel, exact in walk(repo, pats, opts):
524 if src == 'f' and repo.dirstate.state(abs) == '?': 527 if src == 'f' and repo.dirstate.state(abs) == '?':
525 add.append(abs) 528 add.append(abs)
526 if ui.verbose or not exact: 529 if ui.verbose or not exact:
527 ui.status(_('adding %s\n') % ((pats and rel) or abs)) 530 ui.status(_('adding %s\n') % ((pats and rel) or abs))
528 if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel): 531 if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
529 remove.append(abs) 532 remove.append(abs)
530 if ui.verbose or not exact: 533 if ui.verbose or not exact:
531 ui.status(_('removing %s\n') % ((pats and rel) or abs)) 534 ui.status(_('removing %s\n') % ((pats and rel) or abs))
532 repo.add(add) 535 repo.add(add, wlock=wlock)
533 repo.remove(remove) 536 repo.remove(remove, wlock=wlock)
534 537
535 def annotate(ui, repo, *pats, **opts): 538 def annotate(ui, repo, *pats, **opts):
536 """show changeset information per file line 539 """show changeset information per file line
537 540
538 List changes in files, showing the revision id responsible for each line 541 List changes in files, showing the revision id responsible for each line