changeset 2:0d9094bb98b0

adding function to return all hg repos on a path
author k0s <k0scist@gmail.com>
date Fri, 02 Oct 2009 19:00:46 -0400
parents 9b139702a8f9
children 8a5d2083fbd1
files silvermirror/hg.py
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/silvermirror/hg.py
+++ b/silvermirror/hg.py
@@ -12,8 +12,26 @@ def update(host, path):
     """
     ui = ui.ui()
     try: 
         repo = hg.repository(ui, path)
         command = commands.pull
     except mercurial.repo.RepoError:
         repo = hg.repository(ui, 'ssh://%s/%s' % (host, path))
         command = commands.clone
+
+def repositories(path):
+    """
+    return all hg repositories in a path
+    """
+
+    ui = ui.ui()
+    files = [ os.path.join(path, f) for f in os.listdir(path) ]
+    directories = [ f for f in files if os.path.isdir(f) ]
+                    
+    repos = []
+    for d in directories:
+        try: 
+            repo = hg.repository(ui, d)
+            repos.append(os.path.basename(d))
+        except mercurial.repo.RepoError:
+            pass
+    return repos