Mercurial > hg
comparison mercurial/cmdutil.py @ 10606:5868dd69fb03
addremove: atomically update the dirstate
In case someone hits ^C during the similarity search, properly rollback
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sun, 07 Mar 2010 23:59:28 +0100 |
parents | 5ddde896a19d |
children | f3ac9d6105ee |
comparison
equal
deleted
inserted
replaced
10605:3077ee5ca750 | 10606:5868dd69fb03 |
---|---|
354 # for finding renames | 354 # for finding renames |
355 elif repo.dirstate[abs] == 'r': | 355 elif repo.dirstate[abs] == 'r': |
356 removed.append(abs) | 356 removed.append(abs) |
357 elif repo.dirstate[abs] == 'a': | 357 elif repo.dirstate[abs] == 'a': |
358 added.append(abs) | 358 added.append(abs) |
359 if not dry_run: | 359 copies = {} |
360 repo.remove(deleted) | |
361 repo.add(unknown) | |
362 if similarity > 0: | 360 if similarity > 0: |
363 for old, new, score in findrenames(repo, added + unknown, | 361 for old, new, score in findrenames(repo, added + unknown, |
364 removed + deleted, similarity): | 362 removed + deleted, similarity): |
365 if repo.ui.verbose or not m.exact(old) or not m.exact(new): | 363 if repo.ui.verbose or not m.exact(old) or not m.exact(new): |
366 repo.ui.status(_('recording removal of %s as rename to %s ' | 364 repo.ui.status(_('recording removal of %s as rename to %s ' |
367 '(%d%% similar)\n') % | 365 '(%d%% similar)\n') % |
368 (m.rel(old), m.rel(new), score * 100)) | 366 (m.rel(old), m.rel(new), score * 100)) |
369 if not dry_run: | 367 copies[new] = old |
368 | |
369 if not dry_run: | |
370 wlock = repo.wlock() | |
371 try: | |
372 repo.remove(deleted) | |
373 repo.add(unknown) | |
374 for new, old in copies.iteritems(): | |
370 repo.copy(old, new) | 375 repo.copy(old, new) |
376 finally: | |
377 wlock.release() | |
371 | 378 |
372 def copy(ui, repo, pats, opts, rename=False): | 379 def copy(ui, repo, pats, opts, rename=False): |
373 # called with the repo lock held | 380 # called with the repo lock held |
374 # | 381 # |
375 # hgsep => pathname that uses "/" to separate directories | 382 # hgsep => pathname that uses "/" to separate directories |