Search in sources :

Example 1 with DirectoryHistoryDialogModel

use of com.intellij.history.integration.ui.models.DirectoryHistoryDialogModel 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 DirectoryHistoryDialogModel

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

the class DirectoryHistoryDialogTest method testSelectionRevertion.

public void testSelectionRevertion() throws Exception {
    createChildData(myRoot, "f1.txt");
    createChildData(myRoot, "f2.txt");
    DirectoryHistoryDialogModel m = createModelAndSelectRevision(1);
    DirectoryChange c = (DirectoryChange) m.getChanges().get(0);
    m.createRevisionReverter(Collections.singletonList(c.getDifference())).revert();
    assertNull(myRoot.findChild("f1.txt"));
    assertNotNull(myRoot.findChild("f2.txt"));
}
Also used : DirectoryHistoryDialogModel(com.intellij.history.integration.ui.models.DirectoryHistoryDialogModel) DirectoryChange(com.intellij.history.integration.ui.views.DirectoryChange)

Example 3 with DirectoryHistoryDialogModel

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

the class DirectoryHistoryDialogTest method createModelAndSelectRevisions.

private DirectoryHistoryDialogModel createModelAndSelectRevisions(int first, int second) {
    DirectoryHistoryDialogModel m = new DirectoryHistoryDialogModel(myProject, myGateway, getVcs(), myRoot);
    m.selectRevisions(first, second);
    return m;
}
Also used : DirectoryHistoryDialogModel(com.intellij.history.integration.ui.models.DirectoryHistoryDialogModel)

Example 4 with DirectoryHistoryDialogModel

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

the class DirectoryHistoryDialogPatchCreationTest method testPatchCreation.

public void testPatchCreation() throws Exception {
    DirectoryHistoryDialogModel m = new DirectoryHistoryDialogModel(myProject, myGateway, getVcs(), myRoot);
    m.clearRevisions();
    createChildDataWithContent(myRoot, "f1.txt");
    createChildDataWithContent(myRoot, "f2.txt");
    createChildDataWithContent(myRoot, "f3.txt");
    assertSize(6, m.getRevisions());
    m.selectRevisions(0, 5);
    m.createPatch(patchFilePath, myProject.getBasePath(), false, Charset.defaultCharset());
    clearRoot();
    applyPatch();
    assertNotNull(myRoot.findChild("f1.txt"));
    assertNotNull(myRoot.findChild("f2.txt"));
    assertNull(myRoot.findChild("f3.txt"));
}
Also used : DirectoryHistoryDialogModel(com.intellij.history.integration.ui.models.DirectoryHistoryDialogModel)

Aggregations

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