*/
public static List<Migration> determineMigrations(
ProjectContext context, MigrationConfig migrationConfig, Db db) {
Repository fromRepo = context.repositories.get(migrationConfig.getFromRepository());
EquivalenceMatchResult equivMatch = fromRepo.revisionHistory.findRevisions(
null, // Start at head.
new EquivalenceMatcher(migrationConfig.getToRepository(), db));
// TODO(user): Decide whether to migrate linear or graph history here. Once DVCS Writers
// support writing a graph of Revisions, we'll need to opt for linear or graph history based
// on the MigrationConfig (e.g. whether or not the destination repo is linear-only).
List<Revision> revisionsSinceEquivalence =
Lists.reverse(equivMatch.getRevisionsSinceEquivalence().getLinearHistory());
if (revisionsSinceEquivalence.isEmpty()) {
AppContext.RUN.ui.info("No revisions found since last equivalence for migration '"
+ migrationConfig.getName() + "'");
return ImmutableList.of();
}
// TODO(user): Figure out how to report all equivalences.
Equivalence lastEq = equivMatch.getEquivalences().get(0);
AppContext.RUN.ui.info(String.format("Found %d revisions in %s since equivalence (%s): %s",
revisionsSinceEquivalence.size(),
migrationConfig.getFromRepository(),
lastEq,
Joiner.on(", ").join(revisionsSinceEquivalence)));