]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/prepare_config.py
Convert ad hoc shell calls to singleton instance; fix upgrade bug.
[wizard.git] / wizard / command / prepare_config.py
index 68fa48c171f0fff0b9bf38a4b894fa91fd22b13e..13a4bc92910d28aaa8a99c6962d968d567cada77 100644 (file)
@@ -1,33 +1,29 @@
-import os
-import shutil
-import logging
-import errno
 import sys
+import os.path
 
-import wizard
-from wizard import command, deploy, shell, util
+from wizard import command, deploy, shell
 
 def main(argv, baton):
     options, args = parse_args(argv, baton)
-    sh = shell.Shell()
-    d = deploy.Deployment(".")
-    try:
-        configure_args = args + command.make_base_args(options)
-        sh.call("wizard", "configure", *configure_args, interactive=True)
-    except shell.PythonCallError:
-        sys.exit(1)
-    d.prepareConfig()
+    wc = deploy.WorkingCopy(".")
+    wc.verify()
+    wc.verifyConfigured()
+    # worst case scenario protection
+    for file in wc.application.parametrized_files:
+        shell.call("git", "add", file)
+    shell.call("git", "commit", "--allow-empty", "-am", "Protection commit")
+    shell.call("git", "reset", "HEAD~")
+    wc.prepareConfig()
 
 def parse_args(argv, baton):
-    usage = """usage: %prog prepare-config -- [SETUPARGS]
+    usage = """usage: %prog prepare-config
 
 During the preparation of an upgrade, changes to configuration files
 must be taken into account.  Unfortunately, configuration files
 are not commonly versioned, and are commonly autogenerated.  Running
 this command will update all configuration files.
 
-To be more specific, it takes a checked out repository, and performs a
-configuration.  Then, it replaces the specific values from the installation
+To be more specific, it replaces the specific values from the installation
 back with generic values, which can be committed to the repository.  The final
 working copy state has HEAD pointing to the -scripts version that the commit
 was based off of, but with local changes that can be incorporated using