use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class VcsLogPathsIndex method iterateCommits.
public void iterateCommits(@NotNull Collection<FilePath> paths, @NotNull ObjIntConsumer<Couple<FilePath>> consumer) throws IOException, StorageException {
Set<Integer> startIds = getPathIds(paths);
Set<Integer> allIds = ContainerUtil.newHashSet(startIds);
Set<Integer> newIds = ContainerUtil.newHashSet();
while (!startIds.isEmpty()) {
for (int currentPathId : startIds) {
FilePath currentPath = VcsUtil.getFilePath(myPathsIndexer.myPathsEnumerator.valueOf(currentPathId));
iterateCommitIdsAndValues(currentPathId, (renamedPathId, commitId) -> {
FilePath renamedPath = null;
if (renamedPathId != null) {
if (!allIds.contains(renamedPathId)) {
newIds.add(renamedPathId);
}
try {
renamedPath = VcsUtil.getFilePath(myPathsIndexer.myPathsEnumerator.valueOf(renamedPathId));
} catch (IOException e) {
LOG.error(e);
}
}
consumer.accept(Couple.of(currentPath, renamedPath), commitId);
});
}
startIds = ContainerUtil.newHashSet(newIds);
allIds.addAll(startIds);
newIds.clear();
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class CvsCheckinHandlerFactory method createVcsHandler.
@NotNull
@Override
protected CheckinHandler createVcsHandler(final CheckinProjectPanel panel) {
return new CheckinHandler() {
@Nullable
public RefreshableOnComponent getAfterCheckinConfigurationPanel(Disposable parentDisposable) {
final Project project = panel.getProject();
final CvsVcs2 cvs = CvsVcs2.getInstance(project);
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
final Collection<VirtualFile> roots = panel.getRoots();
final Collection<FilePath> files = new HashSet<>();
for (VirtualFile root : roots) {
final VcsRoot vcsRoot = vcsManager.getVcsRootObjectFor(root);
if (vcsRoot == null || vcsRoot.getVcs() != cvs) {
continue;
}
files.add(VcsContextFactory.SERVICE.getInstance().createFilePathOn(root));
}
return new AdditionalOptionsPanel(CvsConfiguration.getInstance(project), files, project);
}
};
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class ModuleVcsPathPresenter method getPresentableRelativePath.
@Override
public String getPresentableRelativePath(@NotNull final ContentRevision fromRevision, @NotNull final ContentRevision toRevision) {
final FilePath fromPath = fromRevision.getFile();
final FilePath toPath = toRevision.getFile();
// need to use parent path because the old file is already not there
final VirtualFile fromParent = getParentFile(fromPath);
final VirtualFile toParent = getParentFile(toPath);
if (fromParent != null && toParent != null) {
String moduleResult = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
final boolean hideExcludedFiles = Registry.is("ide.hide.excluded.files");
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
Module fromModule = fileIndex.getModuleForFile(fromParent, hideExcludedFiles);
Module toModule = fileIndex.getModuleForFile(toParent, hideExcludedFiles);
if (fromModule == null || toModule == null || fromModule.equals(toModule))
return null;
VirtualFile fromContentRoot = fileIndex.getContentRootForFile(fromParent, hideExcludedFiles);
if (fromContentRoot == null)
return null;
String relativePath = VfsUtilCore.getRelativePath(fromParent, fromContentRoot, File.separatorChar);
assert relativePath != null;
relativePath += File.separatorChar;
if (!fromPath.getName().equals(toPath.getName())) {
relativePath += fromPath.getName();
}
return getPresentableRelativePathFor(fromModule, fromContentRoot, relativePath);
}
});
if (moduleResult != null)
return moduleResult;
}
final RelativePathCalculator calculator = new RelativePathCalculator(toPath.getPath(), fromPath.getPath());
calculator.execute();
final String result = calculator.getResult();
return result != null ? result.replace("/", File.separator) : null;
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class ShowDiffWithLocalFromHistoryAction method performAction.
@Override
protected void performAction(@NotNull Project project, @NotNull FileHistoryUi ui, @NotNull VcsFullCommitDetails detail, @NotNull AnActionEvent e) {
if (ChangeListManager.getInstance(project).isFreezedWithNotification(null))
return;
FilePath path = e.getRequiredData(VcsDataKeys.FILE_PATH);
VcsFileRevision revision = ui.createRevision(detail);
if (revision != null) {
StandardDiffFromHistoryHandler handler = new StandardDiffFromHistoryHandler();
handler.showDiffForTwo(project, path, revision, new CurrentRevision(notNull(path.getVirtualFile()), VcsRevisionNumber.NULL));
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class CompareRevisionsFromHistoryAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
FileHistoryUi ui = e.getRequiredData(VcsLogInternalDataKeys.FILE_HISTORY_UI);
FilePath filePath = e.getRequiredData(VcsDataKeys.FILE_PATH);
if (e.getInputEvent() instanceof MouseEvent && ui.getTable().isResizingColumns()) {
// disable action during columns resize
return;
}
VcsLogUtil.triggerUsage(e);
List<CommitId> commits = ui.getVcsLog().getSelectedCommits();
if (commits.size() != 1 && commits.size() != 2)
return;
List<Integer> commitIds = ContainerUtil.map(commits, c -> ui.getLogData().getCommitIndex(c.getHash(), c.getRoot()));
ui.getLogData().getCommitDetailsGetter().loadCommitsData(commitIds, details -> {
if (details.size() == 2) {
VcsFileRevision newestRevision = ui.createRevision(details.get(0));
VcsFileRevision olderRevision = ui.createRevision(details.get(1));
if (olderRevision != null && newestRevision != null) {
myDiffHandler.showDiffForTwo(project, filePath, olderRevision, newestRevision);
}
} else if (details.size() == 1) {
VcsFullCommitDetails detail = ObjectUtils.notNull(ContainerUtil.getFirstItem(details));
List<Change> changes = ui.collectRelevantChanges(detail);
if (filePath.isDirectory()) {
VcsDiffUtil.showChangesDialog(project, "Changes in " + detail.getId().toShortString() + " for " + filePath.getName(), ContainerUtil.newArrayList(changes));
} else {
ShowDiffAction.showDiffForChange(project, changes, 0, new ShowDiffContext());
}
}
}, null);
}
Aggregations