]> scripts.mit.edu Git - wizard.git/commitdiff
Fix unmerged counts, make backups lock, add Wordpress resolutions.
authorEdward Z. Yang <ezyang@mit.edu>
Fri, 25 Dec 2009 02:32:30 +0000 (21:32 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Fri, 25 Dec 2009 02:32:30 +0000 (21:32 -0500)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
wizard/app/wordpress.py
wizard/command/upgrade.py
wizard/deploy.py

index d98add18b2c4c0e09fb8be8053f0034929ceb3cc..8b1f9cb9d73e441b22bd21644a6434d98d5820a8 100644 (file)
@@ -91,3 +91,18 @@ class Application(app.Application):
         app.restore_database(backup_dir, deployment)
     def remove(self, deployment, options):
         app.remove_database(deployment)
+
+Application.resolutions = {
+'wp-config.php': [
+    ("""
+<<<<<<<
+
+/** WordPress absolute path to the Wordpress directory. */
+|||||||
+/** WordPress absolute path to the Wordpress directory. */
+=======
+/** Absolute path to the WordPress directory. */
+>>>>>>>
+""", [0])
+],
+}
index dc2298b2e19aa68f9ce54a75700e97813c1ac8c5..12c720576b9e5b40f053559b3f415c0a207f8c28 100644 (file)
@@ -5,6 +5,7 @@ import shutil
 import logging.handlers
 import tempfile
 import itertools
+import time
 
 from wizard import app, command, deploy, scripts, shell, util
 
@@ -247,7 +248,6 @@ def perform_merge(sh, repo, d, wc, version, use_shm, kib_avail, non_interactive)
         sh.call("git", "config", "merge.conflictstyle", "diff3")
         sh.call("git", "merge", next_virtual_commit)
     except shell.CallError as e:
-        conflicts = e.stdout.count("CONFLICT") # not perfect, if there is a file named CONFLICT
         logging.info("Merge failed with these messages:\n\n" + e.stderr)
         # Run the application's specific merge resolution algorithms
         # and see if we can salvage it
@@ -256,8 +256,13 @@ def perform_merge(sh, repo, d, wc, version, use_shm, kib_avail, non_interactive)
             logging.info("Resolved conflicts with application specific knowledge")
             sh.call("git", "commit", "-a", "-m", "merge")
             return os.getcwd()
-        # XXX: Maybe should recalculate conflicts
         logging.info("Conflict info:\n" + sh.eval("git", "diff"))
+        outlines = sh.eval("git", "ls-files", "--unmerged").splitlines()
+        files = set()
+        for line in outlines:
+            _, _, _, name = line.split(None, 3)
+            files.add(name)
+        conflicts = len(files)
         curdir = mv_shm_to_tmp(curdir, use_shm)
         os.chdir(curdir)
         open(os.path.join(d.location, ".scripts/pending"), "w").write(curdir)
@@ -271,11 +276,6 @@ def perform_merge(sh, repo, d, wc, version, use_shm, kib_avail, non_interactive)
                 print
                 print "ERROR: The merge failed with %d conflicts in these files:" % conflicts
                 print
-                outlines = sh.eval("git", "ls-files", "--unmerged").splitlines()
-                files = set()
-                for line in outlines:
-                    _, _, _, name = line.split(None, 3)
-                    files.add(name)
                 for file in sorted(files):
                     print "  * %s" % file
                 print
index 73f0095ea27014c83d76fa2ca3d0fc758c396d41..8b3748d5047f75ba9a6ad45fb500d74485941057 100644 (file)
@@ -10,6 +10,9 @@ import logging
 import decorator
 import datetime
 import tempfile
+import time
+import traceback
+import shutil
 
 import wizard
 from wizard import app, git, old_log, scripts, shell, sql, util
@@ -347,20 +350,24 @@ class ProductionCopy(Deployment):
             shutil.rmtree(tmpdir)
             raise
         backup = None
-        while 1:
-            backup = str(self.version) + "-" + datetime.datetime.today().strftime("%Y-%m-%dT%H%M%S")
-            outdir = os.path.join(backupdir, backup)
-            if os.path.exists(outdir):
-                logging.warning("Backup: A backup occurred in the last second. Trying again in a second...")
-                time.sleep(1)
-                continue
-            try:
-                os.rename(tmpdir, outdir)
-            except OSError:
-                logging.warning("Backup: We lost the race, trying again in a second...")
-                time.sleep(1)
-                continue
-            break
+        with util.LockDirectory(os.path.join(backupdir, "lock")):
+            while 1:
+                backup = str(self.version) + "-" + datetime.datetime.today().strftime("%Y-%m-%dT%H%M%S")
+                outdir = os.path.join(backupdir, backup)
+                if os.path.exists(outdir):
+                    logging.warning("Backup: A backup occurred in the last second. Trying again in a second...")
+                    time.sleep(1)
+                    continue
+                try:
+                    shutil.move(tmpdir, outdir)
+                except:
+                    # don't leave half-baked stuff lying around
+                    try:
+                        shutil.rmtree(outdir)
+                    except OSError:
+                        pass
+                    raise
+                break
         return backup
     @chdir_to_location
     def restore(self, backup, options):