db = FileDb.makeDbFromFile(dbFile.getAbsolutePath());
} else {
db = new FileDb(new DbStorage());
}
RepositoryExpression repoEx1 = null, repoEx2 = null;
try {
repoEx1 = Parser.parseRepositoryExpression(options.repo1);
repoEx2 = Parser.parseRepositoryExpression(options.repo2);
} catch (ParseError e) {
AppContext.RUN.ui.error(
e, "Couldn't parse " + (repoEx1 == null ? options.repo1 : options.repo2));
return 1;
}
if (repoEx1.getOption("revision") == null || repoEx2.getOption("revision") == null) {
throw new MoeProblem("You must specify a revision in each repo, e.g. 'internal(revision=2)'");
}
// Sanity check: make sure the given repos and revisions exist.
Repository repo1 = context.repositories.get(repoEx1.getRepositoryName());
Repository repo2 = context.repositories.get(repoEx2.getRepositoryName());
if (repo1 == null || repo2 == null) {
AppContext.RUN.ui.error(
"Unknown repository: " +
(repo1 == null ? repoEx1.getRepositoryName() : repoEx2.getRepositoryName()));
return 1;
}
Revision realRev1 = repo1.revisionHistory.findHighestRevision(repoEx1.getOption("revision"));
Revision realRev2 = repo2.revisionHistory.findHighestRevision(repoEx2.getOption("revision"));
Equivalence newEq = new Equivalence(realRev1, realRev2);
db.noteEquivalence(newEq);
db.writeToLocation(options.dbLocation);