merge with mpm
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Fri, 08 May 2009 22:35:10 +0200
changeset 8326 b7017097a4ec
parent 8325 f2559645643a (diff)
parent 8318 6b8513f8274a (current diff)
child 8327 aa25be1c2889
merge with mpm
--- a/hgext/inotify/server.py	Thu May 07 19:39:45 2009 -0500
+++ b/hgext/inotify/server.py	Fri May 08 22:35:10 2009 +0200
@@ -32,69 +32,62 @@
     '''Iterate over all subdirectories of this repo.
     Exclude the .hg directory, any nested repos, and ignored dirs.'''
     rootslash = repo.root + os.sep
+
     def walkit(dirname, top):
-        hginside = False
+        fullpath = rootslash + dirname
         try:
-            for name, kind in osutil.listdir(rootslash + dirname):
+            for name, kind in osutil.listdir(fullpath):
                 if kind == stat.S_IFDIR:
                     if name == '.hg':
-                        hginside = True
-                        if not top: break
+                        if not top:
+                            return
                     else:
                         d = join(dirname, name)
                         if repo.dirstate._ignore(d):
                             continue
-                        for subdir, hginsub in walkit(d, False):
-                            if not hginsub:
-                                yield subdir, False
+                        for subdir in walkit(d, False):
+                            yield subdir
         except OSError, err:
             if err.errno not in walk_ignored_errors:
                 raise
-        yield rootslash + dirname, hginside
-    for dirname, hginside in walkit('', True):
-        yield dirname
+        yield fullpath
+
+    return walkit('', True)
 
 def walk(repo, root):
     '''Like os.walk, but only yields regular files.'''
 
     # This function is critical to performance during startup.
 
-    reporoot = root == ''
     rootslash = repo.root + os.sep
 
     def walkit(root, reporoot):
         files, dirs = [], []
-        hginside = False
 
         try:
             fullpath = rootslash + root
             for name, kind in osutil.listdir(fullpath):
                 if kind == stat.S_IFDIR:
                     if name == '.hg':
-                        hginside = True
-                        if reporoot:
-                            continue
-                        else:
-                            break
-                    dirs.append(name)
+                        if not reporoot:
+                            return
+                    else:
+                        dirs.append(name)
                 elif kind in (stat.S_IFREG, stat.S_IFLNK):
-                    path = join(root, name)
                     files.append((name, kind))
-
-            yield hginside, fullpath, dirs, files
+            yield fullpath, dirs, files
 
             for subdir in dirs:
                 path = join(root, subdir)
                 if repo.dirstate._ignore(path):
                     continue
                 for result in walkit(path, False):
-                    if not result[0]:
-                        yield result
+                    yield result
         except OSError, err:
             if err.errno not in walk_ignored_errors:
                 raise
-    for result in walkit(root, reporoot):
-        yield result[1:]
+
+    return walkit(root, root == '')
 
 def _explain_watch_limit(ui, repo, count):
     path = '/proc/sys/fs/inotify/max_user_watches'