@NotNull public Change[] getSelectedChanges() { Set<Change> changes = new LinkedHashSet<Change>(); final TreePath[] paths = getSelectionPaths(); if (paths == null) { return new Change[0]; } for (TreePath path : paths) { ChangesBrowserNode<?> node = (ChangesBrowserNode) path.getLastPathComponent(); changes.addAll(node.getAllChangesUnder()); } if (changes.isEmpty()) { final List<VirtualFile> selectedModifiedWithoutEditing = getSelectedModifiedWithoutEditing(); if (selectedModifiedWithoutEditing != null && !selectedModifiedWithoutEditing.isEmpty()) { for (VirtualFile file : selectedModifiedWithoutEditing) { AbstractVcs vcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(file); if (vcs == null) continue; final VcsCurrentRevisionProxy before = VcsCurrentRevisionProxy.create(file, myProject, vcs.getKeyInstanceMethod()); if (before != null) { ContentRevision afterRevision = new CurrentContentRevision(new FilePathImpl(file)); changes.add(new Change(before, afterRevision, FileStatus.HIJACKED)); } } } } return changes.toArray(new Change[changes.size()]); }
@Override public boolean dvcsUsedInProject() { AbstractVcs[] allActiveVcss = getAllActiveVcss(); for (AbstractVcs activeVcs : allActiveVcss) { if (VcsType.distributed.equals(activeVcs.getType())) { return true; } } return false; }
public void unregisterVcs(@NotNull AbstractVcs vcs) { if (!ApplicationManager.getApplication().isUnitTestMode() && myMappings.haveActiveVcs(vcs.getName())) { // unlikely LOG.warn( "Active vcs '" + vcs.getName() + "' is being unregistered. Remove from mappings first."); } myMappings.beingUnregistered(vcs.getName()); AllVcses.getInstance(myProject).unregisterManually(vcs); }
public void readDirectoryMappings(final Element element) { myMappings.clear(); final List<VcsDirectoryMapping> mappingsList = new ArrayList<VcsDirectoryMapping>(); boolean haveNonEmptyMappings = false; for (Element child : element.getChildren(ELEMENT_MAPPING)) { final String vcs = child.getAttributeValue(ATTRIBUTE_VCS); if (vcs != null && !vcs.isEmpty()) { haveNonEmptyMappings = true; } VcsDirectoryMapping mapping = new VcsDirectoryMapping(child.getAttributeValue(ATTRIBUTE_DIRECTORY), vcs); mappingsList.add(mapping); Element rootSettingsElement = child.getChild(ELEMENT_ROOT_SETTINGS); if (rootSettingsElement != null) { String className = rootSettingsElement.getAttributeValue(ATTRIBUTE_CLASS); AbstractVcs vcsInstance = findVcsByName(mapping.getVcs()); if (vcsInstance != null && className != null) { final VcsRootSettings rootSettings = vcsInstance.createEmptyVcsRootSettings(); if (rootSettings != null) { try { rootSettings.readExternal(rootSettingsElement); mapping.setRootSettings(rootSettings); } catch (InvalidDataException e) { LOG.error( "Failed to load VCS root settings class " + className + " for VCS " + vcsInstance.getClass().getName(), e); } } } } } boolean defaultProject = Boolean.TRUE.toString().equals(element.getAttributeValue(ATTRIBUTE_DEFAULT_PROJECT)); // run autodetection if there's no VCS in default project and if (haveNonEmptyMappings || !defaultProject) { myMappingsLoaded = true; } myMappings.setDirectoryMappings(mappingsList); }
@NotNull public static Collection<VcsDirectoryMapping> findRoots( @NotNull VirtualFile rootDir, @NotNull Project project) throws IllegalArgumentException { if (!rootDir.isDirectory()) { throw new IllegalArgumentException( "Can't find VCS at the target file system path. Reason: expected to find a directory there but it's not. The path: " + rootDir.getParent()); } Collection<VcsRoot> roots = ServiceManager.getService(project, VcsRootDetector.class).detect(rootDir); Collection<VcsDirectoryMapping> result = ContainerUtilRt.newArrayList(); for (VcsRoot vcsRoot : roots) { VirtualFile vFile = vcsRoot.getPath(); AbstractVcs rootVcs = vcsRoot.getVcs(); if (rootVcs != null && vFile != null) { result.add(new VcsDirectoryMapping(vFile.getPath(), rootVcs.getName())); } } return result; }
@Override public List<VcsDirectoryMapping> getDirectoryMappings(final AbstractVcs vcs) { return myMappings.getDirectoryMappings(vcs.getName()); }
@Override public boolean checkVcsIsActive(AbstractVcs vcs) { return checkVcsIsActive(vcs.getName()); }