# HG changeset patch # User Jeff Hammel # Date 1375180230 25200 # Node ID f652f9d4765b171a113b25290af3b1a44e7775e1 # Parent 8964b285c2f741ecf7439214b527bbd134c95f3c flesh out diff -r 8964b285c2f7 -r f652f9d4765b python/setup_repo.py --- a/python/setup_repo.py Tue Jul 30 02:54:51 2013 -0700 +++ b/python/setup_repo.py Tue Jul 30 03:30:30 2013 -0700 @@ -40,12 +40,14 @@ # parse command line arguments parser = OptionParser('%prog [options] location') parser.add_option('-m', '--message', dest='message', - help='commit message') + default='initial commit', + help='commit message [Default: %default]') parser.add_option('-u', '--remote-url', dest='remote_url', default="http://k0s.org/hg/", help="URL of host hg repository collection [Default: %default]") parser.add_option('-p', '--remote-path', dest='remote_path', help="remote path of hg repository links; otherwise taken from --remote-url, if specified") + parser.add_option options, args = parser.parse_args(args) if len(args) != 1: parser.print_usage() @@ -53,10 +55,11 @@ # TODO: sanity check for remote_url, remote_path # setup repository - name = os.path.basename(directory) - call(['hg', 'init']) - call(['hg', 'add']) - call(['hg', 'commit', '-m', options.message or 'initial commit of %s' %name]) + directory = args[0] + name = os.path.basename(directory) # XXX unnecessary? + call(['hg', 'init', directory]) + call(['hg', 'add', '-R', directory]) + call(['hg', 'commit', '-m', options.message, '-R', directory]) # setup remote, if specified if options.remote_url: @@ -71,12 +74,15 @@ remote_path = path # setup remote repository - call(['ssh', HOST, "cd %s/%s && hg init && hg add && hg ci -m '%s'" % (repo, name, options.message or 'initial commit of %s' % name)]) + call(['ssh', host, "mkdir -p cd %s/%s && hg init && hg add && hg ci -m '%s'" % (repo, name, options.message)]) # write local .hgrc file # TODO: use ConfigParser f = file(os.path.join('.hg', 'hgrc'), 'w') print >> f, HGRC % { 'host': HOST, 'repo': repo, 'name': name} + # push changes + call(['hg', 'push', '-R', directory]) + if __name__ == '__main__': main()