]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/migrate.py
Fix bug where php.ini not being rewritten for MediaWiki.
[wizard.git] / wizard / command / migrate.py
index 83b3d1e4780ae21df052c750850874b9ef5f036f..d3dce85ef3f10b0e82620b24dea53fca3c6322be 100644 (file)
@@ -3,10 +3,7 @@ import os.path
 import shutil
 import logging
 
-from wizard import command, deploy, shell, util
-
-# LEGACY (but still necessary, since we haven't migrated all of scripts
-# yet.  Maybe if we plugin-ify the commands interface move this.)
+from wizard import app, command, deploy, shell, util
 
 def main(argv, baton):
     options, args = parse_args(argv, baton)
@@ -26,29 +23,39 @@ def main(argv, baton):
     try:
         deployment.verify()
         raise AlreadyMigratedError(deployment.location)
+    except deploy.NotAutoinstallError:
+        # Previously, this was a fatal error, but now let's try
+        # a little harder.
+        # XXX: The user still has to tell us what application ; a more
+        # user friendly thing to do is figure it out automatically
+        if not options.force_app:
+            raise
+        # actual version number will get overwritten shortly
+        deployment.setAppVersion(app.ApplicationVersion.make(options.force_app, "unknown"))
     except deploy.NotMigratedError:
+        # LEGACY
         pass
     except (deploy.CorruptedAutoinstallError, AlreadyMigratedError):
         if not options.force:
             raise
 
-    deployment.verifyTag(options.srv_path)
-
     if options.force_version:
-        version = deployment.application.makeVersion(options.force_version)
+        deployment.setAppVersion(deployment.application.makeVersion(options.force_version))
     else:
         try:
             deployment.verifyVersion()
-            version = deployment.app_version
         except deploy.VersionMismatchError as e:
             # well, we'll use that then
-            version = deployment.application.makeVersion(str(e.real_version))
-    repo = version.application.repository(options.srv_path)
-    tag = version.wizard_tag
+            deployment.setAppVersion(deployment.application.makeVersion(str(e.real_version)))
+
+    deployment.verifyTag(options.srv_path)
+
+    repo = deployment.application.repository(options.srv_path)
+    tag = deployment.app_version.wizard_tag
     try:
         sh.call("git", "--git-dir=%s" % repo, "rev-parse", tag)
     except shell.CallError:
-        raise UnsupportedVersion(version.version)
+        raise UnsupportedVersion(deployment.version)
 
     with util.LockDirectory(".wizard-migrate-lock"):
         try:
@@ -77,11 +84,14 @@ upgrading .  Do NOT run this command as root."""
     parser.add_option("--dry-run", dest="dry_run", action="store_true",
             default=False, help="Prints would would be run without changing anything")
     parser.add_option("--force", "-f", dest="force", action="store_true",
-            default=False, help="If .git or .wizard directory already exists,"
+            default=False, help="If .git or .wizard directory already exists, "
             "delete them and migrate")
     parser.add_option("--force-version", dest="force_version",
-            default=None, help="If .scripts-version tells lies, explicitly specify"
+            default=None, help="If .scripts-version is corrupted or non-existent, explicitly specify "
             "a version to migrate to.")
+    parser.add_option("--force-app", dest="force_app",
+            default=None, help="If .scripts-version is corrupted or non-existent, explicitly specify "
+            "an application to migrate to.")
     options, args = parser.parse_all(argv)
     if len(args) > 1:
         parser.error("too many arguments")