Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/pathutil.py @ 27232:79a86a95f325
pathauditor: add a way to skip file system check
We need to be able to skip it when looking at data within the history.
Doing them in all cases leads to buggy behavior like issue4749.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 03 Dec 2015 10:40:19 -0800 |
parents | 6d29ce250a3d |
children | 054cd38a2f19 |
comparison
equal
deleted
inserted
replaced
27231:6d29ce250a3d | 27232:79a86a95f325 |
---|---|
21 | 21 |
22 - ends with a directory separator | 22 - ends with a directory separator |
23 - under top-level .hg | 23 - under top-level .hg |
24 - starts at the root of a windows drive | 24 - starts at the root of a windows drive |
25 - contains ".." | 25 - contains ".." |
26 | |
27 More check are also done about the file system states: | |
26 - traverses a symlink (e.g. a/symlink_here/b) | 28 - traverses a symlink (e.g. a/symlink_here/b) |
27 - inside a nested repository (a callback can be used to approve | 29 - inside a nested repository (a callback can be used to approve |
28 some nested repositories, e.g., subrepositories) | 30 some nested repositories, e.g., subrepositories) |
31 | |
32 The file system checks are only done when 'realfs' is set to True (the | |
33 default). They should be disable then we are auditing path for operation on | |
34 stored history. | |
29 ''' | 35 ''' |
30 | 36 |
31 def __init__(self, root, callback=None): | 37 def __init__(self, root, callback=None, realfs=True): |
32 self.audited = set() | 38 self.audited = set() |
33 self.auditeddir = set() | 39 self.auditeddir = set() |
34 self.root = root | 40 self.root = root |
41 self._realfs = realfs | |
35 self.callback = callback | 42 self.callback = callback |
36 if os.path.lexists(root) and not util.checkcase(root): | 43 if os.path.lexists(root) and not util.checkcase(root): |
37 self.normcase = util.normcase | 44 self.normcase = util.normcase |
38 else: | 45 else: |
39 self.normcase = lambda x: x | 46 self.normcase = lambda x: x |
79 while parts: | 86 while parts: |
80 prefix = os.sep.join(parts) | 87 prefix = os.sep.join(parts) |
81 normprefix = os.sep.join(normparts) | 88 normprefix = os.sep.join(normparts) |
82 if normprefix in self.auditeddir: | 89 if normprefix in self.auditeddir: |
83 break | 90 break |
84 self._checkfs(prefix, path) | 91 if self._realfs: |
92 self._checkfs(prefix, path) | |
85 prefixes.append(normprefix) | 93 prefixes.append(normprefix) |
86 parts.pop() | 94 parts.pop() |
87 normparts.pop() | 95 normparts.pop() |
88 | 96 |
89 self.audited.add(normpath) | 97 self.audited.add(normpath) |