private String getSourceCode(SVNRepository repository, long endRevision, SVNLogEntryPath e) throws SVNException, UnsupportedEncodingException { if (e.getType() == 'D') return ""; ByteArrayOutputStream out = new ByteArrayOutputStream(); repository.getFile(e.getPath(), endRevision, null, out); String sc = out.toString("UTF-8"); return sc; }
for (Iterator entries = logEntries.iterator(); entries.hasNext();) { SVNLogEntry logEntry = (SVNLogEntry) entries.next(); if (logEntry.getChangedPaths().size() > 0) { Set<String> changedPathsSet = logEntry.getChangedPaths().keySet(); for (Iterator<String> changedPaths = changedPathsSet.iterator(); changedPaths .hasNext();) { SVNLogEntryPath entryPath = (SVNLogEntryPath) logEntry .getChangedPaths().get(changedPaths.next()); String path = entryPath.getPath(); if (!path.startsWith(updatePath)) { continue; }
/** * TODO: type replaced * * * @param modifications * @param entry */ public static void appendModification(Modifications modifications, SVNLogEntryPath entry) { appendModification(modifications, entry.getType(), entry.getPath()); }
private List<Modification> getModifications(SVNRepository repository, SVNURL url, long revision, SVNLogEntry logEntry) throws SVNException, UnsupportedEncodingException { List<Modification> modifications = new ArrayList<Modification>(); for (Entry<String, SVNLogEntryPath> entry : logEntry.getChangedPaths().entrySet()) { SVNLogEntryPath e = entry.getValue(); String diffText = getDiffText(repository, url, e, revision); String sc = getSourceCode(repository, revision, e); Modification modification = new Modification(e.getCopyPath(), e.getPath(), getModificationType(e), diffText, sc); modifications.add(modification); } return modifications; }
private static Collection<String> convert(@NotNull Collection<SVNLogEntryPath> changedPaths) { List<String> result = new ArrayList<>(); for (SVNLogEntryPath logPath : changedPaths) { result.add(logPath.getType() + " " + logPath.getPath()); } return result; }
private static Set<ChangePath> getChangePaths(Map<String, SVNLogEntryPath> changedPaths) { if (changedPaths == null) { return null; } Set<ChangePath> changePaths = new HashSet<ChangePath>(); for (Map.Entry<String, SVNLogEntryPath> entry : changedPaths.entrySet()) { SVNLogEntryPath svnLogEntryPath = entry.getValue(); //TODO: replace Tristate.Unknown with correct values in the following changePaths.add(new ChangePath(svnLogEntryPath.getPath(), svnLogEntryPath.getCopyRevision(), svnLogEntryPath.getCopyPath(), getChangePathAction(svnLogEntryPath.getType()), getNodeKind(svnLogEntryPath.getKind()), Tristate.Unknown, Tristate.Unknown)); } return changePaths; }
private String getDiffText(SVNRepository repository, SVNURL url, SVNLogEntryPath entry, long revision) { try { SVNClientManager clientManager = SVNClientManager.newInstance(null, repository.getAuthenticationManager()); SVNDiffClient diffClient = clientManager.getDiffClient(); ByteArrayOutputStream out = new ByteArrayOutputStream(); SVNRevision startRevision = SVNRevision.create(revision - 1); SVNRevision endRevision = SVNRevision.create(revision); diffClient.doDiff(url, startRevision, startRevision, endRevision, SVNDepth.FILES, true, out); String diffText = out.toString("UTF-8"); if (diffText.length() > MAX_SIZE_OF_A_DIFF) { log.error("diffs for " + entry.getPath() + " too big"); diffText = "-- TOO BIG --"; } return diffText; } catch (Exception e) { return ""; } }
private void indexSVNStopEvents(SVNRepository repository, SVNLogEntry logEntry) { long revision = logEntry.getRevision(); // Looking for copy tags @SuppressWarnings("unchecked") Map<String, SVNLogEntryPath> changedPaths = logEntry.getChangedPaths(); // For all changes path for (SVNLogEntryPath logEntryPath : changedPaths.values()) { String path = logEntryPath.getPath(); if (logEntryPath.getType() == SVNLogEntryPath.TYPE_DELETED && svnClient.isTagOrBranch(repository, path)) { logger.debug(String.format("\tSTOP %s", path)); // Adds the stop event eventDao.createStopEvent(repository.getId(), revision, path); } } }
for (Iterator changedPaths = changedPathsSet.iterator(); changedPaths.hasNext();) { SVNLogEntryPath entryPath = (SVNLogEntryPath) logEntry.getChangedPaths().get(changedPaths.next()); String workingFileName = entryPath.getPath();
if (logPath != null) { if (logPath.getType() != SVNLogEntryPath.TYPE_ADDED && logPath.getType() != SVNLogEntryPath.TYPE_REPLACED) { return logPath.getPath();
if (logPath != null) { if (logPath.getType() != SVNLogEntryPath.TYPE_ADDED && logPath.getType() != SVNLogEntryPath.TYPE_REPLACED) { return logPath.getPath();
if (logPath != null) { if (logPath.getType() != SVNLogEntryPath.TYPE_ADDED && logPath.getType() != SVNLogEntryPath.TYPE_REPLACED) { return logPath.getPath();
if (logPath != null) { if (logPath.getType() != SVNLogEntryPath.TYPE_ADDED && logPath.getType() != SVNLogEntryPath.TYPE_REPLACED) { return logPath.getPath();
private void indexSVNCopyEvents(SVNRepository repository, SVNLogEntry logEntry) { long revision = logEntry.getRevision(); // Looking for copy tags @SuppressWarnings("unchecked") Map<String, SVNLogEntryPath> changedPaths = logEntry.getChangedPaths(); // Copies /* * Looks through all changed paths and retains only copy operations toward branches or tags */ for (SVNLogEntryPath logEntryPath : changedPaths.values()) { // Gets the copy path String copyFromPath = logEntryPath.getCopyPath(); if (StringUtils.isNotBlank(copyFromPath) && logEntryPath.getType() == SVNLogEntryPath.TYPE_ADDED) { // Registers the new history String copyToPath = logEntryPath.getPath(); // Retains only branches and tags if (svnClient.isTagOrBranch(repository, copyToPath)) { long copyFromRevision = logEntryPath.getCopyRevision(); logger.debug(String.format("\tCOPY %s@%d --> %s", copyFromPath, copyFromRevision, copyToPath)); // Adds a copy event eventDao.createCopyEvent(repository.getId(), revision, copyFromPath, copyFromRevision, copyToPath); } } } }
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); final SvnLog log = svnOperationFactory.createLog(); log.setSingleTarget(SvnTarget.fromURL(url)); log.addRange(SvnRevisionRange.create(SVNRevision.create(12345), SVNRevision.create(12345))); log.setDiscoverChangedPaths(true); final SVNLogEntry logEntry = log.run(); final Map<String,SVNLogEntryPath> changedPaths = logEntry.getChangedPaths(); for (Map.Entry<String, SVNLogEntryPath> entry : changedPaths.entrySet()) { final SVNLogEntryPath svnLogEntryPath = entry.getValue(); System.out.println(svnLogEntryPath.getType() + " " + svnLogEntryPath.getPath() + (svnLogEntryPath.getCopyPath() == null ? "" : (" from " + svnLogEntryPath.getCopyPath() + ":" + svnLogEntryPath.getCopyRevision()))); }
private void checkCopyFrom(@NotNull SVNRepository repo, @NotNull CopyFromSVNEditor editor, long revision) throws SVNException { final Map<String, String> copyFrom = new TreeMap<>(); repo.log(new String[]{""}, revision, revision, true, true, logEntry -> { for (SVNLogEntryPath entry : logEntry.getChangedPaths().values()) { if (entry.getCopyPath() != null) { copyFrom.put(entry.getPath(), entry.getCopyPath() + "@" + entry.getCopyRevision()); } } }); Assert.assertEquals(editor.getCopyFrom(), copyFrom); }
if (path.getPath().startsWith(modulePath)) { String relativeWorkspacePath = context.moduleWorkspacePath + path.getPath().substring(context.url.length() - context.repoUrl.length()); if (".".equals(context.moduleWorkspacePath) && relativeWorkspacePath.length() >= 2) { addAttribute(KIND_ATTR, path.getKind().toString()); addTag(PATH_TAG, path.getPath());
for (Map.Entry<String, SVNLogEntryPath> e : cps.entrySet()) { SVNLogEntryPath lep = e.getValue(); System.out.println(lep.getType() + " " + lep.getPath());
addAttribute(COPYFROM_REV_ATTR, path.getCopyRevision() + ""); addTag(PATH_TAG, SVNEncodingUtil.xmlEncodeAttr(path.getPath()));