[cig-commits] commit: `hg ftrees` now uses the Forest framework

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


changeset:   68:00cc9acdcf3e
user:        Simon Law <simon at akoha.org>
date:        Mon Aug 27 13:49:23 2007 -0400
files:       forest.py
description:
`hg ftrees` now uses the Forest framework


diff -r f0d10035b058 -r 00cc9acdcf3e forest.py
--- a/forest.py	Mon Aug 27 13:48:25 2007 -0400
+++ b/forest.py	Mon Aug 27 13:49:23 2007 -0400
@@ -1115,18 +1115,24 @@ def status(ui, top, *pats, **opts):
                  prehooks=[lambda tree: check_mq(tree)])
 
 
-def trees(ui, repo, convert=False, walkhg='', **opts):
-    """List the roots of the repositories."""
-
-    walkhg = walkhgenabled(ui, walkhg)
-    if convert:
-        l = repo.forests(walkhg)
-    else:
-        root = repo.root
-        l = [(f == "." and root) or os.path.join(root, f)
-             for f in repo.forests(walkhg)]
-    for t in l:
-        ui.write(t + '\n')
+def trees(ui, top, **opts):
+    """show the roots of the repositories
+
+    Show the roots of the trees in the forest.
+
+    By default, show the absolute path of each repository.  With
+    --convert, show the portable Mercurial path.
+    """
+
+    forest = Forest(top=top,
+                    walkhg=walkhgenabled(ui, opts['walkhg']))
+    convert = opts['convert']
+    for tree in forest.trees:
+        if convert:
+            ui.write("%s\n" % relpath(top.root, tree.root))
+        else:
+            ui.write("%s\n" % util.localpath(tree.root))
+
 
 def update(ui, toprepo, snapfile=None, tip=False, walkhg='', **opts):
     """Update working directories to tip or according to a snapshot file.



More information about the CIG-COMMITS mailing list