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	Sat Sep 26 23:36:42 2009 -0400
+++ b/silvermirror/hg.py	Fri Oct 02 19:00:46 2009 -0400
@@ -17,3 +17,21 @@
     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