@NotNull public static List<VcsDirectoryMapping> addMapping( @NotNull List<VcsDirectoryMapping> existingMappings, @NotNull String path, @NotNull String vcs) { List<VcsDirectoryMapping> mappings = new ArrayList<VcsDirectoryMapping>(existingMappings); for (Iterator<VcsDirectoryMapping> iterator = mappings.iterator(); iterator.hasNext(); ) { VcsDirectoryMapping mapping = iterator.next(); if (mapping.isDefaultMapping() && StringUtil.isEmptyOrSpaces(mapping.getVcs())) { LOG.debug("Removing <Project> -> <None> mapping"); iterator.remove(); } else if (FileUtil.pathsEqual(mapping.getDirectory(), path)) { if (!StringUtil.isEmptyOrSpaces(mapping.getVcs())) { LOG.warn( "Substituting existing mapping [" + path + "] -> [" + mapping.getVcs() + "] with [" + vcs + "]"); } else { LOG.debug("Removing [" + path + "] -> <None> mapping"); } iterator.remove(); } } mappings.add(new VcsDirectoryMapping(path, vcs)); return mappings; }
public boolean hasExplicitMapping(final VirtualFile vFile) { final VcsDirectoryMapping mapping = myMappings.getMappingFor(vFile); return mapping != null && !mapping.isDefaultMapping(); }