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