private ModificationType getModificationType(SVNLogEntryPath e) { if (e.getType() == 'A') { return ModificationType.ADD; } else if (e.getType() == 'D') { return ModificationType.DELETE; } else if (e.getType() == 'M') { return ModificationType.MODIFY; } else if (e.getType() == 'R') { return ModificationType.COPY; } return null; }
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { Map changedPaths = logEntry.getChangedPaths(); for (Iterator changedPathsIter = changedPaths.keySet().iterator(); changedPathsIter.hasNext();) { String path = (String) changedPathsIter.next(); SVNLogEntryPath change = (SVNLogEntryPath) changedPaths.get(path); if (myPath.equals(path) && (change.getType() == SVNLogEntryPath.TYPE_DELETED || change.getType() == SVNLogEntryPath.TYPE_REPLACED)) { myDeletedRevision = logEntry.getRevision(); } } }
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { Map changedPaths = logEntry.getChangedPaths(); for (Iterator changedPathsIter = changedPaths.keySet().iterator(); changedPathsIter.hasNext();) { String path = (String) changedPathsIter.next(); SVNLogEntryPath change = (SVNLogEntryPath) changedPaths.get(path); if (myPath.equals(path) && (change.getType() == SVNLogEntryPath.TYPE_DELETED || change.getType() == SVNLogEntryPath.TYPE_REPLACED)) { myDeletedRevision = logEntry.getRevision(); } } }
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { Map changedPaths = logEntry.getChangedPaths(); for (Iterator changedPathsIter = changedPaths.keySet().iterator(); changedPathsIter.hasNext();) { String path = (String) changedPathsIter.next(); SVNLogEntryPath change = (SVNLogEntryPath) changedPaths.get(path); if (myPath.equals(path) && (change.getType() == SVNLogEntryPath.TYPE_DELETED || change.getType() == SVNLogEntryPath.TYPE_REPLACED)) { myDeletedRevision = logEntry.getRevision(); } } }
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; }
public void deleteEntry(String path, long revision) throws SVNException { String absPath = getSourceRepository().getRepositoryPath(path); SVNLogEntryPath deletedPath = (SVNLogEntryPath) myChangedPaths.get(absPath); if (deletedPath != null && (deletedPath.getType() == SVNLogEntryPath.TYPE_DELETED || deletedPath.getType() == SVNLogEntryPath.TYPE_REPLACED)) { if (deletedPath.getType() == SVNLogEntryPath.TYPE_DELETED) { myChangedPaths.remove(absPath); } } else { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "Expected that path ''{0}'' is deleted in revision {1,number,integer}", new Object[]{absPath, new Long(myPreviousRevision)}); SVNErrorManager.error(err); } myCommitEditor.deleteEntry(path, myPreviousRevision); }
/** * TODO: type replaced * * * @param modifications * @param entry */ public static void appendModification(Modifications modifications, SVNLogEntryPath entry) { appendModification(modifications, entry.getType(), entry.getPath()); }
/** * Removes <code>path</code> from the paths to be committed. * * @param path * @param revision * @throws SVNException exception with {@link SVNErrorCode#UNKNOWN} error code - if somehow * chanded paths fetched from the log of the resource repository did not * reflect <code>path</code> deletion in <code>revision</code> * */ public void deleteEntry(String path, long revision) throws SVNException { String absPath = getSourceRepository().getRepositoryPath(path); SVNLogEntryPath deletedPath = (SVNLogEntryPath) myChangedPaths.get(absPath); if (deletedPath != null && (deletedPath.getType() == SVNLogEntryPath.TYPE_DELETED || deletedPath.getType() == SVNLogEntryPath.TYPE_REPLACED)) { if (deletedPath.getType() == SVNLogEntryPath.TYPE_DELETED) { myChangedPaths.remove(absPath); } } else { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "Expected that path ''{0}'' is deleted in revision {1}", new Object[]{absPath, new Long(myPreviousRevision)}); SVNErrorManager.error(err, SVNLogType.FSFS); } myCommitEditor.deleteEntry(path, myPreviousRevision); }
@Override public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { for (Map.Entry<String, SVNLogEntryPath> entry : (Set<Map.Entry<String, SVNLogEntryPath>>) logEntry .getChangedPaths().entrySet()) { String path = entry.getKey(); SVNLogEntryPath value = entry.getValue(); //log if(log.isDebugEnabled()) { log.debug("path changed : " + path + " = [" + value.getType() + "] " + logEntry.getMessage()); } // handler return url as : // /isis-fish-data/trunk/scripts/version.txt // just transform in into // scripts/version.txt String relativePath = SVNPathUtil.getRelativePath(repoPath, repoRootPath + path); // tranform SVNLogEntryPath into file File file = new File(getLocalRepository().getAbsoluteFile() + File.separator + relativePath); changLog.put(file, logEntry.getMessage()); } } };
/** * Creates a new replication editor. * * <p> * <code>repository</code> must be created for the root location of * the source repository which is to be replicated. * * @param repository a source repository * @param commitEditor a commit editor received from the destination * repository driver (which also must be point to the * root location of the destination repository) * @param revision log information of the revision to be copied */ public SVNReplicationEditor(SVNRepository repository, ISVNEditor commitEditor, SVNLogEntry revision) { myRepos = repository; myCommitEditor = commitEditor; myPathsToFileBatons = new SVNHashMap(); myDirsStack = new Stack(); myCopiedPaths = new SVNHashMap(); myChangedPaths = revision.getChangedPaths(); myDeletedPaths = new SVNHashSet(); for(Iterator paths = myChangedPaths.keySet().iterator(); paths.hasNext();){ String path = (String)paths.next(); SVNLogEntryPath pathChange = (SVNLogEntryPath)myChangedPaths.get(path); //make sure it's a copy if((pathChange.getType() == SVNLogEntryPath.TYPE_REPLACED || pathChange.getType() == SVNLogEntryPath.TYPE_ADDED) && pathChange.getCopyPath() != null && pathChange.getCopyRevision() >= 0){ myCopiedPaths.put(path, pathChange); } } }
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 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); } } }
public static void handleLogMessage(SVNLogEntry logEntry, LogMessageCallback handler) { if(logEntry == null || handler == null) { return; } Map cpaths = logEntry.getChangedPaths(); ChangePath[] cp = null; if (cpaths == null) { cp = new ChangePath[]{}; } else { Collection clientChangePaths = new ArrayList(); for (Iterator iter = cpaths.keySet().iterator(); iter.hasNext();) { String path = (String) iter.next(); SVNLogEntryPath entryPath = (SVNLogEntryPath)cpaths.get(path); if(entryPath != null){ clientChangePaths.add(new ChangePath(path, entryPath.getCopyRevision(), entryPath.getCopyPath(), entryPath.getType(), getNodeKind(entryPath.getKind()))); } } cp = (ChangePath[]) clientChangePaths.toArray(new ChangePath[clientChangePaths.size()]); } SVNProperties revisionProperties = logEntry.getRevisionProperties(); Map revisionPropertiesMap = new HashMap(); for(Iterator names = revisionProperties.nameSet().iterator(); names.hasNext();) { String name = (String) names.next(); revisionPropertiesMap.put(name, revisionProperties.getStringValue(name)); } handler.singleMessage(cp, logEntry.getRevision(), revisionPropertiesMap, logEntry.hasChildren()); }
public static void handleLogMessage(SVNLogEntry logEntry, LogMessageCallback handler) { if(logEntry == null || handler == null) { return; } Map cpaths = logEntry.getChangedPaths(); ChangePath[] cp = null; if (cpaths == null) { cp = new ChangePath[]{}; } else { Collection clientChangePaths = new ArrayList(); for (Iterator iter = cpaths.keySet().iterator(); iter.hasNext();) { String path = (String) iter.next(); SVNLogEntryPath entryPath = (SVNLogEntryPath)cpaths.get(path); if(entryPath != null){ clientChangePaths.add(new ChangePath(path, entryPath.getCopyRevision(), entryPath.getCopyPath(), entryPath.getType(), getNodeKind(entryPath.getKind()))); } } cp = (ChangePath[]) clientChangePaths.toArray(new ChangePath[clientChangePaths.size()]); } SVNProperties revisionProperties = logEntry.getRevisionProperties(); Map revisionPropertiesMap = new HashMap(); for(Iterator names = revisionProperties.nameSet().iterator(); names.hasNext();) { String name = (String) names.next(); revisionPropertiesMap.put(name, revisionProperties.getStringValue(name)); } handler.singleMessage(cp, logEntry.getRevision(), revisionPropertiesMap, logEntry.hasChildren()); }
public static LogMessage createLogMessage(SVNLogEntry logEntry) { if(logEntry == null){ return null; } Map cpaths = logEntry.getChangedPaths(); ChangePath[] cp = null; if(cpaths == null){ cp = new ChangePath[]{}; }else{ Collection clientChangePaths = new ArrayList(); for (Iterator iter = cpaths.keySet().iterator(); iter.hasNext();) { String path = (String) iter.next(); SVNLogEntryPath entryPath = (SVNLogEntryPath)cpaths.get(path); if(entryPath != null){ clientChangePaths.add(new ChangePath(path, entryPath.getCopyRevision(), entryPath.getCopyPath(), entryPath.getType())); } } cp = (ChangePath[]) clientChangePaths.toArray(new ChangePath[clientChangePaths.size()]); } return new LogMessage(logEntry.getMessage(), logEntry.getDate(), logEntry.getRevision(), logEntry.getAuthor(), cp); }
public static LogMessage createLogMessage(SVNLogEntry logEntry) { if(logEntry == null){ return null; } Map cpaths = logEntry.getChangedPaths(); ChangePath[] cp = null; if(cpaths == null){ cp = new ChangePath[]{}; }else{ Collection clientChangePaths = new ArrayList(); for (Iterator iter = cpaths.keySet().iterator(); iter.hasNext();) { String path = (String) iter.next(); SVNLogEntryPath entryPath = (SVNLogEntryPath)cpaths.get(path); if(entryPath != null){ clientChangePaths.add(new ChangePath(path, entryPath.getCopyRevision(), entryPath.getCopyPath(), entryPath.getType(), getNodeKind(entryPath.getKind()))); } } cp = (ChangePath[]) clientChangePaths.toArray(new ChangePath[clientChangePaths.size()]); // sort by paths. Arrays.sort(cp, CHANGE_PATH_COMPARATOR); } long time = 0; if (logEntry.getDate() != null) { time = logEntry.getDate().getTime()*1000; if (logEntry.getDate() instanceof SVNDate) { time = ((SVNDate) logEntry.getDate()).getTimeInMicros(); } } return new LogMessage(cp, logEntry.getRevision(), logEntry.getAuthor(), time, logEntry.getMessage()); }
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); } } } }
if (logEntryPath.getType() == 'A' || !operativeChildren.containsKey(potentialChild)) { operativeChildren.put(potentialChild, path);
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()))); }