[PATCH 2 of 3] util.walkrepos() follows symbolic links to directories

Robin Farine robin.farine at terminus.org
Tue Dec 26 19:26:02 UTC 2006


Updated version from Benoit Boissinot based on an iterative rather
than recursive implementation.

# HG changeset patch
# User Robin Farine <robin.farine at terminus.org>
# Date 1167160817 -3600
# Node ID 10b255882392a4c86255732266f6907bebfeaa26
# Parent  cd4f4bc4e25ec834bebd8991800d0645470718e8
util.walkrepos() follows symbolic links to directories

diff -r cd4f4bc4e25e -r 10b255882392 mercurial/util.py
--- a/mercurial/util.py	Sat Dec 23 16:10:58 2006 +0100
+++ b/mercurial/util.py	Tue Dec 26 20:20:17 2006 +0100
@@ -1263,11 +1263,18 @@ def walkrepos(path):
         if err.filename == path:
             raise err
 
-    for root, dirs, files in os.walk(path, onerror=errhandler):
-        for d in dirs:
-            if d == '.hg':
-                yield root
-                dirs.remove(d)
+    paths = [path]
+    while paths:
+        path = paths.pop()
+        for root, dirs, files in os.walk(path, onerror=errhandler):
+            for d in dirs:
+                if d == '.hg':
+                    yield root
+                    dirs.remove(d)
+                else:
+                    p = os.path.join(root, d)
+                    if os.path.islink(p):
+                        paths.append(p)
 
 _rcpath = None
 



More information about the Mercurial-devel mailing list