Mercurial > hg > silvermirror
view silvermirror/hg.py @ 4:aeb8ddd4a36f
* giving a real version
* giving front-end to hg mirroring
author | k0s <k0scist@gmail.com> |
---|---|
date | Fri, 02 Oct 2009 19:06:12 -0400 |
parents | 8a5d2083fbd1 |
children | 660c74f33ed2 |
line wrap: on
line source
#!/usr/bin/env python """ stub for the hg backend of silvermirror """ import os import sys from mercurial import commands, hg, ui from optparse import OptionParser 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 def main(args=sys.argv[1:]): parser = OptionParser() options, args = parser.parse_args(args) if len(args) > 1: raise NotImplementedError if __name__ == '__main__': main()