From 1f784d0c4a740a898115f08f66c062ef8c5a0e83 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 8 Mar 2010 21:45:23 -0500 Subject: [PATCH] More robust handling for symlinks and Git rematching. Signed-off-by: Edward Z. Yang --- wizard/command/mass_migrate.py | 2 +- wizard/command/upgrade.py | 13 ++++++++++++- wizard/scripts.py | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/wizard/command/mass_migrate.py b/wizard/command/mass_migrate.py index 98c0509..956399a 100644 --- a/wizard/command/mass_migrate.py +++ b/wizard/command/mass_migrate.py @@ -37,7 +37,7 @@ def main(argv, baton): def on_success(stdout, stderr): if stderr: logging.warning("Warnings [%04d] %s:\n%s" % (i, d.location, stderr)) - runtime.write("warning", i, d.location) + runtime.write("warnings", i, d.location) runtime.write("success", i, d.location) def on_error(e): if e.name == "wizard.command.migrate.AlreadyMigratedError" or \ diff --git a/wizard/command/upgrade.py b/wizard/command/upgrade.py index d6ea50b..3f14251 100644 --- a/wizard/command/upgrade.py +++ b/wizard/command/upgrade.py @@ -150,7 +150,7 @@ class Upgrade(object): attempting anything. """ options = self.options - while True: + for i in range(0,2): self.prod = deploy.ProductionCopy(".") self.prod.verify() self.repo = self.prod.application.repository(options.srv_path) @@ -176,6 +176,8 @@ class Upgrade(object): shell.call("git", "merge", "--strategy=ours", self.prod.application.makeVersion(str(e.real_version)).scripts_tag) continue break + else: + raise VersionRematchFailed self.prod.verifyWeb() self.preflightAlreadyUpgraded() self.preflightQuota() @@ -515,3 +517,12 @@ ERROR: We cannot resume the upgrade process; either this working copy is missing essential metadata, or you've attempt to continue from a production copy that does not have any pending upgrades. """ + +class VersionRematchFailed(Error): + def __str__(self): + return """ + +ERROR: Your Git version information was not consistent with your +files on the system, and we were unable to create a fake merge +to make the two consistent. Please contact scripts@mit.edu. +""" diff --git a/wizard/scripts.py b/wizard/scripts.py index 50af4af..9092f26 100644 --- a/wizard/scripts.py +++ b/wizard/scripts.py @@ -124,6 +124,7 @@ def get_disk_usage(dir=None, excluded_dir=".git"): if not os.path.join(root, name).startswith(dir + excluded_dir): file = os.path.join(root, name) try: + if os.path.islink(file): continue sum_sizes += os.path.getsize(file) except OSError as e: if e.errno == errno.ENOENT: -- 2.45.2