Search in sources :

Example 1 with Label

use of com.intellij.history.Label in project intellij-community by JetBrains.

the class HistoryReverterToLabelTest method testRevertContentChangeOnlyForFile.

public void testRevertContentChangeOnlyForFile() throws Exception {
    VirtualFile f = createChildData(myRoot, "foo.txt");
    int modificationStamp1 = -1;
    setBinaryContent(f, new byte[] { 1 }, modificationStamp1, 1000, this);
    VirtualFile f2 = createChildData(myRoot, "foo2.txt");
    setBinaryContent(f, new byte[] { 1 }, modificationStamp1, 1000, this);
    final Label testLabel = LocalHistory.getInstance().putSystemLabel(myProject, "testLabel");
    int modificationStamp = -1;
    setBinaryContent(f, new byte[] { 2 }, modificationStamp, 2000, this);
    setBinaryContent(f2, new byte[] { 3 }, modificationStamp, 3000, this);
    revertToLabel(testLabel, f);
    f = myRoot.findChild("foo.txt");
    assertNotNull(f);
    assertEquals(1, f.contentsToByteArray()[0]);
    assertEquals(1000, f.getTimeStamp());
    f2 = myRoot.findChild("foo2.txt");
    assertNotNull(f2);
    assertEquals(3, f2.contentsToByteArray()[0]);
    assertEquals(3000, f2.getTimeStamp());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Label(com.intellij.history.Label)

Example 2 with Label

use of com.intellij.history.Label in project intellij-community by JetBrains.

the class HistoryReverterToLabelTest method testFileDeletionWithContent.

public void testFileDeletionWithContent() throws Exception {
    VirtualFile f = createChildData(myRoot, "foo.txt");
    final Label testLabel = LocalHistory.getInstance().putSystemLabel(myProject, "testLabel");
    setBinaryContent(f, new byte[] { 123 }, -1, 4000, this);
    delete(f);
    revertToLabel(testLabel, myRoot);
    f = myRoot.findChild("foo.txt");
    assertNotNull(f);
    assertEquals(0, f.contentsToByteArray().length);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Label(com.intellij.history.Label)

Example 3 with Label

use of com.intellij.history.Label in project intellij-community by JetBrains.

the class HistoryReverterToLabelTest method testParentAndChildRename.

public void testParentAndChildRename() throws Exception {
    VirtualFile dir = createChildDirectory(myRoot, "dir");
    VirtualFile f = createChildData(dir, "foo.txt");
    int modificationStamp = -1;
    setBinaryContent(f, new byte[] { 123 }, modificationStamp, 4000, this);
    final LocalHistory localHistory = LocalHistory.getInstance();
    final Label testLabel1 = localHistory.putSystemLabel(myProject, "testLabel");
    rename(dir, "dir2");
    final Label testLabel2 = localHistory.putSystemLabel(myProject, "testLabel");
    rename(f, "bar.txt");
    revertToLabel(testLabel2, f);
    assertNotNull(myRoot.findChild("dir2"));
    dir = myRoot.findChild("dir2");
    assert dir != null;
    assertNull(dir.findChild("bar.txt"));
    f = dir.findChild("foo.txt");
    assertNotNull(f);
    assertEquals(123, f.contentsToByteArray()[0]);
    assertEquals(4000, f.getTimeStamp());
    revertToLabel(testLabel1, myRoot);
    assertNull(myRoot.findChild("dir2"));
    dir = myRoot.findChild("dir");
    assert dir != null;
    assertNull(dir.findChild("bar.txt"));
    f = dir.findChild("foo.txt");
    assertNotNull(f);
    assertEquals(123, f.contentsToByteArray()[0]);
    assertEquals(4000, f.getTimeStamp());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Label(com.intellij.history.Label) LocalHistory(com.intellij.history.LocalHistory)

Example 4 with Label

use of com.intellij.history.Label in project intellij-community by JetBrains.

the class HistoryReverterToLabelTest method testFileDeletion.

public void testFileDeletion() throws Exception {
    VirtualFile f = createChildData(myRoot, "foo.txt");
    setBinaryContent(f, new byte[] { 123 }, -1, 4000, this);
    final Label testLabel = LocalHistory.getInstance().putSystemLabel(myProject, "testLabel");
    delete(f);
    revertToLabel(testLabel, myRoot);
    f = myRoot.findChild("foo.txt");
    assertNotNull(f);
    assertEquals(123, f.contentsToByteArray()[0]);
    assertEquals(4000, f.getTimeStamp());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Label(com.intellij.history.Label)

Example 5 with Label

use of com.intellij.history.Label in project intellij-community by JetBrains.

the class HistoryReverterToLabelTest method testPutLabelAndRevertInstantly.

public void testPutLabelAndRevertInstantly() throws Exception {
    VirtualFile f = createChildData(myRoot, "foo.txt");
    setBinaryContent(f, new byte[] { 123 }, -1, 4000, this);
    final Label testLabel = LocalHistory.getInstance().putSystemLabel(myProject, "testLabel");
    revertToLabel(testLabel, myRoot);
    f = myRoot.findChild("foo.txt");
    assertNotNull(f);
    assertEquals(123, f.contentsToByteArray()[0]);
    assertEquals(4000, f.getTimeStamp());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Label(com.intellij.history.Label)

Aggregations

Label (com.intellij.history.Label)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 Project (com.intellij.openapi.project.Project)2 GitRepository (git4idea.repo.GitRepository)2 LocalHistory (com.intellij.history.LocalHistory)1 AccessToken (com.intellij.openapi.application.AccessToken)1 ApplyPatchStatus (com.intellij.openapi.diff.impl.patch.ApplyPatchStatus)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 Pair (com.intellij.openapi.util.Pair)1 Ref (com.intellij.openapi.util.Ref)1 GitRevisionNumber (git4idea.GitRevisionNumber)1 GitRepositoryManager (git4idea.repo.GitRepositoryManager)1 GitUpdateResult (git4idea.update.GitUpdateResult)1 CalledInAwt (org.jetbrains.annotations.CalledInAwt)1 NotNull (org.jetbrains.annotations.NotNull)1