public void setAutoDirectoryMapping(String path, String activeVcsName) { final List<VirtualFile> defaultRoots = myMappings.getDefaultRoots(); if (defaultRoots.size() == 1 && StringUtil.isEmpty(myMappings.haveDefaultMapping())) { myMappings.removeDirectoryMapping(new VcsDirectoryMapping("", "")); } myMappings.setMapping(path, activeVcsName); }
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); }
@Override public void setDirectoryMapping(final String path, final String activeVcsName) { if (myMappingsLoaded) return; // ignore per-module VCS settings if the mapping table was loaded from .ipr myHaveLegacyVcsConfiguration = true; myMappings.setMapping(FileUtil.toSystemIndependentName(path), activeVcsName); }
@Override public VirtualFile[] getAllVersionedRoots() { List<VirtualFile> vFiles = new ArrayList<VirtualFile>(); final AbstractVcs[] vcses = myMappings.getActiveVcses(); for (AbstractVcs vcs : vcses) { Collections.addAll(vFiles, getRootsUnderVcs(vcs)); } return VfsUtilCore.toVirtualFileArray(vFiles); }
@Override @Nullable public AbstractVcs getVcsFor(@NotNull VirtualFile file) { final String vcsName = myMappings.getVcsFor(file); if (vcsName == null || vcsName.isEmpty()) { return null; } return AllVcses.getInstance(myProject).getByName(vcsName); }
@Override @Nullable public VcsDirectoryMapping getDirectoryMappingFor(final FilePath path) { VirtualFile vFile = ChangesUtil.findValidParentAccurately(path); if (vFile != null) { return myMappings.getMappingFor(vFile); } return null; }
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); }
@Override @Nullable public VirtualFile getVcsRootFor(@Nullable final VirtualFile file) { final VcsDirectoryMapping mapping = myMappings.getMappingFor(file); if (mapping == null) { return null; } final String directory = mapping.getDirectory(); if (directory.isEmpty()) { return myDefaultVcsRootPolicy.getVcsRootFor(file); } return LocalFileSystem.getInstance().findFileByPath(directory); }
@Override public void disposeComponent() { releaseEditor(); myMappings.disposeMe(); myConnect.disconnect(); Disposer.dispose(myAnnotationLocalChangesListener); myContentManager = null; ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject); if (toolWindowManager != null && toolWindowManager.getToolWindow(ToolWindowId.VCS) != null) { toolWindowManager.unregisterToolWindow(ToolWindowId.VCS); } }
@Override @NotNull public VcsRoot[] getAllVcsRoots() { List<VcsRoot> vcsRoots = new ArrayList<VcsRoot>(); final AbstractVcs[] vcses = myMappings.getActiveVcses(); for (AbstractVcs vcs : vcses) { final VirtualFile[] roots = getRootsUnderVcs(vcs); for (VirtualFile root : roots) { vcsRoots.add(new VcsRoot(vcs, root)); } } return vcsRoots.toArray(new VcsRoot[vcsRoots.size()]); }
@Override @Nullable public VcsRoot getVcsRootObjectFor(final VirtualFile file) { final VcsDirectoryMapping mapping = myMappings.getMappingFor(file); if (mapping == null) { return null; } final String directory = mapping.getDirectory(); final AbstractVcs vcs = findVcsByName(mapping.getVcs()); if (directory.isEmpty()) { return new VcsRoot(vcs, myDefaultVcsRootPolicy.getVcsRootFor(file)); } return new VcsRoot(vcs, LocalFileSystem.getInstance().findFileByPath(directory)); }
@Override public String haveDefaultMapping() { return myMappings.haveDefaultMapping(); }
@Override public void fireDirectoryMappingsChanged() { if (myProject.isOpen() && !myProject.isDisposed()) { myMappings.mappingsChanged(); } }
@Override public List<VirtualFile> getRootsUnderVcsWithoutFiltering(final AbstractVcs vcs) { return myMappings.getMappingsAsFilesUnderVcs(vcs); }
@Override public boolean checkVcsIsActive(final String vcsName) { return myMappings.haveActiveVcs(vcsName); }
public void removeDirectoryMapping(VcsDirectoryMapping mapping) { myMappings.removeDirectoryMapping(mapping); }
@Override public void setDirectoryMappings(final List<VcsDirectoryMapping> items) { myHaveLegacyVcsConfiguration = true; myMappings.setDirectoryMappings(items); }
@Override public boolean hasActiveVcss() { return myMappings.hasActiveVcss(); }
@Override public AbstractVcs[] getAllActiveVcss() { return myMappings.getActiveVcses(); }
public boolean hasExplicitMapping(final VirtualFile vFile) { final VcsDirectoryMapping mapping = myMappings.getMappingFor(vFile); return mapping != null && !mapping.isDefaultMapping(); }
@Override public boolean hasAnyMappings() { return !myMappings.isEmpty(); }
@Override public List<VcsDirectoryMapping> getDirectoryMappings(final AbstractVcs vcs) { return myMappings.getDirectoryMappings(vcs.getName()); }
@Override public List<VcsDirectoryMapping> getDirectoryMappings() { return myMappings.getDirectoryMappings(); }
public void cleanupMappings() { myMappings.cleanupMappings(); }