# HG changeset patch # User Jeff Hammel # Date 1391231134 28800 # Node ID fa1fe03ad9240c7fb967c74e9dc95479d8f4ef2e # Parent 2adda506392bd1f387d448dde813bc80be0723e7 STUB: silvermirror/hg.py diff -r 2adda506392b -r fa1fe03ad924 silvermirror/hg.py --- a/silvermirror/hg.py Fri Jan 31 20:34:34 2014 -0800 +++ b/silvermirror/hg.py Fri Jan 31 21:05:34 2014 -0800 @@ -8,6 +8,7 @@ import os import sys import argparse +from hglib.error import ServerError _import_error = None try: @@ -16,21 +17,18 @@ pass -def update(host, path): +def update(source, path): """ get changes from host on path """ - url = '%s/%s' % (host, path) try: - repo = hg.repository(path) + repo = hglib.open(path) print ('Updating {}:'.format(path)) - except Exception, e: - repo = hg.repository(_ui, url) + repo.pull(host, update=True, insecure=True) + except ServerError: print ('Cloning {} -> {}'.format(url, path)) - commands.clone(_ui, repo, pull=False, uncompressed=False, rev=None, noupdate=False) - return + repo = hglib.clone(source, path) - commands.pull(_ui, repo, url, rev=None, force=False, update=True) # TODO: local repository # def repositories(path): @@ -93,7 +91,8 @@ if not os.path.exists(options.directory): os.mkdir(options.directory) for repo in repos: - update(options.host, repo) + dest = os.path.join(options.directory, repo) + update(options.host, dest) if __name__ == '__main__': main()