68 otherparent.add(fname) |
68 otherparent.add(fname) |
69 return nonnorm, otherparent |
69 return nonnorm, otherparent |
70 |
70 |
71 class dirstate(object): |
71 class dirstate(object): |
72 |
72 |
73 def __init__(self, opener, ui, root, validate): |
73 def __init__(self, opener, ui, root, validate, sparsematchfn): |
74 '''Create a new dirstate object. |
74 '''Create a new dirstate object. |
75 |
75 |
76 opener is an open()-like callable that can be used to open the |
76 opener is an open()-like callable that can be used to open the |
77 dirstate file; root is the root of the directory tracked by |
77 dirstate file; root is the root of the directory tracked by |
78 the dirstate. |
78 the dirstate. |
79 ''' |
79 ''' |
80 self._opener = opener |
80 self._opener = opener |
81 self._validate = validate |
81 self._validate = validate |
82 self._root = root |
82 self._root = root |
|
83 self._sparsematchfn = sparsematchfn |
83 # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is |
84 # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is |
84 # UNC path pointing to root share (issue4557) |
85 # UNC path pointing to root share (issue4557) |
85 self._rootdir = pathutil.normasprefix(root) |
86 self._rootdir = pathutil.normasprefix(root) |
86 self._dirty = False |
87 self._dirty = False |
87 self._dirtypl = False |
88 self._dirtypl = False |
194 f = {} |
195 f = {} |
195 normcase = util.normcase |
196 normcase = util.normcase |
196 for name in self._dirs: |
197 for name in self._dirs: |
197 f[normcase(name)] = name |
198 f[normcase(name)] = name |
198 return f |
199 return f |
|
200 |
|
201 @property |
|
202 def _sparsematcher(self): |
|
203 """The matcher for the sparse checkout. |
|
204 |
|
205 The working directory may not include every file from a manifest. The |
|
206 matcher obtained by this property will match a path if it is to be |
|
207 included in the working directory. |
|
208 """ |
|
209 # TODO there is potential to cache this property. For now, the matcher |
|
210 # is resolved on every access. (But the called function does use a |
|
211 # cache to keep the lookup fast.) |
|
212 return self._sparsematchfn() |
199 |
213 |
200 @repocache('branch') |
214 @repocache('branch') |
201 def _branch(self): |
215 def _branch(self): |
202 try: |
216 try: |
203 return self._opener.read("branch").strip() or "default" |
217 return self._opener.read("branch").strip() or "default" |