changeset 404:fb304dcd1e64

factor to its own method
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 30 Jul 2013 10:35:47 -0700
parents 62eb670a408f
children 815eb5c796e9
files python/setup_repo.py
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/python/setup_repo.py	Tue Jul 30 03:42:15 2013 -0700
+++ b/python/setup_repo.py	Tue Jul 30 10:35:47 2013 -0700
@@ -25,6 +25,13 @@
 
 call = subprocess.check_output
 
+def init_repo(directory):
+    """setup repository"""
+    call(['hg', 'init', directory])
+    call(['hg', 'add', '-R', directory])
+    call(['hg', 'commit', '-m', options.message, '-R', directory])
+
+
 def main(args=sys.argv[1:]):
 
     # parse command line arguments
@@ -42,16 +49,13 @@
     if len(args) != 1:
         parser.print_usage()
         parser.exit()
-    # TODO: sanity check for remote_url, remote_path
+    directory = args[0]
 
-    # setup repository
-    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])
+    # initialize repository
+    init_repo(directory)
 
     # setup remote, if specified
+    name = os.path.basename(directory)
     if options.remote_url:
 
         # parse remote URL