##// END OF EJS Templates
merge: cache unknown dir checks (issue5716)...
Mark Thomas -
r35181:b8596235 stable
parent child Browse files
Show More
@@ -653,7 +653,7 b' def _checkunknownfile(repo, wctx, mctx, '
653 653 and repo.dirstate.normalize(f) not in repo.dirstate
654 654 and mctx[f2].cmp(wctx[f]))
655 655
656 def _checkunknowndirs(repo, f):
656 class _unknowndirschecker(object):
657 657 """
658 658 Look for any unknown files or directories that may have a path conflict
659 659 with a file. If any path prefix of the file exists as a file or link,
@@ -663,23 +663,42 b' def _checkunknowndirs(repo, f):'
663 663 Returns the shortest path at which a conflict occurs, or None if there is
664 664 no conflict.
665 665 """
666 def __init__(self):
667 # A set of paths known to be good. This prevents repeated checking of
668 # dirs. It will be updated with any new dirs that are checked and found
669 # to be safe.
670 self._unknowndircache = set()
666 671
667 # Check for path prefixes that exist as unknown files.
668 for p in reversed(list(util.finddirs(f))):
669 if (repo.wvfs.audit.check(p)
670 and repo.wvfs.isfileorlink(p)
671 and repo.dirstate.normalize(p) not in repo.dirstate):
672 return p
672 # A set of paths that are known to be absent. This prevents repeated
673 # checking of subdirectories that are known not to exist. It will be
674 # updated with any new dirs that are checked and found to be absent.
675 self._missingdircache = set()
673 676
674 # Check if the file conflicts with a directory containing unknown files.
675 if repo.wvfs.audit.check(f) and repo.wvfs.isdir(f):
676 # Does the directory contain any files that are not in the dirstate?
677 for p, dirs, files in repo.wvfs.walk(f):
678 for fn in files:
679 relf = repo.dirstate.normalize(repo.wvfs.reljoin(p, fn))
680 if relf not in repo.dirstate:
681 return f
682 return None
677 def __call__(self, repo, f):
678 # Check for path prefixes that exist as unknown files.
679 for p in reversed(list(util.finddirs(f))):
680 if p in self._missingdircache:
681 return
682 if p in self._unknowndircache:
683 continue
684 if repo.wvfs.audit.check(p):
685 if (repo.wvfs.isfileorlink(p)
686 and repo.dirstate.normalize(p) not in repo.dirstate):
687 return p
688 if not repo.wvfs.lexists(p):
689 self._missingdircache.add(p)
690 return
691 self._unknowndircache.add(p)
692
693 # Check if the file conflicts with a directory containing unknown files.
694 if repo.wvfs.audit.check(f) and repo.wvfs.isdir(f):
695 # Does the directory contain any files that are not in the dirstate?
696 for p, dirs, files in repo.wvfs.walk(f):
697 for fn in files:
698 relf = repo.dirstate.normalize(repo.wvfs.reljoin(p, fn))
699 if relf not in repo.dirstate:
700 return f
701 return None
683 702
684 703 def _checkunknownfiles(repo, wctx, mctx, force, actions, mergeforce):
685 704 """
@@ -701,12 +720,13 b' def _checkunknownfiles(repo, wctx, mctx,'
701 720 elif config == 'warn':
702 721 warnconflicts.update(conflicts)
703 722
723 checkunknowndirs = _unknowndirschecker()
704 724 for f, (m, args, msg) in actions.iteritems():
705 725 if m in ('c', 'dc'):
706 726 if _checkunknownfile(repo, wctx, mctx, f):
707 727 fileconflicts.add(f)
708 728 elif pathconfig and f not in wctx:
709 path = _checkunknowndirs(repo, f)
729 path = checkunknowndirs(repo, f)
710 730 if path is not None:
711 731 pathconflicts.add(path)
712 732 elif m == 'dg':
General Comments 0
You need to be logged in to leave comments. Login now