]> scripts.mit.edu Git - wizard.git/commitdiff
Implement number of conflict reporting for upgrades.
authorEdward Z. Yang <ezyang@mit.edu>
Sun, 11 Oct 2009 22:36:48 +0000 (18:36 -0400)
committerEdward Z. Yang <ezyang@mit.edu>
Sun, 11 Oct 2009 22:36:48 +0000 (18:36 -0400)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
TODO
tests/test-continue-upgrade-mediawiki.sh
wizard/command/mass_upgrade.py
wizard/command/upgrade.py

diff --git a/TODO b/TODO
index 5457c380c998c6108a30ae4f9d0e101375b2cd5d..a4c4e142678cca157322fbb70d4d76d3e7e7ef1f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -23,8 +23,6 @@ TODO NOW:
     - Failed migrations should be wired to have wizard commands in them
       automatically log to the relevant file.  In addition, the seen file
       should get updated when one of them gets fixed.
-    - Failed migration should report how many unmerged files there are
-      (so we can auto-punt if it's over a threshold)
 
 - Let users use Wizard when ssh'ed into Scripts
     - Make single user mass-migrate work when not logged in as root
index 86832e0d225d24013a726c0dd595db9a19e8730f..e03e1572e6716f8580e546ff0db85a0732a12601 100755 (executable)
@@ -11,7 +11,8 @@ mv "$TESTDIR/$FROB" "$TESTDIR/$FROB.bak"
 echo "this is a bad file" > "$TESTDIR/$FROB"
 
 # attempt an upgrade, this will fail
-TMPTESTDIR=`! wizard upgrade "$TESTDIR"`
+RESULT=`! wizard upgrade "$TESTDIR"`
+TMPTESTDIR=`echo "$RESULT" | awk '{print $2}'`
 
 # resolve the upgrade
 mv -f "$TESTDIR/$FROB.bak" "$TMPTESTDIR/$FROB"
index 41dec2076076ca9350889e15f4e7f76bd38f028b..91c74021290b31abc2359e97598ea47f1bf2aa62 100644 (file)
@@ -61,9 +61,9 @@ def main(argv, baton):
                     logging.info("[%04d] Skipped already upgraded %s" % (i, d.location))
                 elif e.name == "MergeFailed":
                     seen.add(d.location)
-                    tmpdir = e.stdout.rstrip()
-                    logging.warning("[%04d] Merge failed: resolve at [%s], source at [%s]" % (i, tmpdir, d.location))
-                    report.merge.write("[%04d] %s %s\n" % (i, tmpdir, d.location))
+                    conflicts, _, tmpdir = e.stdout.rstrip().partition(" ")
+                    logging.warning("[%04d] Conflicts in %d files: resolve at [%s], source at [%s]" % (i, int(conflicts), tmpdir, d.location))
+                    report.merge.write("[%04d] %s %d %s\n" % (i, tmpdir, int(conflicts), d.location))
                     fails['merge'] += 1
                 else:
                     name = e.name
index e7dab134a3dec33d5a5a7c4d875928fd8756cfc1..94af4f674d876d4e5818729483d2d53d5b3af536 100644 (file)
@@ -210,7 +210,9 @@ def perform_merge(sh, repo, d, version, use_shm):
     sh.call("git", "checkout", user_virtual_commit, "--")
     try:
         sh.call("git", "merge", next_virtual_commit)
-    except shell.CallError:
+    except shell.CallError as e:
+        conflicts = e.stderr.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
         curdir = os.getcwd()
@@ -218,6 +220,7 @@ def perform_merge(sh, repo, d, version, use_shm):
             logging.info("Resolved conflicts with application specific knowledge")
             sh.call("git", "commit", "-a", "-m", "merge")
             return
+        # XXX: Maybe should recalculate conflicts
         logging.info("Conflict info:\n" + sh.eval("git", "diff"))
         if use_shm:
             # Keeping all of our autoinstalls in shared memory is
@@ -230,16 +233,16 @@ def perform_merge(sh, repo, d, version, use_shm):
             shutil.move(curdir, newdir)
             shutil.rmtree(os.path.dirname(curdir))
             curdir = os.path.join(newdir, "repo")
-        print curdir
+        print "%d %s" % (conflicts, curdir)
         raise MergeFailed
 
 def parse_args(argv, baton):
     usage = """usage: %prog upgrade [ARGS] [DIR]
 
 Upgrades an autoinstall to the latest version.  This involves
-updating files and running .scripts/update.
-
-WARNING: This is still experimental."""
+updating files and running .scripts/update.  If the merge fails,
+this program will write the number of conflicts and the directory
+of the conflicted working tree to stdout, separated by a space."""
     parser = command.WizardOptionParser(usage)
     parser.add_option("--dry-run", dest="dry_run", action="store_true",
             default=False, help="Prints would would be run without changing anything")