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)
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:
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")
self._app_version = None
self._read_cache = {}
self._old_log = None
+ def setAppVersion(self, app_version):
+ """
+ Manually resets the application version; useful if the working
+ copy is off in space (i.e. not anchored to something we can
+ git describe off of) or there is no metadata to be heard of.
+ """
+ self._app_version = app_version
def read(self, file, force = False):
"""
Reads a file's contents, possibly from cache unless ``force``
modifications to without fear of interfering with a production
deployment. More operations are permitted on these copies.
"""
- def setAppVersion(self, app_version):
- """
- Manually resets the application version; useful if the working
- copy is off in space (i.e. not anchored to something we can
- git describe off of.)
- """
- self._app_version = app_version
@chdir_to_location
def parametrize(self, deployment):
"""