Search in sources :

Example 1 with Change

use of com.intellij.history.core.changes.Change in project intellij-community by JetBrains.

the class FileListeningTest method testDeletionDoesNotVersionIgnoredFilesRecursively.

public void testDeletionDoesNotVersionIgnoredFilesRecursively() throws Exception {
    String dir1 = createDirectoryExternally("dir");
    createFileExternally("dir/f.txt");
    createFileExternally("dir/f.class");
    createFileExternally("dir/subdir/f.txt");
    createDirectoryExternally("dir/subdir/subdir2");
    createFileExternally("dir/subdir/subdir2/f.txt");
    LocalFileSystem.getInstance().refresh(false);
    addExcludedDir(myRoot.getPath() + "/dir/subdir");
    addContentRoot(myRoot.getPath() + "/dir/subdir/subdir2");
    final VirtualFile vDir1 = LocalFileSystem.getInstance().findFileByPath(dir1);
    assertNotNull(dir1, vDir1);
    delete(vDir1);
    List<Change> changes = getVcs().getChangeListInTests().getChangesInTests().get(0).getChanges();
    assertEquals(1, changes.size());
    Entry e = ((DeleteChange) changes.get(0)).getDeletedEntry();
    final List<Entry> children = e.getChildren();
    sortEntries(children);
    assertEquals(2, children.size());
    assertEquals("f.txt", children.get(0).getName());
    assertEquals("subdir", children.get(1).getName());
    assertEquals(1, children.get(1).getChildren().size());
    assertEquals("subdir2", children.get(1).getChildren().get(0).getName());
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) Entry(com.intellij.history.core.tree.Entry) DeleteChange(com.intellij.history.core.changes.DeleteChange) DeleteChange(com.intellij.history.core.changes.DeleteChange) StructuralChange(com.intellij.history.core.changes.StructuralChange) Change(com.intellij.history.core.changes.Change)

Example 2 with Change

use of com.intellij.history.core.changes.Change in project intellij-community by JetBrains.

the class ChangeRange method revert.

public ChangeRange revert(ChangeRange reverse) throws IOException {
    final Ref<Long> first = new Ref<>();
    final Ref<Long> last = new Ref<>();
    LocalHistoryFacade.Listener l = new LocalHistoryFacade.Listener() {

        public void changeAdded(Change c) {
            if (first.isNull())
                first.set(c.getId());
            last.set(c.getId());
        }
    };
    myVcs.addListener(l, null);
    try {
        myVcs.accept(new UndoChangeRevertingVisitor(myGateway, myToChangeId, myFromChangeId));
    } catch (UndoChangeRevertingVisitor.RuntimeIOException e) {
        throw (IOException) e.getCause();
    } finally {
        myVcs.removeListener(l);
    }
    if (reverse != null) {
        if (first.isNull())
            first.set(reverse.myFromChangeId);
        if (last.isNull())
            last.set(reverse.myToChangeId);
    }
    return new ChangeRange(myGateway, myVcs, first.get(), last.get());
}
Also used : Ref(com.intellij.openapi.util.Ref) UndoChangeRevertingVisitor(com.intellij.history.integration.revertion.UndoChangeRevertingVisitor) LocalHistoryFacade(com.intellij.history.core.LocalHistoryFacade) Change(com.intellij.history.core.changes.Change)

Example 3 with Change

use of com.intellij.history.core.changes.Change in project intellij-community by JetBrains.

the class ByteContentRetriever method recordContentAndTimestamp.

private void recordContentAndTimestamp(ChangeSet c) {
    // todo what if the path is being changed during changes?
    for (Change each : c.getChanges()) {
        if (!(each instanceof ContentChange))
            continue;
        ContentChange cc = (ContentChange) each;
        if (!cc.affectsPath(myPath))
            continue;
        myCurrentFileTimestamp = cc.getOldTimestamp();
        myCurrentFileContent = cc.getOldContent();
    }
}
Also used : ContentChange(com.intellij.history.core.changes.ContentChange) ContentChange(com.intellij.history.core.changes.ContentChange) Change(com.intellij.history.core.changes.Change)

Example 4 with Change

use of com.intellij.history.core.changes.Change in project intellij-community by JetBrains.

the class FileListeningTest method testIgnoringFilesRecursively.

public void testIgnoringFilesRecursively() throws Exception {
    addExcludedDir(myRoot.getPath() + "/dir/subdir");
    addContentRoot(createModule("foo"), myRoot.getPath() + "/dir/subdir/subsubdir1");
    String dir = createDirectoryExternally("dir");
    String dir1_file = createFileExternally("dir/f.txt");
    createFileExternally("dir/f.class");
    createFileExternally("dir/subdir/f.txt");
    String subsubdir1 = createDirectoryExternally("dir/subdir/subsubdir1");
    String subsubdir1_file = createFileExternally("dir/subdir/subsubdir1/f.txt");
    createDirectoryExternally("dir/subdir/subsubdir2");
    createFileExternally("dir/subdir/subsubdir2/f.txt");
    myRoot.refresh(false, true);
    List<Change> changes = getVcs().getChangeListInTests().getChangesInTests().get(0).getChanges();
    List<String> actual = new SmartList<>();
    for (Change each : changes) {
        actual.add(((StructuralChange) each).getPath());
    }
    List<String> expected = new ArrayList<>(Arrays.asList(dir, subsubdir1, dir1_file, subsubdir1_file));
    Collections.sort(actual);
    Collections.sort(expected);
    assertOrderedEquals(actual, expected);
    // ignored folders should not be loaded in VFS
    assertEquals("dir\n" + " f.class\n" + " f.txt\n" + " subdir\n" + "  subsubdir1\n" + "   f.txt\n", buildDBFileStructure(myRoot, 0, new StringBuilder()).toString());
}
Also used : ArrayList(java.util.ArrayList) DeleteChange(com.intellij.history.core.changes.DeleteChange) StructuralChange(com.intellij.history.core.changes.StructuralChange) Change(com.intellij.history.core.changes.Change) SmartList(com.intellij.util.SmartList)

Aggregations

Change (com.intellij.history.core.changes.Change)4 DeleteChange (com.intellij.history.core.changes.DeleteChange)2 StructuralChange (com.intellij.history.core.changes.StructuralChange)2 LocalHistoryFacade (com.intellij.history.core.LocalHistoryFacade)1 ContentChange (com.intellij.history.core.changes.ContentChange)1 Entry (com.intellij.history.core.tree.Entry)1 UndoChangeRevertingVisitor (com.intellij.history.integration.revertion.UndoChangeRevertingVisitor)1 Ref (com.intellij.openapi.util.Ref)1 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)1 SmartList (com.intellij.util.SmartList)1 ArrayList (java.util.ArrayList)1