# HG changeset patch # User Jeff Hammel # Date 1375180935 25200 # Node ID 62eb670a408fbea4fcda214a4d9bb54dc6eef227 # Parent c00b70509ffff2f1ac22c41841a2a0e32722be1d dont roll your own diff -r c00b70509fff -r 62eb670a408f python/setup_repo.py --- a/python/setup_repo.py Tue Jul 30 03:32:31 2013 -0700 +++ b/python/setup_repo.py Tue Jul 30 03:42:15 2013 -0700 @@ -13,7 +13,6 @@ import sys import urlparse -from subprocess import check_call as call from optparse import OptionParser @@ -24,21 +23,12 @@ default-push = ssh://%(host)s/%(repo)s/%(name)s """ -def call(command, *args, **kw): - - code = subprocess.call(command, *args, **kw) - if isinstance(command, basestring): - cmdstr = command - else: - cmdstr = ' '.join(command) - print cmdstr - if code: - raise SystemExit("Command `%s` exited with code %d" % (cmdstr, code)) +call = subprocess.check_output def main(args=sys.argv[1:]): # parse command line arguments - parser = OptionParser('%prog [options] location') + parser = OptionParser('%prog [options] directory') parser.add_option('-m', '--message', dest='message', default='initial commit', help='commit message [Default: %default]') @@ -74,7 +64,8 @@ remote_path = path # setup remote repository - call(['ssh', host, "mkdir -p cd %s/%s && hg init && hg add && hg ci -m '%s'" % (repo, name, options.message)]) + remote_dir = '%s/%s' % (path, name) + call(['ssh', host, "mkdir -p %s && cd %s && hg init" % (remote_dir, remote_dir)]) # write local .hgrc file # TODO: use ConfigParser