changeset 401:f652f9d4765b

flesh out
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 30 Jul 2013 03:30:30 -0700
parents 8964b285c2f7
children c00b70509fff
files python/setup_repo.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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()