# HG changeset patch # User k0s # Date 1254524446 14400 # Node ID 0d9094bb98b04ef13b3a3ba49861d75aa2443b7d # Parent 9b139702a8f9e355e1f057af6c66ef3114d775dc adding function to return all hg repos on a path diff -r 9b139702a8f9 -r 0d9094bb98b0 silvermirror/hg.py --- 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