Search in sources :

Example 1 with HistoryDialogModel

use of com.intellij.history.integration.ui.models.HistoryDialogModel in project intellij-community by JetBrains.

the class LocalHistoryImpl method revertToLabel.

private void revertToLabel(@NotNull Project project, @NotNull VirtualFile f, @NotNull LabelImpl impl) throws LocalHistoryException {
    HistoryDialogModel dirHistoryModel = f.isDirectory() ? new DirectoryHistoryDialogModel(project, myGateway, myVcs, f) : new EntireFileHistoryDialogModel(project, myGateway, myVcs, f);
    int leftRev = findRevisionIndexToRevert(dirHistoryModel, impl);
    if (leftRev < 0) {
        throw new LocalHistoryException("Couldn't find label revision");
    }
    // we shouldn't revert because no changes found to revert;
    if (leftRev == 0)
        return;
    try {
        //-1 because we should revert all changes up to previous one, but not label-related.
        dirHistoryModel.selectRevisions(-1, leftRev - 1);
        dirHistoryModel.createReverter().revert();
    } catch (IOException e) {
        throw new LocalHistoryException(String.format("Couldn't revert %s to local history label.", f.getName()), e);
    }
}
Also used : EntireFileHistoryDialogModel(com.intellij.history.integration.ui.models.EntireFileHistoryDialogModel) DirectoryHistoryDialogModel(com.intellij.history.integration.ui.models.DirectoryHistoryDialogModel) EntireFileHistoryDialogModel(com.intellij.history.integration.ui.models.EntireFileHistoryDialogModel) DirectoryHistoryDialogModel(com.intellij.history.integration.ui.models.DirectoryHistoryDialogModel) HistoryDialogModel(com.intellij.history.integration.ui.models.HistoryDialogModel) IOException(java.io.IOException)

Example 2 with HistoryDialogModel

use of com.intellij.history.integration.ui.models.HistoryDialogModel in project intellij-community by JetBrains.

the class DirectoryHistoryDialogTest method testRevertion.

public void testRevertion() throws Exception {
    createChildData(myRoot, "f.txt");
    HistoryDialogModel m = createModelAndSelectRevision(0);
    m.createReverter().revert();
    assertNull(myRoot.findChild("f.txt"));
}
Also used : DirectoryHistoryDialogModel(com.intellij.history.integration.ui.models.DirectoryHistoryDialogModel) HistoryDialogModel(com.intellij.history.integration.ui.models.HistoryDialogModel)

Aggregations

DirectoryHistoryDialogModel (com.intellij.history.integration.ui.models.DirectoryHistoryDialogModel)2 HistoryDialogModel (com.intellij.history.integration.ui.models.HistoryDialogModel)2 EntireFileHistoryDialogModel (com.intellij.history.integration.ui.models.EntireFileHistoryDialogModel)1 IOException (java.io.IOException)1