##// END OF EJS Templates
scmutil.addremove: factor out dirstate walk into another function...
Siddharth Agarwal -
r19150:7a4eab24 default
parent child Browse files
Show More
@@ -685,26 +685,11 b' def addremove(repo, pats=[], opts={}, dr'
685 685 if similarity is None:
686 686 similarity = float(opts.get('similarity') or 0)
687 687 # we'd use status here, except handling of symlinks and ignore is tricky
688 added, unknown, deleted, removed = [], [], [], []
689 audit_path = pathauditor(repo.root)
690 688 m = match(repo[None], pats, opts)
691 689 rejected = []
692 690 m.bad = lambda x, y: rejected.append(x)
693 691
694 ctx = repo[None]
695 dirstate = repo.dirstate
696 walkresults = dirstate.walk(m, sorted(ctx.substate), True, False)
697 for abs, st in walkresults.iteritems():
698 dstate = dirstate[abs]
699 if dstate == '?' and audit_path.check(abs):
700 unknown.append(abs)
701 elif dstate != 'r' and not st:
702 deleted.append(abs)
703 # for finding renames
704 elif dstate == 'r':
705 removed.append(abs)
706 elif dstate == 'a':
707 added.append(abs)
692 added, unknown, deleted, removed = _interestingfiles(repo, m)
708 693
709 694 unknownset = set(unknown)
710 695 toprint = unknownset.copy()
@@ -744,6 +729,32 b' def addremove(repo, pats=[], opts={}, dr'
744 729 return 1
745 730 return 0
746 731
732 def _interestingfiles(repo, matcher):
733 '''Walk dirstate with matcher, looking for files that addremove would care
734 about.
735
736 This is different from dirstate.status because it doesn't care about
737 whether files are modified or clean.'''
738 added, unknown, deleted, removed = [], [], [], []
739 audit_path = pathauditor(repo.root)
740
741 ctx = repo[None]
742 dirstate = repo.dirstate
743 walkresults = dirstate.walk(matcher, sorted(ctx.substate), True, False)
744 for abs, st in walkresults.iteritems():
745 dstate = dirstate[abs]
746 if dstate == '?' and audit_path.check(abs):
747 unknown.append(abs)
748 elif dstate != 'r' and not st:
749 deleted.append(abs)
750 # for finding renames
751 elif dstate == 'r':
752 removed.append(abs)
753 elif dstate == 'a':
754 added.append(abs)
755
756 return added, unknown, deleted, removed
757
747 758 def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None):
748 759 """Update the dirstate to reflect the intent of copying src to dst. For
749 760 different reasons it might not end with dst being marked as copied from src.
General Comments 0
You need to be logged in to leave comments. Login now