use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class TabbedShowHistoryAction method actionPerformed.
@Override
protected void actionPerformed(@NotNull VcsContext context) {
Project project = assertNotNull(context.getProject());
Pair<FilePath, VirtualFile> pair = getPathAndParentFile(context);
FilePath path = assertNotNull(pair.first);
VirtualFile fileOrParent = assertNotNull(pair.second);
AbstractVcs vcs = assertNotNull(ChangesUtil.getVcsForFile(fileOrParent, project));
if (canShowNewFileHistory(project, path)) {
showNewFileHistory(project, path);
} else {
showOldFileHistory(project, vcs, path);
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class ChangeDiffRequestProducer method createContent.
@NotNull
public static DiffContent createContent(@Nullable Project project, @Nullable ContentRevision revision, @NotNull UserDataHolder context, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
try {
indicator.checkCanceled();
if (revision == null)
return DiffContentFactory.getInstance().createEmpty();
FilePath filePath = revision.getFile();
DiffContentFactoryEx contentFactory = DiffContentFactoryEx.getInstanceEx();
if (revision instanceof CurrentContentRevision) {
VirtualFile vFile = ((CurrentContentRevision) revision).getVirtualFile();
if (vFile == null)
throw new DiffRequestProducerException("Can't get current revision content");
return contentFactory.create(project, vFile);
}
if (revision instanceof BinaryContentRevision) {
byte[] content = ((BinaryContentRevision) revision).getBinaryContent();
if (content == null) {
throw new DiffRequestProducerException("Can't get binary revision content");
}
return contentFactory.createFromBytes(project, content, filePath);
}
if (revision instanceof ByteBackedContentRevision) {
byte[] revisionContent = ((ByteBackedContentRevision) revision).getContentAsBytes();
if (revisionContent == null)
throw new DiffRequestProducerException("Can't get revision content");
return contentFactory.createFromBytes(project, revisionContent, filePath);
} else {
String revisionContent = revision.getContent();
if (revisionContent == null)
throw new DiffRequestProducerException("Can't get revision content");
return contentFactory.create(project, revisionContent, filePath);
}
} catch (IOException | VcsException e) {
LOG.info(e);
throw new DiffRequestProducerException(e);
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class ChangeDiffRequestProducer method getRequestTitle.
@NotNull
public static String getRequestTitle(@NotNull Change change) {
ContentRevision bRev = change.getBeforeRevision();
ContentRevision aRev = change.getAfterRevision();
assert bRev != null || aRev != null;
if (bRev != null && aRev != null) {
FilePath bPath = bRev.getFile();
FilePath aPath = aRev.getFile();
if (bPath.equals(aPath)) {
return DiffRequestFactoryImpl.getContentTitle(bPath);
} else {
return DiffRequestFactoryImpl.getTitle(bPath, aPath, " -> ");
}
} else if (bRev != null) {
return DiffRequestFactoryImpl.getContentTitle(bRev.getFile());
} else {
return DiffRequestFactoryImpl.getContentTitle(aRev.getFile());
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class AbstractMissingFilesAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final List<FilePath> files = e.getData(ChangesListView.MISSING_FILES_DATA_KEY);
if (files == null)
return;
final ProgressManager progressManager = ProgressManager.getInstance();
final Runnable action = new Runnable() {
public void run() {
final List<VcsException> allExceptions = new ArrayList<>();
ChangesUtil.processFilePathsByVcs(project, files, (vcs, items) -> {
final List<VcsException> exceptions = processFiles(vcs, files);
if (exceptions != null) {
allExceptions.addAll(exceptions);
}
});
for (FilePath file : files) {
VcsDirtyScopeManager.getInstance(project).fileDirty(file);
}
ChangesViewManager.getInstance(project).scheduleRefresh();
if (allExceptions.size() > 0) {
AbstractVcsHelper.getInstance(project).showErrors(allExceptions, "VCS Errors");
}
}
};
if (synchronously()) {
action.run();
} else {
progressManager.runProcessWithProgressSynchronously(action, getName(), true, project);
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class ChangeListsIndexes method getDelta.
/**
* this method is called after each local changes refresh and collects all:
* - paths that are new in local changes
* - paths that are no more changed locally
* - paths that were and are changed, but base revision has changed (ex. external update)
* (for RemoteRevisionsCache and annotation listener)
*/
public void getDelta(final ChangeListsIndexes newIndexes, Set<BaseRevision> toRemove, Set<BaseRevision> toAdd, Set<BeforeAfter<BaseRevision>> toModify) {
TreeMap<FilePath, Data> oldMap = myMap;
TreeMap<FilePath, Data> newMap = newIndexes.myMap;
Set<FilePath> oldFiles = oldMap.keySet();
Set<FilePath> newFiles = newMap.keySet();
final Set<FilePath> toRemoveSet = newHashSet(oldFiles);
toRemoveSet.removeAll(newFiles);
final Set<FilePath> toAddSet = newHashSet(newFiles);
toAddSet.removeAll(oldFiles);
final Set<FilePath> toModifySet = newHashSet(oldFiles);
toModifySet.removeAll(toRemoveSet);
for (FilePath s : toRemoveSet) {
final Data data = oldMap.get(s);
toRemove.add(createBaseRevision(s, data));
}
for (FilePath s : toAddSet) {
final Data data = newMap.get(s);
toAdd.add(createBaseRevision(s, data));
}
for (FilePath s : toModifySet) {
final Data oldData = oldMap.get(s);
final Data newData = newMap.get(s);
assert oldData != null && newData != null;
if (!oldData.sameRevisions(newData)) {
toModify.add(new BeforeAfter<>(createBaseRevision(s, oldData), createBaseRevision(s, newData)));
}
}
}
Aggregations