diff -r 4085c9fafb8e -r 38982de2b4eb mercurial/scmutil.py --- 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)