Mercurial > hg
comparison mercurial/scmutil.py @ 19153:9a4e219bda89
scmutil.addremove: factor out code to mark added/removed/renames
An upcoming patch will reuse this code in another function.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 03 Apr 2013 15:53:59 -0700 |
parents | 7a1292523db3 |
children | 0c7cf411b390 |
comparison
equal
deleted
inserted
replaced
19152:7a1292523db3 | 19153:9a4e219bda89 |
---|---|
705 | 705 |
706 renames = _findrenames(repo, m, added + unknown, removed + deleted, | 706 renames = _findrenames(repo, m, added + unknown, removed + deleted, |
707 similarity) | 707 similarity) |
708 | 708 |
709 if not dry_run: | 709 if not dry_run: |
710 wctx = repo[None] | 710 _markchanges(repo, unknown, deleted, renames) |
711 wlock = repo.wlock() | |
712 try: | |
713 wctx.forget(deleted) | |
714 wctx.add(unknown) | |
715 for new, old in renames.iteritems(): | |
716 wctx.copy(old, new) | |
717 finally: | |
718 wlock.release() | |
719 | 711 |
720 for f in rejected: | 712 for f in rejected: |
721 if f in m.files(): | 713 if f in m.files(): |
722 return 1 | 714 return 1 |
723 return 0 | 715 return 0 |
760 '(%d%% similar)\n') % | 752 '(%d%% similar)\n') % |
761 (matcher.rel(old), matcher.rel(new), | 753 (matcher.rel(old), matcher.rel(new), |
762 score * 100)) | 754 score * 100)) |
763 renames[new] = old | 755 renames[new] = old |
764 return renames | 756 return renames |
757 | |
758 def _markchanges(repo, unknown, deleted, renames): | |
759 '''Marks the files in unknown as added, the files in deleted as removed, | |
760 and the files in renames as copied.''' | |
761 wctx = repo[None] | |
762 wlock = repo.wlock() | |
763 try: | |
764 wctx.forget(deleted) | |
765 wctx.add(unknown) | |
766 for new, old in renames.iteritems(): | |
767 wctx.copy(old, new) | |
768 finally: | |
769 wlock.release() | |
765 | 770 |
766 def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None): | 771 def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None): |
767 """Update the dirstate to reflect the intent of copying src to dst. For | 772 """Update the dirstate to reflect the intent of copying src to dst. For |
768 different reasons it might not end with dst being marked as copied from src. | 773 different reasons it might not end with dst being marked as copied from src. |
769 """ | 774 """ |