Show More
@@ -86,17 +86,25 class match(object): | |||
|
86 | 86 | self._always = False |
|
87 | 87 | self._pathrestricted = bool(include or exclude or patterns) |
|
88 | 88 | self._warn = warn |
|
89 | self._includeroots = set() | |
|
90 | self._includedirs = set(['.']) | |
|
91 | self._excluderoots = set() | |
|
89 | 92 | |
|
90 | 93 | matchfns = [] |
|
91 | 94 | if include: |
|
92 | 95 | kindpats = self._normalize(include, 'glob', root, cwd, auditor) |
|
93 | 96 | self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)', |
|
94 | 97 | listsubrepos) |
|
98 | self._includeroots.update(_roots(kindpats)) | |
|
99 | self._includeroots.discard('.') | |
|
100 | self._includedirs.update(util.dirs(self._includeroots)) | |
|
95 | 101 | matchfns.append(im) |
|
96 | 102 | if exclude: |
|
97 | 103 | kindpats = self._normalize(exclude, 'glob', root, cwd, auditor) |
|
98 | 104 | self.excludepat, em = _buildmatch(ctx, kindpats, '(?:/|$)', |
|
99 | 105 | listsubrepos) |
|
106 | self._excluderoots.update(_roots(kindpats)) | |
|
107 | self._excluderoots.discard('.') | |
|
100 | 108 | matchfns.append(lambda f: not em(f)) |
|
101 | 109 | if exact: |
|
102 | 110 | if isinstance(patterns, list): |
@@ -177,10 +185,25 class match(object): | |||
|
177 | 185 | return set(util.dirs(self._fileroots)) | set(['.']) |
|
178 | 186 | |
|
179 | 187 | def visitdir(self, dir): |
|
188 | '''Decides whether a directory should be visited based on whether it | |
|
189 | has potential matches in it or one of its subdirectories. This is | |
|
190 | based on the match's primary, included, and excluded patterns. | |
|
191 | ||
|
192 | This function's behavior is undefined if it has returned False for | |
|
193 | one of the dir's parent directories. | |
|
194 | ''' | |
|
195 | if dir in self._excluderoots: | |
|
196 | return False | |
|
197 | parentdirs = None | |
|
198 | if (self._includeroots and dir not in self._includeroots and | |
|
199 | dir not in self._includedirs): | |
|
200 | parentdirs = util.finddirs(dir) | |
|
201 | if not any(parent in self._includeroots for parent in parentdirs): | |
|
202 | return False | |
|
180 | 203 | return (not self._fileroots or '.' in self._fileroots or |
|
181 | 204 | dir in self._fileroots or dir in self._dirs or |
|
182 | 205 | any(parentdir in self._fileroots |
|
183 | for parentdir in util.finddirs(dir))) | |
|
206 | for parentdir in parentdirs or util.finddirs(dir))) | |
|
184 | 207 | |
|
185 | 208 | def exact(self, f): |
|
186 | 209 | '''Returns True if f is in .files().''' |
@@ -280,3 +280,100 Turning off treemanifest config has no e | |||
|
280 | 280 | 0 0 125 0 4 63c9c0557d24 000000000000 000000000000 |
|
281 | 281 | 1 125 109 0 5 23d12a1f6e0e 000000000000 000000000000 |
|
282 | 282 | 2 234 55 0 6 3cb2d87b4250 23d12a1f6e0e 000000000000 |
|
283 | ||
|
284 | Create deeper repo with tree manifests. | |
|
285 | ||
|
286 | $ cd .. | |
|
287 | $ hg --config experimental.treemanifest=True init deeprepo | |
|
288 | $ cd deeprepo | |
|
289 | ||
|
290 | $ mkdir a | |
|
291 | $ mkdir b | |
|
292 | $ mkdir b/bar | |
|
293 | $ mkdir b/bar/orange | |
|
294 | $ mkdir b/bar/orange/fly | |
|
295 | $ mkdir b/foo | |
|
296 | $ mkdir b/foo/apple | |
|
297 | $ mkdir b/foo/apple/bees | |
|
298 | ||
|
299 | $ touch a/one.txt | |
|
300 | $ touch a/two.txt | |
|
301 | $ touch b/bar/fruits.txt | |
|
302 | $ touch b/bar/orange/fly/gnat.py | |
|
303 | $ touch b/bar/orange/fly/housefly.txt | |
|
304 | $ touch b/foo/apple/bees/flower.py | |
|
305 | $ touch c.txt | |
|
306 | $ touch d.py | |
|
307 | ||
|
308 | $ hg ci -Aqm 'initial' | |
|
309 | ||
|
310 | We'll see that visitdir works by removing some treemanifest revlogs and running | |
|
311 | the files command with various parameters. | |
|
312 | ||
|
313 | Test files from the root. | |
|
314 | ||
|
315 | $ hg files -r . | |
|
316 | a/one.txt | |
|
317 | a/two.txt | |
|
318 | b/bar/fruits.txt | |
|
319 | b/bar/orange/fly/gnat.py | |
|
320 | b/bar/orange/fly/housefly.txt | |
|
321 | b/foo/apple/bees/flower.py | |
|
322 | c.txt | |
|
323 | d.py | |
|
324 | ||
|
325 | Test files for a subdirectory. | |
|
326 | ||
|
327 | $ mv .hg/store/meta/a oldmf | |
|
328 | $ hg files -r . b | |
|
329 | b/bar/fruits.txt | |
|
330 | b/bar/orange/fly/gnat.py | |
|
331 | b/bar/orange/fly/housefly.txt | |
|
332 | b/foo/apple/bees/flower.py | |
|
333 | $ mv oldmf .hg/store/meta/a | |
|
334 | ||
|
335 | Test files with just includes and excludes. | |
|
336 | ||
|
337 | $ mv .hg/store/meta/a oldmf | |
|
338 | $ mv .hg/store/meta/b/bar/orange/fly oldmf2 | |
|
339 | $ mv .hg/store/meta/b/foo/apple/bees oldmf3 | |
|
340 | $ hg files -r . -I b/bar -X b/bar/orange/fly -I b/foo -X b/foo/apple/bees | |
|
341 | b/bar/fruits.txt | |
|
342 | $ mv oldmf .hg/store/meta/a | |
|
343 | $ mv oldmf2 .hg/store/meta/b/bar/orange/fly | |
|
344 | $ mv oldmf3 .hg/store/meta/b/foo/apple/bees | |
|
345 | ||
|
346 | Test files for a subdirectory, excluding a directory within it. | |
|
347 | ||
|
348 | $ mv .hg/store/meta/a oldmf | |
|
349 | $ mv .hg/store/meta/b/foo oldmf2 | |
|
350 | $ hg files -r . -X b/foo b | |
|
351 | b/bar/fruits.txt | |
|
352 | b/bar/orange/fly/gnat.py | |
|
353 | b/bar/orange/fly/housefly.txt | |
|
354 | $ mv oldmf .hg/store/meta/a | |
|
355 | $ mv oldmf2 .hg/store/meta/b/foo | |
|
356 | ||
|
357 | Test files for a sub directory, including only a directory within it, and | |
|
358 | including an unrelated directory. | |
|
359 | ||
|
360 | $ mv .hg/store/meta/a oldmf | |
|
361 | $ mv .hg/store/meta/b/foo oldmf2 | |
|
362 | $ hg files -r . -I b/bar/orange -I a b | |
|
363 | b/bar/orange/fly/gnat.py | |
|
364 | b/bar/orange/fly/housefly.txt | |
|
365 | $ mv oldmf .hg/store/meta/a | |
|
366 | $ mv oldmf2 .hg/store/meta/b/foo | |
|
367 | ||
|
368 | Test files for a pattern, including a directory, and excluding a directory | |
|
369 | within that. | |
|
370 | ||
|
371 | $ mv .hg/store/meta/a oldmf | |
|
372 | $ mv .hg/store/meta/b/foo oldmf2 | |
|
373 | $ mv .hg/store/meta/b/bar/orange oldmf3 | |
|
374 | $ hg files -r . glob:**.txt -I b/bar -X b/bar/orange | |
|
375 | b/bar/fruits.txt | |
|
376 | $ mv oldmf .hg/store/meta/a | |
|
377 | $ mv oldmf2 .hg/store/meta/b/foo | |
|
378 | $ mv oldmf3 .hg/store/meta/b/bar/orange | |
|
379 |
General Comments 0
You need to be logged in to leave comments.
Login now