Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 19154:0c7cf411b390
scmutil: add a function to mark that files have been operated on
Several places use scmutil.addremove as a means to declare that certain files
have been operated on. This is ugly because:
- addremove takes patterns relative to the cwd, not paths relative to the root,
which means extra contortions for callers.
- addremove doesn't make clear what happens to files whose status hasn't
changed.
This new method accepts filenames relative to the repo root, and has a much
clearer contract. It also allows future modifications that do more with files
whose status hasn't changed.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Thu, 04 Apr 2013 13:38:28 -0700 |
parents | 9a4e219bda89 |
children | 8963a706e075 |
comparison
equal
deleted
inserted
replaced
19153:9a4e219bda89 | 19154:0c7cf411b390 |
---|---|
712 for f in rejected: | 712 for f in rejected: |
713 if f in m.files(): | 713 if f in m.files(): |
714 return 1 | 714 return 1 |
715 return 0 | 715 return 0 |
716 | 716 |
717 def marktouched(repo, files, similarity=0.0): | |
718 '''Assert that files have somehow been operated upon. files are relative to | |
719 the repo root.''' | |
720 m = matchfiles(repo, files) | |
721 rejected = [] | |
722 m.bad = lambda x, y: rejected.append(x) | |
723 | |
724 added, unknown, deleted, removed = _interestingfiles(repo, m) | |
725 | |
726 if repo.ui.verbose: | |
727 unknownset = set(unknown) | |
728 toprint = unknownset.copy() | |
729 toprint.update(deleted) | |
730 for abs in sorted(toprint): | |
731 if abs in unknownset: | |
732 status = _('adding %s\n') % abs | |
733 else: | |
734 status = _('removing %s\n') % abs | |
735 repo.ui.status(status) | |
736 | |
737 renames = _findrenames(repo, m, added + unknown, removed + deleted, | |
738 similarity) | |
739 | |
740 _markchanges(repo, unknown, deleted, renames) | |
741 | |
742 for f in rejected: | |
743 if f in m.files(): | |
744 return 1 | |
745 return 0 | |
746 | |
717 def _interestingfiles(repo, matcher): | 747 def _interestingfiles(repo, matcher): |
718 '''Walk dirstate with matcher, looking for files that addremove would care | 748 '''Walk dirstate with matcher, looking for files that addremove would care |
719 about. | 749 about. |
720 | 750 |
721 This is different from dirstate.status because it doesn't care about | 751 This is different from dirstate.status because it doesn't care about |