##// END OF EJS Templates
util: make util.dirs() and util.finddirs() include root directory (API)...
Martin von Zweigbergk -
r42915:d8e55c0c default
parent child Browse files
Show More
@@ -42,6 +42,9 b' static inline Py_ssize_t _finddir(const '
42 42 break;
43 43 pos -= 1;
44 44 }
45 if (pos == -1) {
46 return 0;
47 }
45 48
46 49 return pos;
47 50 }
@@ -667,7 +667,7 b' void dirs_module_init(PyObject *mod);'
667 667 void manifest_module_init(PyObject *mod);
668 668 void revlog_module_init(PyObject *mod);
669 669
670 static const int version = 12;
670 static const int version = 13;
671 671
672 672 static void module_init(PyObject *mod)
673 673 {
@@ -414,14 +414,10 b' class hgwebdir(object):'
414 414 return self.makeindex(req, res, tmpl, subdir)
415 415
416 416 def _virtualdirs():
417 # Check the full virtual path, each parent, and the root ('')
418 if virtual != '':
419 yield virtual
420
421 for p in util.finddirs(virtual):
422 yield p
423
424 yield ''
417 # Check the full virtual path, and each parent
418 yield virtual
419 for p in util.finddirs(virtual):
420 yield p
425 421
426 422 for virtualrepo in _virtualdirs():
427 423 real = repos.get(virtualrepo)
@@ -539,8 +539,7 b' class patternmatcher(basematcher):'
539 539 dir = normalizerootdir(dir, 'visitdir')
540 540 if self._prefix and dir in self._fileset:
541 541 return 'all'
542 return ('' in self._fileset or
543 dir in self._fileset or
542 return (dir in self._fileset or
544 543 dir in self._dirs or
545 544 any(parentdir in self._fileset
546 545 for parentdir in util.finddirs(dir)))
@@ -621,8 +620,7 b' class includematcher(basematcher):'
621 620 dir = normalizerootdir(dir, 'visitdir')
622 621 if self._prefix and dir in self._roots:
623 622 return 'all'
624 return ('' in self._roots or
625 dir in self._roots or
623 return (dir in self._roots or
626 624 dir in self._dirs or
627 625 dir in self._parents or
628 626 any(parentdir in self._roots
@@ -1386,14 +1384,14 b' def _rootsdirsandparents(kindpats):'
1386 1384 >>> _rootsdirsandparents(
1387 1385 ... [(b'glob', b'g/h/*', b''), (b'glob', b'g/h', b''),
1388 1386 ... (b'glob', b'g*', b'')])
1389 (['g/h', 'g/h', ''], [], ['g', ''])
1387 (['g/h', 'g/h', ''], [], ['', 'g'])
1390 1388 >>> _rootsdirsandparents(
1391 1389 ... [(b'rootfilesin', b'g/h', b''), (b'rootfilesin', b'', b'')])
1392 ([], ['g/h', ''], ['g', ''])
1390 ([], ['g/h', ''], ['', 'g'])
1393 1391 >>> _rootsdirsandparents(
1394 1392 ... [(b'relpath', b'r', b''), (b'path', b'p/p', b''),
1395 1393 ... (b'path', b'', b'')])
1396 (['r', 'p/p', ''], [], ['p', ''])
1394 (['r', 'p/p', ''], [], ['', 'p'])
1397 1395 >>> _rootsdirsandparents(
1398 1396 ... [(b'relglob', b'rg*', b''), (b're', b're/', b''),
1399 1397 ... (b'relre', b'rr', b'')])
@@ -1406,8 +1404,6 b' def _rootsdirsandparents(kindpats):'
1406 1404 # scanned to get to either the roots or the other exact directories.
1407 1405 p.extend(util.dirs(d))
1408 1406 p.extend(util.dirs(r))
1409 # util.dirs() does not include the root directory, so add it manually
1410 p.append('')
1411 1407
1412 1408 # FIXME: all uses of this function convert these to sets, do so before
1413 1409 # returning.
@@ -69,7 +69,7 b' def _importfrom(pkgname, modname):'
69 69 (r'cext', r'bdiff'): 3,
70 70 (r'cext', r'mpatch'): 1,
71 71 (r'cext', r'osutil'): 4,
72 (r'cext', r'parsers'): 12,
72 (r'cext', r'parsers'): 13,
73 73 }
74 74
75 75 # map import request to other package or module
@@ -3209,6 +3209,7 b' def finddirs(path):'
3209 3209 while pos != -1:
3210 3210 yield path[:pos]
3211 3211 pos = path.rfind('/', 0, pos)
3212 yield ''
3212 3213
3213 3214
3214 3215 # convenient shortcut
@@ -32,3 +32,6 b''
32 32
33 33 * `match.visitdir()` and `match.visitchildrenset()` now expect the
34 34 empty string instead of '.' to indicate the root directory.
35
36 * `util.dirs()` and `util.finddirs()` now include an entry for the
37 root directory (empty string).
@@ -129,8 +129,9 b' Incorrectly configure origbackuppath to '
129 129 b/c: replacing untracked file
130 130 getting b/c
131 131 creating directory: $TESTTMP/repo/.hg/badorigbackups/b
132 abort: $ENOTDIR$: *$TESTTMP/repo/.hg/badorigbackups/b* (glob)
133 [255]
134 $ cat .hg/badorigbackups
135 data
136
132 removing conflicting file: $TESTTMP/repo/.hg/badorigbackups
133 getting d
134 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
135 (activating bookmark c1)
136 $ ls .hg/badorigbackups/b
137 c
General Comments 0
You need to be logged in to leave comments. Login now