changeset 403:62eb670a408f

dont roll your own
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 30 Jul 2013 03:42:15 -0700
parents c00b70509fff
children fb304dcd1e64
files python/setup_repo.py
diffstat 1 files changed, 4 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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