use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class ShareWholeProject method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final MyChecker checker = new MyChecker();
checker.execute(e);
if (!checker.isEnabled())
return;
final Project project = checker.getProject();
final VirtualFile baseDir = project.getBaseDir();
if (baseDir == null)
return;
boolean success = false;
boolean excThrown = false;
try {
success = ShareProjectAction.share(project, baseDir);
} catch (VcsException exc) {
AbstractVcsHelper.getInstance(project).showError(exc, "Failed to Share Project");
excThrown = true;
} finally {
// if success = false -> either action was cancelled or exception was thrown, so also check for exception
if (success || excThrown) {
baseDir.refresh(true, true, () -> ApplicationManager.getApplication().invokeLater(() -> {
VcsDirtyScopeManager.getInstance(project).dirDirtyRecursively(project.getBaseDir());
if (checker.isHadNoMappings() && SvnUtil.seemsLikeVersionedDir(baseDir)) {
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
vcsManager.setDirectoryMappings(Arrays.asList(new VcsDirectoryMapping("", SvnVcs.VCS_NAME)));
}
}, ModalityState.NON_MODAL, project.getDisposed()));
}
}
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class HgInit method updateDirectoryMappings.
// update vcs directory mappings if new repository was created inside the current project directory
private void updateDirectoryMappings(VirtualFile mapRoot) {
if (myProject != null && (!myProject.isDefault()) && myProject.getBaseDir() != null && VfsUtil.isAncestor(myProject.getBaseDir(), mapRoot, false)) {
mapRoot.refresh(false, false);
final String path = mapRoot.equals(myProject.getBaseDir()) ? "" : mapRoot.getPath();
ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(myProject);
manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), path, HgVcs.VCS_NAME));
manager.updateActiveVcss();
}
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class ExclusiveBackgroundVcsAction method run.
public static void run(final Project project, final Runnable action) {
final ProjectLevelVcsManager plVcsManager = ProjectLevelVcsManager.getInstance(project);
plVcsManager.startBackgroundVcsOperation();
try {
action.run();
} finally {
final Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
application.executeOnPooledThread(() -> plVcsManager.stopBackgroundVcsOperation());
} else {
plVcsManager.stopBackgroundVcsOperation();
}
}
}
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();
}
}
}
Aggregations