changeset 18897:38982de2b4eb

scmutil: migrate finddirs from dirstate
author Bryan O'Sullivan <bryano@fb.com>
date Wed, 10 Apr 2013 15:08:25 -0700
parents 4085c9fafb8e
children 856960173630
files mercurial/dirstate.py mercurial/scmutil.py
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Wed Apr 10 15:05:06 2013 -0700
+++ b/mercurial/dirstate.py	Wed Apr 10 15:08:25 2013 -0700
@@ -25,21 +25,15 @@
     def join(self, obj, fname):
         return obj._join(fname)
 
-def _finddirs(path):
-    pos = path.rfind('/')
-    while pos != -1:
-        yield path[:pos]
-        pos = path.rfind('/', 0, pos)
-
 def _incdirs(dirs, path):
-    for base in _finddirs(path):
+    for base in scmutil.finddirs(path):
         if base in dirs:
             dirs[base] += 1
             return
         dirs[base] = 1
 
 def _decdirs(dirs, path):
-    for base in _finddirs(path):
+    for base in scmutil.finddirs(path):
         if dirs[base] > 1:
             dirs[base] -= 1
             return
@@ -346,7 +340,7 @@
             if f in self._dirs:
                 raise util.Abort(_('directory %r already in dirstate') % f)
             # shadows
-            for d in _finddirs(f):
+            for d in scmutil.finddirs(f):
                 if d in self._dirs:
                     break
                 if d in self._map and self[d] != 'r':
@@ -540,7 +534,7 @@
             return False
         if self._ignore(f):
             return True
-        for p in _finddirs(f):
+        for p in scmutil.finddirs(f):
             if self._ignore(p):
                 return True
         return False
--- a/mercurial/scmutil.py	Wed Apr 10 15:05:06 2013 -0700
+++ b/mercurial/scmutil.py	Wed Apr 10 15:08:25 2013 -0700
@@ -890,3 +890,9 @@
             del obj.__dict__[self.name]
         except KeyError:
             raise AttributeError(self.name)
+
+def finddirs(path):
+    pos = path.rfind('/')
+    while pos != -1:
+        yield path[:pos]
+        pos = path.rfind('/', 0, pos)