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