use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class RemoteRevisionsNumbersCache method getRevisionState.
/**
* Returns {@code true} if passed revision is up to date, comparing to latest repository revision.
*/
private boolean getRevisionState(final ContentRevision revision) {
if (revision != null) {
// TODO: Seems peg revision should also be tracked here.
final VcsRevisionNumber local = revision.getRevisionNumber();
final String path = revision.getFile().getPath();
final VcsRevisionNumber remote = getNumber(path);
return NOT_LOADED == remote || UNKNOWN == remote || local.compareTo(remote) >= 0;
}
return true;
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class RemoteRevisionsNumbersCache method plus.
public void plus(final Pair<String, AbstractVcs> pair) {
// does not support
if (pair.getSecond().getDiffProvider() == null)
return;
final String key = pair.getFirst();
final AbstractVcs newVcs = pair.getSecond();
final VirtualFile root = getRootForPath(key);
if (root == null)
return;
final VcsRoot vcsRoot = new VcsRoot(newVcs, root);
synchronized (myLock) {
final Pair<VcsRoot, VcsRevisionNumber> value = myData.get(key);
if (value == null) {
final LazyRefreshingSelfQueue<String> queue = getQueue(vcsRoot);
myData.put(key, Pair.create(vcsRoot, NOT_LOADED));
queue.addRequest(key);
} else if (!value.getFirst().equals(vcsRoot)) {
switchVcs(value.getFirst(), vcsRoot, key);
}
}
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber 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.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class HistoryIdColumn method getLineText.
@Override
public String getLineText(int line, Editor editor) {
if (!isAvailable())
return "";
final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(line);
if (revisionNumber != null) {
final Integer num = myHistoryIds.get(revisionNumber);
if (num != null) {
final String size = String.valueOf(myHistoryIds.size());
String value = num.toString();
while (value.length() < size.length()) {
value = " " + value;
}
return value;
}
}
return "";
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class ShowDiffFromAnnotation method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final int actualNumber = currentLine;
if (actualNumber < 0)
return;
final VcsRevisionNumber revisionNumber = myFileAnnotation.getLineRevisionNumber(actualNumber);
if (revisionNumber != null) {
final VcsException[] exc = new VcsException[1];
final List<Change> changes = new LinkedList<>();
final FilePath[] targetPath = new FilePath[1];
ProgressManager.getInstance().run(new Task.Backgroundable(myVcs.getProject(), "Loading revision " + revisionNumber.asString() + " contents", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
final CommittedChangesProvider provider = myVcs.getCommittedChangesProvider();
try {
final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(myFile, revisionNumber);
if (pair == null || pair.getFirst() == null) {
VcsBalloonProblemNotifier.showOverChangesView(myVcs.getProject(), "Can not load data for show diff", MessageType.ERROR);
return;
}
targetPath[0] = pair.getSecond() == null ? VcsUtil.getFilePath(myFile) : pair.getSecond();
final CommittedChangeList cl = pair.getFirst();
changes.addAll(cl.getChanges());
Collections.sort(changes, ChangesComparator.getInstance(true));
} catch (VcsException e1) {
exc[0] = e1;
}
}
@Override
public void onSuccess() {
if (exc[0] != null) {
VcsBalloonProblemNotifier.showOverChangesView(myVcs.getProject(), "Can not show diff: " + exc[0].getMessage(), MessageType.ERROR);
} else if (!changes.isEmpty()) {
int idx = findSelfInList(changes, targetPath[0]);
final ShowDiffContext context = new ShowDiffContext(DiffDialogHints.FRAME);
if (idx != -1) {
context.putChangeContext(changes.get(idx), DiffUserDataKeysEx.NAVIGATION_CONTEXT, createDiffNavigationContext(actualNumber));
}
if (ChangeListManager.getInstance(myVcs.getProject()).isFreezedWithNotification(null))
return;
ShowDiffAction.showDiffForChange(myVcs.getProject(), changes, idx, context);
}
}
});
}
}
Aggregations