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); }
@Override public Pair<SvnChangeList, FilePath> getOneList(final VirtualFile file, VcsRevisionNumber number) throws VcsException { final RootUrlInfo rootUrlInfo = myVcs.getSvnFileUrlMapping().getWcRootForFilePath(new File(file.getPath())); if (rootUrlInfo == null) return null; final VirtualFile root = rootUrlInfo.getVirtualFile(); if (root == null) return null; final SvnRepositoryLocation svnRootLocation = (SvnRepositoryLocation) getLocationFor(new FilePathImpl(root)); if (svnRootLocation == null) return null; final String url = svnRootLocation.getURL(); final long revision; try { revision = Long.parseLong(number.asString()); } catch (NumberFormatException e) { throw new VcsException(e); } final SvnChangeList[] result = new SvnChangeList[1]; final SVNLogClient logger; final SVNRevision revisionBefore; final SVNURL repositoryUrl; final SVNURL svnurl; final SVNInfo targetInfo; try { logger = myVcs.createLogClient(); revisionBefore = SVNRevision.create(revision); svnurl = SVNURL.parseURIEncoded(url); final SVNWCClient client = myVcs.createWCClient(); final SVNInfo info = client.doInfo(svnurl, SVNRevision.UNDEFINED, SVNRevision.HEAD); targetInfo = client.doInfo(new File(file.getPath()), SVNRevision.UNDEFINED); if (info == null) { throw new VcsException("Can not get repository URL"); } repositoryUrl = info.getRepositoryRootURL(); } catch (SVNException e) { LOG.info(e); throw new VcsException(e); } tryExactHit(svnRootLocation, result, logger, revisionBefore, repositoryUrl, svnurl); if (result[0] == null) { tryByRoot(result, logger, revisionBefore, repositoryUrl); if (result[0] == null) { FilePath path = tryStepByStep(svnRootLocation, result, logger, revisionBefore, targetInfo, svnurl); path = path == null ? new FilePathImpl(file) : path; // and pass & take rename context there return new Pair<SvnChangeList, FilePath>(result[0], path); } } if (result[0].getChanges().size() == 1) { final Collection<Change> changes = result[0].getChanges(); final Change change = changes.iterator().next(); final ContentRevision afterRevision = change.getAfterRevision(); if (afterRevision != null) { return new Pair<SvnChangeList, FilePath>(result[0], afterRevision.getFile()); } else { return new Pair<SvnChangeList, FilePath>(result[0], new FilePathImpl(file)); } } String relativePath = SVNPathUtil.getRelativePath( targetInfo.getRepositoryRootURL().toString(), targetInfo.getURL().toString()); relativePath = relativePath.startsWith("/") ? relativePath : "/" + relativePath; final Change targetChange = result[0].getByPath(relativePath); if (targetChange == null) { FilePath path = tryStepByStep(svnRootLocation, result, logger, revisionBefore, targetInfo, svnurl); path = path == null ? new FilePathImpl(file) : path; // and pass & take rename context there return new Pair<SvnChangeList, FilePath>(result[0], path); } return new Pair<SvnChangeList, FilePath>(result[0], new FilePathImpl(file)); }
@SuppressWarnings("MethodMayBeStatic") private String formatWc( @NotNull WCInfo info, @NotNull Collection<WorkingCopyFormat> upgradeFormats) { final StringBuilder sb = new StringBuilder() .append("<html><head>") .append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont())) .append("</head><body><table bgColor=\"") .append(ColorUtil.toHex(UIUtil.getPanelBackground())) .append("\">"); sb.append("<tr valign=\"top\"><td colspan=\"3\"><b>") .append(info.getPath()) .append("</b></td></tr>"); if (info.hasError()) { sb.append("<tr valign=\"top\"><td>URL:</td><td colspan=\"2\" color=\"") .append(ColorUtil.toHex(JBColor.red)) .append("\">") .append(info.getErrorMessage()) .append("</td></tr>"); } else { sb.append("<tr valign=\"top\"><td>URL:</td><td colspan=\"2\">") .append(info.getRootUrl()) .append("</td></tr>"); } if (upgradeFormats.size() > 1) { sb.append("<tr valign=\"top\"><td>Format:</td><td>") .append(info.getFormat().getName()) .append("</td><td><a href=\"") .append(CHANGE_FORMAT) .append("\">Change</a></td></tr>"); } else { sb.append("<tr valign=\"top\"><td>Format:</td><td colspan=\"2\">") .append(info.getFormat().getName()) .append("</td></tr>"); } if (!Depth.INFINITY.equals(info.getStickyDepth()) && !info.hasError()) { // can fix sb.append("<tr valign=\"top\"><td>Depth:</td><td>") .append(info.getStickyDepth().getName()) .append("</td><td><a href=\"") .append(FIX_DEPTH) .append("\">Fix</a></td></tr>"); } else { sb.append("<tr valign=\"top\"><td>Depth:</td><td colspan=\"2\">") .append(info.getStickyDepth().getName()) .append("</td></tr>"); } final NestedCopyType type = info.getType(); if (NestedCopyType.external.equals(type) || NestedCopyType.switched.equals(type)) { sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>") .append(type.getName()) .append("</i></td></tr>"); } if (info.isIsWcRoot()) { sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>") .append("Working copy root</i></td></tr>"); } if (!info.hasError()) { if (info.getFormat().isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN)) { sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"") .append(CLEANUP) .append("\">Cleanup</a></td></tr>"); } sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"") .append(CONFIGURE_BRANCHES) .append("\">Configure Branches</a></td></tr>"); sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"") .append(MERGE_FROM) .append("\"><b>Merge From...</b></a></i></td></tr>"); sb.append("</table></body></html>"); } return sb.toString(); }