Search in sources :

Example 11 with Revision

use of com.intellij.history.core.revisions.Revision in project intellij-community by JetBrains.

the class RevisionsAndDiffsTest method testRevisionForRestoredDirectoryWithRestoreChildren.

public void testRevisionForRestoredDirectoryWithRestoreChildren() throws IOException {
    VirtualFile dir = createDirectory("dir");
    createFile("dir/f.txt");
    delete(dir);
    getVcs().beginChangeSet();
    dir = createDirectory("dir");
    VirtualFile f = createFile("dir/f.txt");
    getVcs().endChangeSet(null);
    List<Revision> rr = getRevisionsFor(dir);
    assertEquals(5, rr.size());
    assertEquals(1, rr.get(0).findEntry().getChildren().size());
    assertNull(rr.get(1).findEntry());
    assertEquals(1, rr.get(2).findEntry().getChildren().size());
    assertEquals(0, rr.get(3).findEntry().getChildren().size());
    assertEquals(4, getRevisionsFor(f).size());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision)

Example 12 with Revision

use of com.intellij.history.core.revisions.Revision in project intellij-community by JetBrains.

the class RevisionsAndDiffsTest method testDifferenceForDirectory.

public void testDifferenceForDirectory() throws IOException {
    VirtualFile dir = createDirectory("dir");
    VirtualFile f = createFile("dir/file.txt");
    List<Revision> rr = getRevisionsFor(dir);
    assertEquals(3, rr.size());
    Revision recent = rr.get(0);
    Revision prev = rr.get(1);
    List<Difference> dd = prev.getDifferencesWith(recent);
    assertEquals(1, dd.size());
    Difference d = dd.get(0);
    assertNull(d.getLeft());
    assertEquals("file.txt", d.getRight().getName());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision) Difference(com.intellij.history.core.revisions.Difference)

Example 13 with Revision

use of com.intellij.history.core.revisions.Revision in project intellij-community by JetBrains.

the class RevisionsAndDiffsTest method testNamedAndUnnamedCauseActions.

public void testNamedAndUnnamedCauseActions() throws Exception {
    getVcs().beginChangeSet();
    VirtualFile f = createFile("file.txt");
    getVcs().endChangeSet("name");
    setContent(f, "foo");
    List<Revision> rr = getRevisionsFor(f);
    assertEquals(3, rr.size());
    assertNull(rr.get(1).getChangeSetName());
    assertEquals("name", rr.get(2).getChangeSetName());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision)

Example 14 with Revision

use of com.intellij.history.core.revisions.Revision in project intellij-community by JetBrains.

the class RevisionsAndDiffsTest method testRevisionsTimestamp.

public void testRevisionsTimestamp() throws IOException {
    Clock.setTime(10);
    VirtualFile f = createFile("file1.txt");
    Clock.setTime(20);
    setContent(f, "a");
    Clock.setTime(30);
    setContent(f, "b");
    List<Revision> rr = getRevisionsFor(f);
    assertEquals(30L, rr.get(1).getTimestamp());
    assertEquals(20L, rr.get(2).getTimestamp());
    assertEquals(10L, rr.get(3).getTimestamp());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision)

Example 15 with Revision

use of com.intellij.history.core.revisions.Revision in project intellij-community by JetBrains.

the class FileListeningTest method testCreationAndDeletionOfUnversionedFile.

public void testCreationAndDeletionOfUnversionedFile() throws IOException {
    addExcludedDir(myRoot.getPath() + "/dir");
    Module m = createModule("foo");
    addContentRoot(m, myRoot.getPath() + "/dir/subDir");
    createFileExternally("dir/subDir/file.txt");
    LocalFileSystem.getInstance().refresh(false);
    FileUtil.delete(new File(myRoot.getPath() + "/dir"));
    LocalFileSystem.getInstance().refresh(false);
    createFileExternally("dir/subDir/file.txt");
    LocalFileSystem.getInstance().refresh(false);
    List<Revision> revs = getRevisionsFor(myRoot);
    assertEquals(4, revs.size());
    assertNotNull(revs.get(0).findEntry().findEntry("dir/subDir/file.txt"));
    assertNull(revs.get(1).findEntry().findEntry("dir/subDir/file.txt"));
    assertNotNull(revs.get(2).findEntry().findEntry("dir/subDir/file.txt"));
    assertNull(revs.get(3).findEntry().findEntry("dir/subDir/file.txt"));
}
Also used : Revision(com.intellij.history.core.revisions.Revision) Module(com.intellij.openapi.module.Module) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) File(java.io.File)

Aggregations

Revision (com.intellij.history.core.revisions.Revision)44 VirtualFile (com.intellij.openapi.vfs.VirtualFile)29 Difference (com.intellij.history.core.revisions.Difference)7 Test (org.junit.Test)6 Entry (com.intellij.history.core.tree.Entry)5 Block (com.intellij.diff.Block)4 LocalHistoryAction (com.intellij.history.LocalHistoryAction)3 ArrayList (java.util.ArrayList)3 Module (com.intellij.openapi.module.Module)2 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)2 File (java.io.File)2 ChangeRevision (com.intellij.history.core.revisions.ChangeRevision)1 RecentChange (com.intellij.history.core.revisions.RecentChange)1 DifferenceReverter (com.intellij.history.integration.revertion.DifferenceReverter)1 DirectoryChangeModel (com.intellij.history.integration.ui.models.DirectoryChangeModel)1 SelectionCalculator (com.intellij.history.integration.ui.models.SelectionCalculator)1 RunnableAdapter (com.intellij.history.utils.RunnableAdapter)1 Change (com.intellij.openapi.vcs.changes.Change)1 IOException (java.io.IOException)1 Date (java.util.Date)1