use of org.archicontribs.modelrepository.grafico.MergeConflictHandler in project archi-modelrepository-plugin by archi-contribs.
the class RevertCommitAction method run.
@Override
public void run() {
// Offer to save the model if open and dirty
// We need to do this to keep grafico and temp files in sync
IArchimateModel model = getRepository().locateModel();
if (model != null && IEditorModelManager.INSTANCE.isModelDirty(model)) {
if (!offerToSaveModel(model)) {
return;
}
}
// Do the Grafico Export first
try {
getRepository().exportModelToGraficoFiles();
} catch (IOException ex) {
displayErrorDialog(Messages.RevertCommitAction_0, ex);
return;
}
// Then offer to Commit
try {
if (getRepository().hasChangesToCommit()) {
if (!offerToCommitChanges()) {
return;
}
}
} catch (IOException | GitAPIException ex) {
displayErrorDialog(Messages.RevertCommitAction_3, ex);
return;
}
// Revert
try (Git git = Git.open(getRepository().getLocalRepositoryFolder())) {
RevertCommand revertCommand = doRevertCommand(git);
MergeResult failingResult = revertCommand.getFailingResult();
if (failingResult != null) {
MergeConflictHandler handler = new MergeConflictHandler(failingResult, getRepository(), fWindow.getShell());
boolean result = handler.checkForMergeConflicts();
if (result) {
handler.mergeAndCommit(Messages.RevertCommitAction_4, false);
} else {
// User cancelled - we assume user has committed all changes so we can reset
handler.resetToLocalState();
}
} else {
new GraficoModelLoader(getRepository()).loadModel();
}
// Save the checksum
getRepository().saveChecksum();
notifyChangeListeners(IRepositoryListener.HISTORY_CHANGED);
} catch (IOException | GitAPIException ex) {
displayErrorDialog(Messages.RevertCommitAction_1, ex);
}
}
Aggregations