use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class DescindingFilesFilter method filterDescindingFiles.
@NotNull
public static FilePath[] filterDescindingFiles(@NotNull FilePath[] roots, Project project) {
final List<FilePath> result = new LinkedList<>();
ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
Arrays.sort(roots, FilePathComparator.getInstance());
final Map<VcsKey, List<FilePath>> chains = new HashMap<>();
for (FilePath root : roots) {
final AbstractVcs vcs = manager.getVcsFor(root);
if (vcs == null)
continue;
if (vcs.allowsNestedRoots()) {
// just put into result: nested roots are allowed
result.add(root);
continue;
}
//if (pathsFilter != null && (! pathsFilter.convert(new Pair<FilePath, AbstractVcs>(root, vcs)))) continue;
final List<FilePath> chain = chains.get(vcs.getKeyInstanceMethod());
if (chain == null) {
final LinkedList<FilePath> newList = new LinkedList<>();
newList.add(root);
chains.put(vcs.getKeyInstanceMethod(), newList);
} else {
boolean failed = false;
for (FilePath chainedPath : chain) {
if (VfsUtilCore.isAncestor(chainedPath.getIOFile(), root.getIOFile(), false)) {
// do not take this root
failed = true;
break;
}
}
if (!failed) {
chain.add(root);
}
}
}
for (List<FilePath> filePaths : chains.values()) {
result.addAll(filePaths);
}
return result.toArray(new FilePath[result.size()]);
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class StartUseVcsAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final VcsDataWrapper data = new VcsDataWrapper(e);
final boolean enabled = data.enabled();
if (!enabled) {
return;
}
final StartUseVcsDialog dialog = new StartUseVcsDialog(data);
dialog.show();
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
final String vcsName = dialog.getVcs();
if (vcsName.length() > 0) {
final ProjectLevelVcsManager manager = data.getManager();
AbstractVcs vcs = manager.findVcsByName(vcsName);
assert vcs != null : "No vcs found for name " + vcsName;
vcs.enableIntegration();
}
}
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class VcsContentAnnotationImpl method fileRecentlyChanged.
@Nullable
@Override
public VcsRevisionNumber fileRecentlyChanged(VirtualFile vf) {
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
final AbstractVcs vcs = vcsManager.getVcsFor(vf);
if (vcs == null)
return null;
if (vcs.getDiffProvider() instanceof DiffMixin) {
final VcsRevisionDescription description = ((DiffMixin) vcs.getDiffProvider()).getCurrentRevisionDescription(vf);
final Date date = description.getRevisionDate();
return isRecent(date) ? description.getRevisionNumber() : null;
}
return null;
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager 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.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class GitInit method refreshAndConfigureVcsMappings.
public static void refreshAndConfigureVcsMappings(final Project project, final VirtualFile root, final String path) {
VfsUtil.markDirtyAndRefresh(false, true, false, root);
ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), path, GitVcs.NAME));
manager.updateActiveVcss();
VcsDirtyScopeManager.getInstance(project).dirDirtyRecursively(root);
}
Aggregations