##// END OF EJS Templates
path_auditor: cache names of audited directories...
Alexis S. L. Carvalho -
r5200:c7e8fe11 default
parent child Browse files
Show More
@@ -692,7 +692,8 b' class path_auditor(object):'
692 - inside a nested repository'''
692 - inside a nested repository'''
693
693
694 def __init__(self, root):
694 def __init__(self, root):
695 self.audited = {}
695 self.audited = set()
696 self.auditeddir = set()
696 self.root = root
697 self.root = root
697
698
698 def __call__(self, path):
699 def __call__(self, path):
@@ -720,10 +721,19 b' class path_auditor(object):'
720 os.path.isdir(os.path.join(curpath, '.hg'))):
721 os.path.isdir(os.path.join(curpath, '.hg'))):
721 raise Abort(_('path %r is inside repo %r') %
722 raise Abort(_('path %r is inside repo %r') %
722 (path, prefix))
723 (path, prefix))
723 self.audited[prefix] = True
724
725 prefixes = []
724 for c in strutil.rfindall(normpath, os.sep):
726 for c in strutil.rfindall(normpath, os.sep):
725 check(normpath[:c])
727 prefix = normpath[:c]
726 self.audited[path] = True
728 if prefix in self.auditeddir:
729 break
730 check(prefix)
731 prefixes.append(prefix)
732
733 self.audited.add(path)
734 # only add prefixes to the cache after checking everything: we don't
735 # want to add "foo/bar/baz" before checking if there's a "foo/.hg"
736 self.auditeddir.update(prefixes)
727
737
728 def _makelock_file(info, pathname):
738 def _makelock_file(info, pathname):
729 ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL)
739 ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL)
@@ -13,6 +13,10 b" echo '# should fail'"
13 hg st b/x
13 hg st b/x
14 hg add b/x
14 hg add b/x
15
15
16 echo '# should fail'
17 hg add b b/x
18 hg st
19
16 echo '# should arguably print nothing'
20 echo '# should arguably print nothing'
17 hg st b
21 hg st b
18
22
@@ -2,6 +2,8 b''
2 # should fail
2 # should fail
3 abort: path 'b/x' is inside repo 'b'
3 abort: path 'b/x' is inside repo 'b'
4 abort: path 'b/x' is inside repo 'b'
4 abort: path 'b/x' is inside repo 'b'
5 # should fail
6 abort: path 'b/x' is inside repo 'b'
5 # should arguably print nothing
7 # should arguably print nothing
6 # should fail
8 # should fail
7 abort: path 'b/a' is inside repo 'b'
9 abort: path 'b/a' is inside repo 'b'
General Comments 0
You need to be logged in to leave comments. Login now