Search in sources :

Example 11 with Entry

use of com.intellij.history.core.tree.Entry in project intellij-community by JetBrains.

the class StreamTest method testDeleteChange.

@Test
public void testDeleteChange() throws IOException {
    DirectoryEntry dir = new DirectoryEntry("dir");
    dir.addChild(new FileEntry("file", new StoredContent(333), -1, false));
    dir.addChild(new DirectoryEntry("subDir"));
    Change c = new DeleteChange(nextId(), "entry", dir);
    StreamUtil.writeChange(os, c);
    Change read = StreamUtil.readChange(is);
    assertEquals(DeleteChange.class, read.getClass());
    DeleteChange result = (DeleteChange) read;
    assertEquals("entry", result.getPath());
    Entry e = result.getDeletedEntry();
    assertEquals(DirectoryEntry.class, e.getClass());
    assertEquals("dir", e.getName());
    assertEquals(2, e.getChildren().size());
    assertEquals("dir/file", e.getChildren().get(0).getPath());
    assertEquals("dir/subDir", e.getChildren().get(1).getPath());
}
Also used : DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) FileEntry(com.intellij.history.core.tree.FileEntry) FileEntry(com.intellij.history.core.tree.FileEntry) StoredContent(com.intellij.history.core.StoredContent) DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Test(org.junit.Test)

Example 12 with Entry

use of com.intellij.history.core.tree.Entry in project intellij-community by JetBrains.

the class ChangesRevertingTest method testChangingFileContent.

@Test
public void testChangingFileContent() {
    createFile(root, "file", "old content", 11L, false);
    StructuralChange c = changeContent(root, "file", "new content", 22L);
    c.revertOn(root, true);
    Entry e = root.getEntry("file");
    assertContent("old content", e.getContent());
    assertEquals(11L, e.getTimestamp());
}
Also used : Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) Test(org.junit.Test)

Example 13 with Entry

use of com.intellij.history.core.tree.Entry in project intellij-community by JetBrains.

the class RootEntryDirectoriesTest method testCeatingDirectory.

@Test
public void testCeatingDirectory() {
    assertFalse(root.hasEntry("dir"));
    createDirectory(root, "dir");
    assertTrue(root.hasEntry("dir"));
    Entry e = root.getEntry("dir");
    assertEquals(DirectoryEntry.class, e.getClass());
    assertTrue(e.getChildren().isEmpty());
}
Also used : DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) Test(org.junit.Test)

Example 14 with Entry

use of com.intellij.history.core.tree.Entry in project intellij-community by JetBrains.

the class RootEntryDirectoriesTest method testMovingFilesBetweenDirectories.

@Test
public void testMovingFilesBetweenDirectories() {
    createDirectory(root, "dir1");
    createDirectory(root, "dir2");
    createFile(root, "dir1/file", "content");
    move(root, "dir1/file", "dir2");
    assertTrue(root.hasEntry("dir2/file"));
    assertFalse(root.hasEntry("dir1/file"));
    Entry e = root.getEntry("dir2/file");
    assertContent("content", e.getContent());
}
Also used : DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) Test(org.junit.Test)

Example 15 with Entry

use of com.intellij.history.core.tree.Entry in project intellij-community by JetBrains.

the class StreamTest method testDoesNotWriteEntryParent.

@Test
public void testDoesNotWriteEntryParent() throws IOException {
    Entry parent = new DirectoryEntry("");
    Entry e = new FileEntry("", new StoredContent(333), -1, false);
    parent.addChild(e);
    StreamUtil.writeEntry(os, e);
    assertNull(StreamUtil.readEntry(is).getParent());
}
Also used : DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) FileEntry(com.intellij.history.core.tree.FileEntry) FileEntry(com.intellij.history.core.tree.FileEntry) StoredContent(com.intellij.history.core.StoredContent) DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Test(org.junit.Test)

Aggregations

Entry (com.intellij.history.core.tree.Entry)37 RootEntry (com.intellij.history.core.tree.RootEntry)25 FileEntry (com.intellij.history.core.tree.FileEntry)12 Test (org.junit.Test)12 DirectoryEntry (com.intellij.history.core.tree.DirectoryEntry)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 Revision (com.intellij.history.core.revisions.Revision)5 StoredContent (com.intellij.history.core.StoredContent)4 Difference (com.intellij.history.core.revisions.Difference)3 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)2 ByteContent (com.intellij.history.ByteContent)1 Content (com.intellij.history.core.Content)1 Change (com.intellij.history.core.changes.Change)1 DeleteChange (com.intellij.history.core.changes.DeleteChange)1 StructuralChange (com.intellij.history.core.changes.StructuralChange)1 SelectionCalculator (com.intellij.history.integration.ui.models.SelectionCalculator)1 VirtualFileSystemEntry (com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry)1 THashSet (gnu.trove.THashSet)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1