use of com.intellij.openapi.vcs.diff.DiffProvider in project intellij-community by JetBrains.
the class VcsAnnotationLocalChangesListenerImpl method fromDiffProvider.
private VcsRevisionNumber fromDiffProvider(final VirtualFile vf) {
final VcsRoot vcsRoot = myVcsManager.getVcsRootObjectFor(vf);
DiffProvider diffProvider;
if (vcsRoot != null && vcsRoot.getVcs() != null && (diffProvider = vcsRoot.getVcs().getDiffProvider()) != null) {
return diffProvider.getCurrentRevision(vf);
}
return null;
}
use of com.intellij.openapi.vcs.diff.DiffProvider in project intellij-community by JetBrains.
the class VcsAnnotationCachedProxy method annotate.
@Override
public FileAnnotation annotate(final VirtualFile file) throws VcsException {
final DiffProvider diffProvider = myVcs.getDiffProvider();
final VcsRevisionNumber currentRevision = diffProvider.getCurrentRevision(file);
return annotate(file, currentRevision, true, new ThrowableComputable<FileAnnotation, VcsException>() {
@Override
public FileAnnotation compute() throws VcsException {
return myAnnotationProvider.annotate(file);
}
});
}
use of com.intellij.openapi.vcs.diff.DiffProvider in project intellij-community by JetBrains.
the class SelectAndCompareWithSelectedRevisionAction method actionPerformed.
@Override
protected void actionPerformed(@NotNull VcsContext vcsContext) {
final VirtualFile file = vcsContext.getSelectedFiles()[0];
final Project project = vcsContext.getProject();
final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
if (vcs == null) {
return;
}
RevisionSelector selector = vcs.getRevisionSelector();
final DiffProvider diffProvider = vcs.getDiffProvider();
if (selector != null) {
final VcsRevisionNumber vcsRevisionNumber = selector.selectNumber(file);
if (vcsRevisionNumber != null) {
DiffActionExecutor.showDiff(diffProvider, vcsRevisionNumber, file, project, VcsBackgroundableActions.COMPARE_WITH);
}
}
}
use of com.intellij.openapi.vcs.diff.DiffProvider in project intellij-community by JetBrains.
the class AbstractShowDiffAction method actionPerformed.
@Override
protected void actionPerformed(@NotNull VcsContext vcsContext) {
Project project = assertNotNull(vcsContext.getProject());
if (!ChangeListManager.getInstance(project).isFreezedWithNotification("Can not " + vcsContext.getActionName() + " now")) {
VirtualFile file = vcsContext.getSelectedFiles()[0];
AbstractVcs vcs = assertNotNull(ChangesUtil.getVcsForFile(file, project));
DiffProvider provider = assertNotNull(vcs.getDiffProvider());
getExecutor(provider, file, project).showDiff();
}
}
use of com.intellij.openapi.vcs.diff.DiffProvider in project intellij-community by JetBrains.
the class DefaultPatchBaseVersionProvider method getBaseVersionContent.
public void getBaseVersionContent(final FilePath filePath, final Processor<CharSequence> processor, final List<String> warnings) throws VcsException {
if (myVcs == null) {
return;
}
final VcsHistoryProvider historyProvider = myVcs.getVcsHistoryProvider();
if (historyProvider == null)
return;
VcsRevisionNumber revision = null;
if (myRevisionPattern != null) {
final Matcher matcher = myRevisionPattern.matcher(myVersionId);
if (matcher.find()) {
revision = myVcs.parseRevisionNumber(matcher.group(1), filePath);
final VcsRevisionNumber finalRevision = revision;
final Boolean[] loadedExactRevision = new Boolean[1];
if (historyProvider instanceof VcsBaseRevisionAdviser) {
final boolean success = VcsUtil.runVcsProcessWithProgress(new VcsRunnable() {
public void run() throws VcsException {
loadedExactRevision[0] = ((VcsBaseRevisionAdviser) historyProvider).getBaseVersionContent(filePath, processor, finalRevision.asString(), warnings);
}
}, VcsBundle.message("progress.text2.loading.revision", revision.asString()), true, myProject);
// was cancelled
if (!success)
return;
} else {
// use diff provider
final DiffProvider diffProvider = myVcs.getDiffProvider();
if (diffProvider != null && filePath.getVirtualFile() != null) {
final ContentRevision fileContent = diffProvider.createFileContent(finalRevision, filePath.getVirtualFile());
final boolean success = VcsUtil.runVcsProcessWithProgress(new VcsRunnable() {
public void run() throws VcsException {
loadedExactRevision[0] = !processor.process(fileContent.getContent());
}
}, VcsBundle.message("progress.text2.loading.revision", revision.asString()), true, myProject);
// was cancelled
if (!success)
return;
}
}
if (Boolean.TRUE.equals(loadedExactRevision[0]))
return;
}
}
Date versionDate = null;
if (revision == null) {
try {
final Matcher tsMatcher = ourTsPattern.matcher(myVersionId);
if (tsMatcher.find()) {
final Long fromTsPattern = getFromTsPattern();
if (fromTsPattern == null)
return;
versionDate = new Date(fromTsPattern);
} else {
versionDate = new Date(myVersionId);
}
} catch (IllegalArgumentException ex) {
return;
}
}
try {
final Ref<VcsHistorySession> ref = new Ref<>();
boolean result = VcsUtil.runVcsProcessWithProgress(new VcsRunnable() {
public void run() throws VcsException {
ref.set(historyProvider.createSessionFor(filePath));
}
}, VcsBundle.message("loading.file.history.progress"), true, myProject);
//if not found or cancelled
if (ref.isNull() || !result)
return;
final VcsHistorySession session = ref.get();
final List<VcsFileRevision> list = session.getRevisionList();
if (list == null)
return;
for (VcsFileRevision fileRevision : list) {
boolean found;
if (revision != null) {
found = fileRevision.getRevisionNumber().compareTo(revision) <= 0;
} else {
final Date date = fileRevision instanceof VcsFileRevisionDvcsSpecific ? ((VcsFileRevisionDvcsSpecific) fileRevision).getDateForRevisionsOrdering() : fileRevision.getRevisionDate();
found = (date != null) && (date.before(versionDate) || date.equals(versionDate));
}
if (found) {
fileRevision.loadContent();
processor.process(LoadTextUtil.getTextByBinaryPresentation(fileRevision.getContent(), myFile, false, false));
// TODO: try to download more than one version
break;
}
}
} catch (IOException e) {
LOG.error(e);
}
}
Aggregations