@Override
public int perform() {
ProjectContext context;
String toProjectSpace;
RepositoryExpression toRepoEx, fromRepoEx;
Repository toRepo;
try {
context = AppContext.RUN.contextFactory.makeProjectContext(options.configFilename);
toRepoEx = Parser.parseRepositoryExpression(options.toRepository);
fromRepoEx = Parser.parseRepositoryExpression(options.fromRepository);
toRepo = context.repositories.get(toRepoEx.getRepositoryName());
if (toRepo == null) {
AppContext.RUN.ui.error("No repository " + toRepoEx.getRepositoryName());
return 1;
}
toProjectSpace = context.config.getRepositoryConfigs().get(toRepoEx.getRepositoryName())
.getProjectSpace();
} catch (ParseError e) {
AppContext.RUN.ui.error(e, "Couldn't parse expression");
return 1;
} catch (InvalidProject e) {
AppContext.RUN.ui.error(e, "Couldn't create project");
return 1;
}
List<Revision> revs = Revision.fromRepositoryExpression(fromRepoEx, context);
Codebase c;
try {
c = new RepositoryExpression(fromRepoEx.getRepositoryName())
.atRevision(revs.get(0).revId)
.translateTo(toProjectSpace)
.createCodebase(context);
} catch (CodebaseCreationError e) {
AppContext.RUN.ui.error(e, "Error creating codebase");
return 1;
}
Writer destination;
try {
destination = toRepoEx.createWriter(context);
} catch (WritingError e) {
AppContext.RUN.ui.error(e, "Error writing to repo");
return 1;
}