[cig-commits] commit: The "forests" request should now be network clean.

Mercurial hg at geodynamics.org
Mon Nov 24 11:27:08 PST 2008


changeset:   60:df4e33bd7149
user:        Simon Law <simon at akoha.org>
date:        Mon Aug 27 13:38:49 2007 -0400
files:       forest.py test-forest test-forest.out
description:
The "forests" request should now be network clean.

repo.forests() should always return '/'-separated paths, which will be
converted using util.localpath() by the client.


diff -r 00777c6a37b6 -r df4e33bd7149 forest.py
--- a/forest.py	Tue Aug 28 15:26:17 2007 -0400
+++ b/forest.py	Mon Aug 27 13:38:49 2007 -0400
@@ -105,32 +105,34 @@ def _localrepo_forests(self, walkhg):
         if err.filename == self.root:
             raise err
 
-    res = []
+    def normpath(path):
+        if path:
+            return util.normpath(path)
+        else:
+            return '.'
+
+    res = {}
     paths = [self.root]
     while paths:
         path = paths.pop()
+        if os.path.realpath(path) in res:
+            continue
         for root, dirs, files in os.walk(path, onerror=errhandler):
             hgdirs = dirs[:]  # Shallow-copy to protect d from dirs.remove() 
             for d in hgdirs:
                 if d == '.hg':
-                    res.append(root)
-                    dirs.remove(d)
+                    res[os.path.realpath(root)] = root
+                    if not walkhg:
+                        dirs.remove(d)
                 else:
                     p = os.path.join(root, d)
-                    if os.path.islink(p):
+                    if os.path.islink(p) and os.path.abspath(p) not in res:
                         paths.append(p)
-    if walkhg:
-        for root in list(res):
-            hgroot = os.path.join(root, '.hg')
-            for e in os.listdir(hgroot):
-                path = os.path.join(hgroot, e)
-                if os.path.isdir(os.path.join(path, '.hg')):
-                    res.append(path)
+    res = res.values()
     res.sort()
     # Turn things into relative paths
     pfx = len(self.root) + 1
-    res = [util.pconvert(os.path.normpath(r[pfx:])) for r in res]
-    return res
+    return [normpath(r[pfx:]) for r in res]
 
 localrepo.localrepository.forests = _localrepo_forests
 
diff -r 00777c6a37b6 -r df4e33bd7149 test-forest
--- a/test-forest	Tue Aug 28 15:26:17 2007 -0400
+++ b/test-forest	Mon Aug 27 13:38:49 2007 -0400
@@ -150,3 +150,12 @@ echo "walkhg = No" >> walkhg/.hg/hgrc
 echo "walkhg = No" >> walkhg/.hg/hgrc
 hg ftrees -R walkhg --convert
 hg ftrees --cwd walkhg --convert --walkhg=FALSE
+
+echo "# circular trees"
+hg init circular
+hg init circular/a
+ln -s . circular/b
+hg init circular/a/a
+ln -s . circular/a/b
+ln -s .. circular/a/c
+hg fstatus -R circular
diff -r 00777c6a37b6 -r df4e33bd7149 test-forest.out
--- a/test-forest.out	Tue Aug 28 15:26:17 2007 -0400
+++ b/test-forest.out	Mon Aug 27 13:38:49 2007 -0400
@@ -408,3 +408,13 @@ a
 a
 .
 a
+# circular trees
+[.]
+? b
+
+[a]
+? b
+? c
+
+[a/a]
+



More information about the CIG-COMMITS mailing list