- 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
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
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()
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
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")