mercurial/context.py
branchstable
changeset 16143 fceb2964fa6c
parent 16111 131d1a09108a
child 16145 616c2e278f18
--- a/mercurial/context.py	Mon Feb 20 17:59:48 2012 +0100
+++ b/mercurial/context.py	Thu Feb 23 00:07:54 2012 +0900
@@ -236,6 +236,22 @@
         return patch.diff(self._repo, ctx2.node(), self.node(),
                           match=match, opts=diffopts)
 
+    @propertycache
+    def _dirs(self):
+        dirs = set()
+        for f in self._manifest:
+            pos = f.rfind('/')
+            while pos != -1:
+                f = f[:pos]
+                if f in dirs:
+                    break # dirs already contains this and above
+                dirs.add(f)
+                pos = f.rfind('/')
+        return dirs
+
+    def dirs(self):
+        return self._dirs
+
 class filectx(object):
     """A filecontext object makes access to data related to a particular
        filerevision convenient."""
@@ -953,6 +969,9 @@
             finally:
                 wlock.release()
 
+    def dirs(self):
+        return self._repo.dirstate.dirs()
+
 class workingfilectx(filectx):
     """A workingfilectx object makes access to data related to a particular
        file in the working directory convenient."""