]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/upgrade.py
Rewrite parametrize to use new parametrizeWithVars
[wizard.git] / wizard / command / upgrade.py
index d6ea50b6ba29b4634d741a8286032dd26c83ca90..39c73c9addb573e3283b9decef60758ffd02b2c8 100644 (file)
@@ -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()
@@ -215,6 +217,16 @@ class Upgrade(object):
             self.mergeSaveState()
             self.mergePerform()
     def mergePreCommit(self):
+        def get_file_set(rev):
+            return set(shell.eval("git", "ls-tree", "-r", "--name-only", rev).split("\n"))
+        # add all files that are unversioned but would be replaced by the pull,
+        # and generate a new commit
+        old_files = get_file_set("HEAD")
+        new_files = get_file_set(self.version)
+        added_files = new_files - old_files
+        for f in added_files:
+            if os.path.exists(f):
+                shell.call("git", "add", f)
         message = "Pre-commit of %s locker before autoinstall upgrade.\n\n%s" % (util.get_dir_owner(), util.get_git_footer())
         try:
             message += "\nPre-commit-by: " + util.get_operator_git()
@@ -515,3 +527,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.
+"""