use of com.intellij.openapi.vcs.annotate.FileAnnotation in project intellij-community by JetBrains.
the class SvnAnnotationIsClosedTest method testNotClosedByRenaming.
@Test
public void testNotClosedByRenaming() throws Exception {
final SubTree tree = new SubTree(myWorkingCopyDir);
checkin();
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3\n4\n");
checkin();
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3**\n4\n");
checkin();
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3**\n4++\n");
// not closed on typing
Assert.assertFalse(myIsClosed);
VcsTestUtil.renameFileInCommand(myProject, tree.myS1File, "5364536");
// not closed on typing
Assert.assertFalse(myIsClosed);
myDirtyScopeManager.markEverythingDirty();
myChangeListManager.ensureUpToDate(false);
final Change change = myChangeListManager.getChange(tree.myS1File);
Assert.assertNotNull(change);
}
use of com.intellij.openapi.vcs.annotate.FileAnnotation in project intellij-community by JetBrains.
the class SvnAnnotationIsClosedTest method testClosedByCommitFromIdea.
@Test
public void testClosedByCommitFromIdea() throws Exception {
final SubTree tree = new SubTree(myWorkingCopyDir);
checkin();
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3\n4\n");
checkin();
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3**\n4\n");
checkin();
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3**\n4++\n");
// not closed on typing
Assert.assertFalse(myIsClosed);
myDirtyScopeManager.markEverythingDirty();
myChangeListManager.ensureUpToDate(false);
final Change change = myChangeListManager.getChange(tree.myS1File);
Assert.assertNotNull(change);
final List<VcsException> exceptions = myVcs.getCheckinEnvironment().commit(Collections.singletonList(change), "commit");
Assert.assertTrue(exceptions == null || exceptions.isEmpty());
myDirtyScopeManager.fileDirty(tree.myS1File);
myChangeListManager.ensureUpToDate(false);
// wait for after-events like annotations recalculation
myChangeListManager.ensureUpToDate(false);
// zipper updater
sleep(100);
Assert.assertTrue(myIsClosed);
}
use of com.intellij.openapi.vcs.annotate.FileAnnotation in project intellij-community by JetBrains.
the class SvnAnnotationIsClosedTest method testClosedChangedByUpdateInIdea.
@Test
public void testClosedChangedByUpdateInIdea() throws Exception {
final SubTree tree = new SubTree(myWorkingCopyDir);
//#1
checkin();
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3\n4\n");
//#2
checkin();
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3**\n4\n");
//#3
checkin();
// take #2
runInAndVerifyIgnoreOutput("up", "-r", "2");
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1+\n2\n3\n4\n");
myDirtyScopeManager.markEverythingDirty();
myChangeListManager.ensureUpToDate(false);
Assert.assertFalse(myIsClosed);
ProjectLevelVcsManagerEx.getInstanceEx(myProject).getOptions(VcsConfiguration.StandardOption.UPDATE).setValue(false);
final CommonUpdateProjectAction action = new CommonUpdateProjectAction();
action.getTemplatePresentation().setText("1");
action.actionPerformed(new AnActionEvent(null, dataId -> {
if (CommonDataKeys.PROJECT.is(dataId)) {
return myProject;
}
return null;
}, "test", new Presentation(), ActionManager.getInstance(), 0));
myChangeListManager.ensureUpToDate(false);
// wait for after-events like annotations recalculation
myChangeListManager.ensureUpToDate(false);
// zipper updater
sleep(100);
Assert.assertTrue(myIsClosed);
}
use of com.intellij.openapi.vcs.annotate.FileAnnotation in project intellij-community by JetBrains.
the class VcsAnnotationLocalChangesListenerImpl method processUnderFile.
private void processUnderFile(VirtualFile file) {
final MultiMap<VirtualFile, FileAnnotation> annotations = new MultiMap<>();
synchronized (myLock) {
for (VirtualFile virtualFile : myFileAnnotationMap.keySet()) {
if (VfsUtilCore.isAncestor(file, virtualFile, true)) {
final Collection<FileAnnotation> values = myFileAnnotationMap.get(virtualFile);
for (FileAnnotation value : values) {
annotations.putValue(virtualFile, value);
}
}
}
}
if (!annotations.isEmpty()) {
for (Map.Entry<VirtualFile, Collection<FileAnnotation>> entry : annotations.entrySet()) {
final VirtualFile key = entry.getKey();
final VcsRevisionNumber number = fromDiffProvider(key);
if (number == null)
continue;
final Collection<FileAnnotation> fileAnnotations = entry.getValue();
for (FileAnnotation annotation : fileAnnotations) {
if (annotation.isBaseRevisionChanged(number)) {
annotation.close();
}
}
}
}
}
use of com.intellij.openapi.vcs.annotate.FileAnnotation in project intellij-community by JetBrains.
the class AnnotateVcsVirtualFileAction method doAnnotate.
private static void doAnnotate(@NotNull final Project project, @NotNull final Editor editor, @NotNull final VirtualFile file) {
final AnnotationData data = extractData(project, file);
assert data != null;
final AnnotationProviderEx provider = (AnnotationProviderEx) data.vcs.getAnnotationProvider();
assert provider != null;
final Ref<FileAnnotation> fileAnnotationRef = new Ref<>();
final Ref<VcsException> exceptionRef = new Ref<>();
VcsAnnotateUtil.getBackgroundableLock(project, file).lock();
final Task.Backgroundable annotateTask = new Task.Backgroundable(project, VcsBundle.message("retrieving.annotations"), true) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
try {
fileAnnotationRef.set(provider.annotate(data.filePath, data.revisionNumber));
} catch (VcsException e) {
exceptionRef.set(e);
} catch (ProcessCanceledException pce) {
throw pce;
} catch (Throwable t) {
exceptionRef.set(new VcsException(t));
}
}
@Override
public void onCancel() {
onSuccess();
}
@Override
public void onSuccess() {
VcsAnnotateUtil.getBackgroundableLock(project, file).unlock();
if (!exceptionRef.isNull()) {
LOG.warn(exceptionRef.get());
AbstractVcsHelper.getInstance(project).showErrors(Collections.singletonList(exceptionRef.get()), VcsBundle.message("message.title.annotate"));
}
if (!fileAnnotationRef.isNull()) {
AnnotateToggleAction.doAnnotate(editor, project, null, fileAnnotationRef.get(), data.vcs);
}
}
};
ProgressManager.getInstance().run(annotateTask);
}
Aggregations