Mercurial > hg > silvermirror
view silvermirror/hg.py @ 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 |
line wrap: on
line source
#!/usr/bin/env python """ stub for the hg backend of silvermirror """ import os from mercurial import commands, hg, ui def update(host, path): """ get changes from host on 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