diff mercurial/osutil.py @ 7034:0d513661d6c2

listdir: add support for aborting if a certain path is found This lets us bail out early if we find '.hg', letting us skip sorting and bisecting for it.
author Matt Mackall <mpm@selenic.com>
date Sat, 13 Sep 2008 10:46:47 -0500
parents 5105b119edd2
children 094af6eeb7d7
line wrap: on
line diff
--- a/mercurial/osutil.py	Sat Sep 13 10:44:44 2008 -0500
+++ b/mercurial/osutil.py	Sat Sep 13 10:46:47 2008 -0500
@@ -10,7 +10,7 @@
     if stat.S_ISSOCK(mode): return stat.S_IFSOCK
     return mode
 
-def listdir(path, stat=False):
+def listdir(path, stat=False, skip=None):
     '''listdir(path, stat=False) -> list_of_tuples
 
     Return a sorted list containing information about the entries
@@ -30,6 +30,8 @@
     names.sort()
     for fn in names:
         st = os.lstat(prefix + fn)
+        if fn == skip and stat.S_ISDIR(st.st_mode):
+            return []
         if stat:
             result.append((fn, _mode_to_kind(st.st_mode), st))
         else: