Comments
Patch
@@ -328,7 +328,7 @@ class dirstate(object):
if f in self._dirs:
raise util.Abort(_('directory %r already in dirstate') % f)
# shadows
- for d in scmutil.finddirs(f):
+ for d in util.finddirs(f):
if d in self._dirs:
break
if d in self._map and self[d] != 'r':
@@ -526,7 +526,7 @@ class dirstate(object):
return False
if self._ignore(f):
return True
- for p in scmutil.finddirs(f):
+ for p in util.finddirs(f):
if self._ignore(p):
return True
return False
@@ -940,7 +940,7 @@ class dirs(object):
def addpath(self, path):
dirs = self._dirs
- for base in finddirs(path):
+ for base in util.finddirs(path):
if base in dirs:
dirs[base] += 1
return
@@ -948,7 +948,7 @@ class dirs(object):
def delpath(self, path):
dirs = self._dirs
- for base in finddirs(path):
+ for base in util.finddirs(path):
if dirs[base] > 1:
dirs[base] -= 1
return
@@ -962,9 +962,3 @@ class dirs(object):
if util.safehasattr(parsers, 'dirs'):
dirs = parsers.dirs
-
-def finddirs(path):
- pos = path.rfind('/')
- while pos != -1:
- yield path[:pos]
- pos = path.rfind('/', 0, pos)
@@ -981,6 +981,19 @@ def ensuredirs(name, mode=None):
if mode is not None:
os.chmod(name, mode)
+def finddirs(path):
+ '''yield parent dirs of path, longest first. path must be pconvert'ed.
+
+ >>> list(finddirs('/foo/bar/baz/'))
+ ['/foo/bar/baz', '/foo/bar', '/foo', '']
+ >>> list(finddirs('foo/bar/baz'))
+ ['foo/bar', 'foo']
+ '''
+ pos = path.rfind('/')
+ while pos != -1:
+ yield path[:pos]
+ pos = path.rfind('/', 0, pos)
+
def readfile(path):
fp = open(path, 'rb')
try: