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);
}
}
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());
}
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));
}
Aggregations