public Pair<List<RepositoryLocationGroup>, List<RepositoryLocation>> groupLocations( final List<RepositoryLocation> in) { final List<RepositoryLocationGroup> groups = new ArrayList<RepositoryLocationGroup>(); final List<RepositoryLocation> singles = new ArrayList<RepositoryLocation>(); final MultiMap<SVNURL, RepositoryLocation> map = new MultiMap<SVNURL, RepositoryLocation>(); for (RepositoryLocation location : in) { final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location; final String url = svnLocation.getURL(); final SVNURL root = SvnUtil.getRepositoryRoot(myVcs, url); if (root == null) { // should not occur LOG.info("repository root not found for location:" + location.toPresentableString()); singles.add(location); } else { map.putValue(root, svnLocation); } } final Set<SVNURL> keys = map.keySet(); for (SVNURL key : keys) { final Collection<RepositoryLocation> repositoryLocations = map.get(key); if (repositoryLocations.size() == 1) { singles.add(repositoryLocations.iterator().next()); } else { final SvnRepositoryLocationGroup group = new SvnRepositoryLocationGroup(key, repositoryLocations); groups.add(group); } } return new Pair<List<RepositoryLocationGroup>, List<RepositoryLocation>>(groups, singles); }
public SVNURL ask(final SVNURL url) { for (SVNURL root : myRoots) { if (root.equals(SVNURLUtil.getCommonURLAncestor(root, url))) { return root; } } final SVNURL newUrl = SvnUtil.getRepositoryRoot(myVcs, url); if (newUrl != null) { myRoots.add(newUrl); return newUrl; } return null; }