mercurial/pathutil.py
changeset 43633 0b7733719d21
parent 43523 c21aca51b392
child 44180 d84420232492
--- a/mercurial/pathutil.py	Wed Nov 13 21:52:25 2019 -0500
+++ b/mercurial/pathutil.py	Thu Nov 14 08:03:26 2019 -0800
@@ -275,6 +275,14 @@
         return path
 
 
+def finddirs(path):
+    pos = path.rfind(b'/')
+    while pos != -1:
+        yield path[:pos]
+        pos = path.rfind(b'/', 0, pos)
+    yield b''
+
+
 class dirs(object):
     '''a multiset of directory names from a set of file paths'''
 
@@ -295,7 +303,7 @@
 
     def addpath(self, path):
         dirs = self._dirs
-        for base in util.finddirs(path):
+        for base in finddirs(path):
             if base.endswith(b'/'):
                 raise ValueError(
                     "found invalid consecutive slashes in path: %r" % base
@@ -307,7 +315,7 @@
 
     def delpath(self, path):
         dirs = self._dirs
-        for base in util.finddirs(path):
+        for base in finddirs(path):
             if dirs[base] > 1:
                 dirs[base] -= 1
                 return