protected long getPathLastChangeRevision(String relPath, long revision, SVNRepository repository) throws SVNException { final long[] rev = new long[1]; rev[0] = SVNRepository.INVALID_REVISION; repository.log(new String[] { relPath }, 1, revision, false, true, 1, false, null, new ISVNLogEntryHandler() { public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { rev[0] = logEntry.getRevision(); } }); return rev[0]; }
protected long getPathLastChangeRevision(String relPath, long revision, SVNRepository repository) throws SVNException { final long[] rev = new long[1]; rev[0] = SVNRepository.INVALID_REVISION; repository.log(new String[] { relPath }, 1, revision, false, true, 1, false, null, new ISVNLogEntryHandler() { public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { rev[0] = logEntry.getRevision(); } }); return rev[0]; }
protected long getPathLastChangeRevision(String relPath, long revision, SVNRepository repository) throws SVNException { final long[] rev = new long[1]; rev[0] = SVNRepository.INVALID_REVISION; repository.log(new String[] { relPath }, 1, revision, false, true, 1, false, null, new ISVNLogEntryHandler() { public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { rev[0] = logEntry.getRevision(); } }); return rev[0]; }
private void updateCommitLog(Date _as_of) throws SVNException { // In all of the following cases, no further log entries must be collected if(this.logEntries!=null && (this.asOf==null || (_as_of!=null && this.asOf.before(_as_of)))) return; // Retrieve the log this.asOf = _as_of; final long latest_rev = this.rootRepo.getLatestRevision(); // Search as of ... long first_rev = 0; if(this.asOf!=null) first_rev = this.rootRepo.getDatedRevision(this.asOf); this.logEntries = rootRepo.log(new String[] { "" }, null, first_rev, latest_rev, true, true); }
private long getDeletedRevisionFromLog(String path, long pegRevision, long endRevision) throws SVNException { DeletedRevisionLogHandler handler = new DeletedRevisionLogHandler(path); log(null, pegRevision, endRevision, true, true, 0, false, null, handler); return handler.getDeletedRevision(); }
private long getDeletedRevisionFromLog(String path, long pegRevision, long endRevision) throws SVNException { DeletedRevisionLogHandler handler = new DeletedRevisionLogHandler(path); log(null, pegRevision, endRevision, true, true, 0, false, null, handler); return handler.getDeletedRevision(); }
private long getDeletedRevisionFromLog(String path, long pegRevision, long endRevision) throws SVNException { DeletedRevisionLogHandler handler = new DeletedRevisionLogHandler(path); log(null, pegRevision, endRevision, true, true, 0, false, null, handler); return handler.getDeletedRevision(); }
private Map<File, String> getOperativeImmediateChildren(File mergeSourceFsPath, long oldestRevision, long youngestRevision, File mergeTargetAbsPath, SVNDepth depth, SVNRepository repository) throws SVNException { assert SVNRevision.isValidRevisionNumber(oldestRevision); assert SVNRevision.isValidRevisionNumber(youngestRevision); assert oldestRevision <= youngestRevision; Map<File, String> operativeChildren = new HashMap<File, String>(); if (depth == SVNDepth.INFINITY) { return operativeChildren; } FindOperativeSubtreeRevisions findOperativeSubtreeRevisions = new FindOperativeSubtreeRevisions(operativeChildren, context, mergeSourceFsPath, mergeTargetAbsPath, depth); repository.log(new String[]{""}, youngestRevision, oldestRevision, true, false, 0, false, null, findOperativeSubtreeRevisions); return operativeChildren; }
/** * Method description * * * @param repo * @param start * @param limit * * @return * * @throws SVNException */ private ChangesetPagingResult getChangesets(SVNRepository repo, int start, int limit) throws SVNException { long latest = repo.getLatestRevision(); long startRev = latest - start; long endRev = Math.max(startRev - (limit - 1), 0); final List<Changeset> changesets = Lists.newArrayList(); if (startRev > 0) { logger.debug("fetch changeset from {} to {}", startRev, endRev); repo.log(null, startRev, endRev, true, true, new ChangesetCollector(changesets)); } return new ChangesetPagingResult((int) (latest + 1l), changesets); }
private List<SVNLogEntry> doFilter(final SVNLogFilter logFilter) throws SVNException { final List<SVNLogEntry> log = new ArrayList<>(); ISVNLogEntryHandler logGatherer = logEntry -> { if (logFilter.isIncluded(logEntry)) { log.add(logEntry); } }; svnRepo.log(empty, 1, 5, true, false, logGatherer); return log; }
private void checkLogLimit(@NotNull SVNRepository repo, long r1, long r2, int limit, @NotNull String path, @NotNull LogEntry... expecteds) throws SVNException { final List<LogEntry> actual = new ArrayList<>(); repo.log(new String[]{path}, r1, r2, true, false, limit, logEntry -> actual.add(new LogEntry(logEntry))); ArrayAsserts.assertArrayEquals(expecteds, actual.toArray(new LogEntry[actual.size()])); } }
@NotNull private List<Long> loadUpdateRevisions(@NotNull SVNRepository repo, @NotNull String path) throws SVNException { final long maxRevision = repo.getLatestRevision(); final LinkedList<Long> revisions = new LinkedList<>(); repo.log(new String[]{path}, maxRevision, 0, false, false, logEntry -> revisions.addFirst(logEntry.getRevision())); return new ArrayList<>(revisions); }
@SuppressWarnings("rawtypes") @Override public List<ChangeSet> getChangeSets() { SVNRepository repository = null; try { SVNURL url = SVNURL.parseURIEncoded(path); repository = SVNRepositoryFactory.create(url); authenticateIfNecessary(repository); List<ChangeSet> allCs = new ArrayList<ChangeSet>(); long startRevision = 0; long endRevision = -1; // HEAD (the latest) revision Collection log = repository.log(new String[] { "" }, null, startRevision, endRevision, true, true); for (Iterator iterator = log.iterator(); iterator.hasNext();) { SVNLogEntry entry = (SVNLogEntry) iterator.next(); allCs.add(new ChangeSet(String.valueOf(entry.getRevision()), convertToCalendar(entry.getDate()))); } return allCs; } catch (SVNException e) { throw new RuntimeException("error in getHead() for " + path, e); } finally { if (repository != null) repository.closeSession(); } }
public void getLog(Iterable<String> paths, long startRevision, long endRevision, int limit, boolean strictNodeHistory, boolean discoverPath, boolean includeMergedRevisions, Iterable<String> revisionProperties, LogMessageCallback callback) throws ClientException { try { svnRepository.log(SVNClientImpl.getStrings(paths), startRevision, endRevision, discoverPath, strictNodeHistory, limit, includeMergedRevisions, SVNClientImpl.getStrings(revisionProperties), SVNClientImpl.getLogEntryHandler(callback)); } catch (SVNException e) { throw ClientException.fromException(e); } }
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); }
/** * Check commit .gitattributes. * * @throws Exception */ @Test public void commitUpdatePropertiesRoot() throws Exception { //Map<String, String> props = new HashMap<>()["key":""]; try (SvnTestServer server = SvnTestServer.createEmpty()) { final SVNRepository repo = server.openSvnRepository(); createFile(repo, "/sample.txt", "", propsEolNative); checkFileProp(repo, "/sample.txt", propsEolNative); createFile(repo, "/.gitattributes", "*.txt\t\t\ttext eol=lf\n", propsEolNative); // After commit .gitattributes file sample.txt must change property svn:eol-style automagically. checkFileProp(repo, "/sample.txt", propsEolLf); // After commit .gitattributes directory with .gitattributes must change property svn:auto-props automagically. checkDirProp(repo, "/", propsAutoProps); // After commit .gitattributes file sample.txt must change property svn:eol-style automagically. { final Set<String> changed = new HashSet<>(); repo.log(new String[]{""}, repo.getLatestRevision(), repo.getLatestRevision(), true, false, logEntry -> changed.addAll(logEntry.getChangedPaths().keySet())); Assert.assertTrue(changed.contains("/")); Assert.assertTrue(changed.contains("/.gitattributes")); Assert.assertTrue(changed.contains("/sample.txt")); Assert.assertEquals(changed.size(), 3); } } }
protected SVNLocationEntry getCopySource(File path, SVNURL url, SVNRevision revision) throws SVNException { long[] pegRev = { SVNRepository.INVALID_REVISION }; SVNRepository repos = createRepository(url, path, null, revision, revision, pegRev); SVNLocationEntry copyFromEntry = null; String targetPath = getPathRelativeToRoot(path, url, null, null, repos); CopyFromReceiver receiver = new CopyFromReceiver(targetPath); try { repos.log(new String[] { "" }, pegRev[0], 1, true, true, 0, false, new String[0], receiver); copyFromEntry = receiver.getCopyFromLocation(); } catch (SVNException e) { SVNErrorCode errCode = e.getErrorMessage().getErrorCode(); if (errCode == SVNErrorCode.FS_NOT_FOUND || errCode == SVNErrorCode.RA_DAV_REQUEST_FAILED) { return new SVNLocationEntry(SVNRepository.INVALID_REVISION, null); } throw e; } return copyFromEntry == null ? new SVNLocationEntry(SVNRepository.INVALID_REVISION, null) : copyFromEntry; }
protected SVNLocationEntry getCopySource(File path, SVNURL url, SVNRevision revision) throws SVNException { long[] pegRev = { SVNRepository.INVALID_REVISION }; SVNRepository repos = createRepository(url, path, null, revision, revision, pegRev); SVNLocationEntry copyFromEntry = null; String targetPath = getPathRelativeToRoot(path, url, null, null, repos); CopyFromReceiver receiver = new CopyFromReceiver(targetPath); try { repos.log(new String[] { "" }, pegRev[0], 1, true, true, 0, false, new String[0], receiver); copyFromEntry = receiver.getCopyFromLocation(); } catch (SVNException e) { SVNErrorCode errCode = e.getErrorMessage().getErrorCode(); if (errCode == SVNErrorCode.FS_NOT_FOUND || errCode == SVNErrorCode.RA_DAV_REQUEST_FAILED) { return new SVNLocationEntry(SVNRepository.INVALID_REVISION, null); } throw e; } return copyFromEntry == null ? new SVNLocationEntry(SVNRepository.INVALID_REVISION, null) : copyFromEntry; }
protected SVNLocationEntry getCopySource(File path, SVNURL url, SVNRevision revision) throws SVNException { long[] pegRev = { SVNRepository.INVALID_REVISION }; SVNRepository repos = createRepository(url, path, null, revision, revision, pegRev); SVNLocationEntry copyFromEntry = null; String targetPath = getPathRelativeToRoot(path, url, null, null, repos); CopyFromReceiver receiver = new CopyFromReceiver(targetPath); try { repos.log(new String[] { "" }, pegRev[0], 1, true, true, 0, false, new String[0], receiver); copyFromEntry = receiver.getCopyFromLocation(); } catch (SVNException e) { SVNErrorCode errCode = e.getErrorMessage().getErrorCode(); if (errCode == SVNErrorCode.FS_NOT_FOUND || errCode == SVNErrorCode.RA_DAV_REQUEST_FAILED) { return new SVNLocationEntry(SVNRepository.INVALID_REVISION, null); } throw e; } return copyFromEntry == null ? new SVNLocationEntry(SVNRepository.INVALID_REVISION, null) : copyFromEntry; }
public void execute() throws SVNException { myCommonReportHandler.checkSVNNamespace(null); setDAVResource(getRequestedDAVResource(false, false)); writeXMLHeader(null); for (int i = 0; i < getLogRequest().getTargetPaths().length; i++) { String currentPath = getLogRequest().getTargetPaths()[i]; DAVPathUtil.testCanonical(currentPath); getLogRequest().getTargetPaths()[i] = SVNPathUtil.append(getDAVResource().getResourceURI().getPath(), currentPath); } DAVLogRequest logRequest = getLogRequest(); getDAVResource().getRepository().log(logRequest.getTargetPaths(), logRequest.getStartRevision(), logRequest.getEndRevision(), logRequest.isDiscoverChangedPaths(), logRequest.isStrictNodeHistory(), logRequest.getLimit(), logRequest.isIncludeMergedRevisions(), logRequest.getRevisionProperties(), this); writeXMLFooter(null); }