Search in sources :

Example 1 with LocalHistory

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

the class SvnTreeConflictResolver method resolveSelectTheirsFull.

public void resolveSelectTheirsFull() throws VcsException {
    final LocalHistory localHistory = LocalHistory.getInstance();
    String pathPresentation = TreeConflictRefreshablePanel.filePath(myPath);
    localHistory.putSystemLabel(myVcs.getProject(), "Before accepting theirs for " + pathPresentation);
    try {
        updateToTheirsFull();
        pathDirty(myPath);
        revertAdditional();
    } finally {
        localHistory.putSystemLabel(myVcs.getProject(), "After accepting theirs for " + pathPresentation);
    }
}
Also used : LocalHistory(com.intellij.history.LocalHistory)

Example 2 with LocalHistory

use of com.intellij.history.LocalHistory 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 3 with LocalHistory

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

the class SrcFileAnnotator method doGetLineMapping.

@Nullable
private SoftReference<TIntIntHashMap> doGetLineMapping(final long date, boolean oldToNew, MyEditorBean editorBean) {
    VirtualFile virtualFile = editorBean.getVFile();
    final byte[] oldContent;
    synchronized (LOCK) {
        if (myOldContent == null) {
            if (ApplicationManager.getApplication().isDispatchThread())
                return null;
            final LocalHistory localHistory = LocalHistory.getInstance();
            byte[] byteContent = localHistory.getByteContent(virtualFile, new FileRevisionTimestampComparator() {

                public boolean isSuitable(long revisionTimestamp) {
                    return revisionTimestamp < date;
                }
            });
            if (byteContent == null && virtualFile.getTimeStamp() > date) {
                byteContent = loadFromVersionControl(date, virtualFile);
            }
            myOldContent = new SoftReference<>(byteContent);
        }
        oldContent = myOldContent.get();
    }
    if (oldContent == null)
        return null;
    String[] coveredLines = getCoveredLines(oldContent, virtualFile);
    final Document document = editorBean.getDocument();
    if (document == null)
        return null;
    String[] currentLines = getUpToDateLines(document);
    String[] oldLines = oldToNew ? coveredLines : currentLines;
    String[] newLines = oldToNew ? currentLines : coveredLines;
    Diff.Change change;
    try {
        change = Diff.buildChanges(oldLines, newLines);
    } catch (FilesTooBigForDiffException e) {
        LOG.info(e);
        return null;
    }
    return new SoftReference<>(getCoverageVersionToCurrentLineMapping(change, oldLines.length));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilesTooBigForDiffException(com.intellij.util.diff.FilesTooBigForDiffException) Diff(com.intellij.util.diff.Diff) FileRevisionTimestampComparator(com.intellij.history.FileRevisionTimestampComparator) Document(com.intellij.openapi.editor.Document) SoftReference(com.intellij.reference.SoftReference) LocalHistory(com.intellij.history.LocalHistory) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

LocalHistory (com.intellij.history.LocalHistory)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 FileRevisionTimestampComparator (com.intellij.history.FileRevisionTimestampComparator)1 Label (com.intellij.history.Label)1 Document (com.intellij.openapi.editor.Document)1 SoftReference (com.intellij.reference.SoftReference)1 Diff (com.intellij.util.diff.Diff)1 FilesTooBigForDiffException (com.intellij.util.diff.FilesTooBigForDiffException)1 Nullable (org.jetbrains.annotations.Nullable)1