public byte[] getRevisionProperty(long revision, String propertyName) throws ClientException { try { final SVNPropertyValue propertyValue = svnRepository.getRevisionPropertyValue(revision, propertyName); return SVNPropertyValue.getPropertyAsBytes(propertyValue); } catch (SVNException e) { throw ClientException.fromException(e); } }
public String getRevisionProperty(long revision, String propertyName) throws SVNException { SVNPropertyValue value = getRepository().getRevisionPropertyValue(revision, propertyName); return value == null ? null : value.getString(); }
public long getRevisionTimeStamp(String revision){ long revisionTimeStampMilliSecond = 0; try { //An "svn:date" revision property that is a date & time stamp representing the time when the revision was created. SVNPropertyValue propertyValue = rootRepo.getRevisionPropertyValue(Long.parseLong(revision),SVNRevisionProperty.DATE); String stringValue = SVNPropertyValue.getPropertyAsString(propertyValue); //SVNDate date = SVNDate.parseDate(stringValue); revisionTimeStampMilliSecond = SVNDate.parseDateAsMilliseconds(stringValue); //revisionTimeStampMicroSecond = date.getTimeInMicros(); } catch (SVNException e) { // TODO Auto-generated catch block //e.printStackTrace(); SvnClient.log.error("Error when retrieving time stamp for revision : " + revision + " "+ e.getMessage()); } return revisionTimeStampMilliSecond; }
private void doGetRevisionProperty(SVNRepository repos, String propName, long revNumber, ISVNPropertyHandler handler) throws SVNException { if (propName != null) { String value = repos.getRevisionPropertyValue(revNumber, propName); if (value != null) { handler.handleProperty(revNumber, new SVNPropertyData(propName, value)); } } else { Map props = new HashMap(); repos.getRevisionProperties(revNumber, props); for (Iterator names = props.keySet().iterator(); names.hasNext();) { String name = (String) names.next(); String value = (String) props.get(name); handler.handleProperty(revNumber, new SVNPropertyData(name, value)); } } }
private SessionInfo openSourceRepository(SVNRepository targetRepos) throws SVNException { String fromURL = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_URL); String fromUUID = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_UUID); String lastMergedRev = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.LAST_MERGED_REVISION); if (fromURL == null || fromUUID == null || lastMergedRev == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Destination repository has not been initialized"); SVNErrorManager.error(err); } SVNURL srcURL = SVNURL.parseURIDecoded(fromURL); SVNRepository srcRepos = createRepository(srcURL, false); checkIfRepositoryIsAtRoot(srcRepos, srcURL); String reposUUID = srcRepos.getRepositoryUUID(true); if (!fromUUID.equals(reposUUID)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "UUID of destination repository ({0}) does not match expected UUID ({1})", new String[] { reposUUID, fromUUID }); SVNErrorManager.error(err); } return new SessionInfo(srcRepos, Long.parseLong(lastMergedRev)); }
private SessionInfo openSourceRepository(SVNRepository targetRepos) throws SVNException { SVNPropertyValue fromURL = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_URL); SVNPropertyValue fromUUID = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_UUID); SVNPropertyValue lastMergedRev = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.LAST_MERGED_REVISION); if (fromURL == null || fromUUID == null || lastMergedRev == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Destination repository has not been initialized"); SVNErrorManager.error(err, SVNLogType.FSFS); } SVNURL srcURL = SVNURL.parseURIEncoded(fromURL.getString()); SVNRepository srcRepos = createRepository(srcURL, fromUUID.getString(), false); try { return new SessionInfo(srcRepos, Long.parseLong(lastMergedRev.getString())); } catch (NumberFormatException nfe) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, nfe), SVNLogType.FSFS); } return null; }
private SessionInfo openSourceRepository(SVNRepository targetRepos) throws SVNException { SVNPropertyValue fromURL = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_URL); SVNPropertyValue fromUUID = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_UUID); SVNPropertyValue lastMergedRev = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.LAST_MERGED_REVISION); if (fromURL == null || fromUUID == null || lastMergedRev == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Destination repository has not been initialized"); SVNErrorManager.error(err, SVNLogType.FSFS); } SVNURL srcURL = SVNURL.parseURIDecoded(fromURL.getString()); SVNRepository srcRepos = createRepository(srcURL, fromUUID.getString(), false); try { return new SessionInfo(srcRepos, Long.parseLong(lastMergedRev.getString())); } catch (NumberFormatException nfe) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, nfe), SVNLogType.FSFS); } return null; }
private SessionInfo openSourceRepository(SVNRepository targetRepos) throws SVNException { SVNPropertyValue fromURL = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_URL); SVNPropertyValue fromUUID = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_UUID); SVNPropertyValue lastMergedRev = targetRepos.getRevisionPropertyValue(0, SVNRevisionProperty.LAST_MERGED_REVISION); if (fromURL == null || fromUUID == null || lastMergedRev == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Destination repository has not been initialized"); SVNErrorManager.error(err, SVNLogType.FSFS); } SVNURL srcURL = SVNURL.parseURIDecoded(fromURL.getString()); SVNRepository srcRepos = createRepository(srcURL, fromUUID.getString(), false); try { return new SessionInfo(srcRepos, Long.parseLong(lastMergedRev.getString())); } catch (NumberFormatException nfe) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, nfe), SVNLogType.FSFS); } return null; }
int i = 0; for (i = 0; i < 10; i++) { String reposLockToken = repos.getRevisionPropertyValue(0, SVNRevisionProperty.LOCK); if (reposLockToken != null) { if (reposLockToken.equals(lockToken)) {
/** * Returns information about the synchronization repository located at <code>toURL</code>. * * @param toURL destination repository url * @return synchronization information * @throws SVNException * @since 1.3, SVN 1.6 */ public SVNSyncInfo doInfo(SVNURL toURL) throws SVNException { SVNRepository toRepos = null; try { toRepos = createRepository(toURL, null, true); checkIfRepositoryIsAtRoot(toRepos, toURL); SVNPropertyValue fromURL = toRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_URL); if (fromURL == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_URL, "Repository ''{0}'' is not initialized for synchronization", toURL); SVNErrorManager.error(err, SVNLogType.FSFS); } SVNPropertyValue fromUUID = toRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_UUID); SVNPropertyValue lastMergedRevProp = toRepos.getRevisionPropertyValue(0, SVNRevisionProperty.LAST_MERGED_REVISION); long lastMergedRev = lastMergedRevProp != null ? Long.parseLong(lastMergedRevProp.getString()) : SVNRepository.INVALID_REVISION; return new SVNSyncInfo(fromURL.getString(), fromUUID != null ? fromUUID.getString() : null, lastMergedRev); } finally { if (toRepos != null) { toRepos.closeSession(); } } }
toRepos = createRepository(toURL, null, true); checkIfRepositoryIsAtRoot(toRepos, toURL); SVNPropertyValue fromURL = toRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_URL); if (fromURL == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_URL, "Repository ''{0}'' is not initialized for synchronization", SVNPropertyValue fromUUID = toRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_UUID); SVNPropertyValue lastMergedRevProp = toRepos.getRevisionPropertyValue(0, SVNRevisionProperty.LAST_MERGED_REVISION); long lastMergedRev = lastMergedRevProp != null ? Long.parseLong(lastMergedRevProp.getString()) : SVNRepository.INVALID_REVISION; return new SVNSyncInfo(fromURL.getString(), fromUUID != null ? fromUUID.getString() : null, lastMergedRev);
toRepos = createRepository(toURL, null, true); checkIfRepositoryIsAtRoot(toRepos, toURL); SVNPropertyValue fromURL = toRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_URL); if (fromURL == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_URL, "Repository ''{0}'' is not initialized for synchronization", SVNPropertyValue fromUUID = toRepos.getRevisionPropertyValue(0, SVNRevisionProperty.FROM_UUID); SVNPropertyValue lastMergedRevProp = toRepos.getRevisionPropertyValue(0, SVNRevisionProperty.LAST_MERGED_REVISION); long lastMergedRev = lastMergedRevProp != null ? Long.parseLong(lastMergedRevProp.getString()) : SVNRepository.INVALID_REVISION; return new SVNSyncInfo(fromURL.getString(), fromUUID != null ? fromUUID.getString() : null, lastMergedRev);
private void doGetRevisionProperty(SVNRepository repos, String propName, long revNumber, ISVNPropertyHandler handler) throws SVNException { if (propName != null) { SVNPropertyValue value = repos.getRevisionPropertyValue(revNumber, propName); if (value != null) { handler.handleProperty(revNumber, new SVNPropertyData(propName, value, getOptions())); } } else { SVNProperties props = new SVNProperties(); repos.getRevisionProperties(revNumber, props); for (Iterator names = props.nameSet().iterator(); names.hasNext();) { String name = (String) names.next(); SVNPropertyValue value = props.getSVNPropertyValue(name); handler.handleProperty(revNumber, new SVNPropertyData(name, value, getOptions())); } } }
private void doGetRevisionProperty(SVNRepository repos, String propName, long revNumber, ISVNPropertyHandler handler) throws SVNException { if (propName != null) { SVNPropertyValue value = repos.getRevisionPropertyValue(revNumber, propName); if (value != null) { handler.handleProperty(revNumber, new SVNPropertyData(propName, value, getOptions())); } } else { SVNProperties props = new SVNProperties(); repos.getRevisionProperties(revNumber, props); for (Iterator names = props.nameSet().iterator(); names.hasNext();) { String name = (String) names.next(); SVNPropertyValue value = props.getSVNPropertyValue(name); handler.handleProperty(revNumber, new SVNPropertyData(name, value, getOptions())); } } }
private void doGetRevisionProperty(SVNRepository repos, String propName, long revNumber, ISVNPropertyHandler handler) throws SVNException { if (propName != null) { SVNPropertyValue value = repos.getRevisionPropertyValue(revNumber, propName); if (value != null) { handler.handleProperty(revNumber, new SVNPropertyData(propName, value, getOptions())); } } else { SVNProperties props = new SVNProperties(); repos.getRevisionProperties(revNumber, props); for (Iterator names = props.nameSet().iterator(); names.hasNext();) { String name = (String) names.next(); SVNPropertyValue value = props.getSVNPropertyValue(name); handler.handleProperty(revNumber, new SVNPropertyData(name, value, getOptions())); } } }
for (i = 0; i < LOCK_RETRY_COUNT; i++) { checkCancelled(); SVNPropertyValue reposLockToken = repos.getRevisionPropertyValue(0, SVNRevisionProperty.LOCK); if (reposLockToken != null) { if (lockToken.equals(reposLockToken.getString())) {
while (true) { try { SVNRepositoryFactory.create(url).getRevisionPropertyValue(0, "example"); } catch (SVNAuthenticationException ignored) { break;
@Test public void testReplayFileModification() throws Exception { try (SvnTestServer server = SvnTestServer.createEmpty()) { final URL repoMark = ReplayTest.class.getResource("repo/format"); final SVNURL url = SVNURL.fromFile(new File(repoMark.getPath()).getParentFile()); final SVNRepository srcRepo = SVNRepositoryFactory.create(url); final SVNRepository dstRepo = server.openSvnRepository(); long lastRevision = srcRepo.getLatestRevision(); log.info("Start replay"); for (long revision = 1; revision <= lastRevision; revision++) { final SVNPropertyValue message = srcRepo.getRevisionPropertyValue(revision, "svn:log"); log.info(" replay commit #{}: {}", revision, StringHelper.getFirstLine(message.getString())); replayRangeRevision(srcRepo, dstRepo, revision, false); log.info(" compare revisions #{}: {}", revision, StringHelper.getFirstLine(message.getString())); compareRevision(srcRepo, revision, dstRepo, dstRepo.getLatestRevision()); } log.info("End replay"); } }
private void checkReplaySelf(@NotNull ReplayMethod replayMethod) throws Exception { try ( SvnTestServer src = SvnTestServer.createMasterRepository(); SvnTestServer dst = SvnTestServer.createEmpty() ) { final SVNRepository srcRepo = src.openSvnRepository(); final SVNRepository dstRepo = dst.openSvnRepository(); final Repository srcGit = src.getRepository(); final Repository dstGit = dst.getRepository(); final long lastRevision = Math.min(200, srcRepo.getLatestRevision()); log.info("Start replay"); for (long revision = 1; revision <= lastRevision; revision++) { final SVNPropertyValue message = srcRepo.getRevisionPropertyValue(revision, "svn:log"); final SVNPropertyValue srcHash = srcRepo.getRevisionPropertyValue(revision, SvnConstants.PROP_GIT); log.info(" replay commit #{} {}: {}", revision, new String(srcHash.getBytes()), StringHelper.getFirstLine(message.getString())); replayMethod.replay(srcRepo, dstRepo, revision); log.info(" compare revisions #{}: {}", revision, StringHelper.getFirstLine(message.getString())); compareRevision(srcRepo, revision, dstRepo, revision); final SVNPropertyValue dstHash = dstRepo.getRevisionPropertyValue(revision, SvnConstants.PROP_GIT); compareGitRevision(srcGit, srcHash, dstGit, dstHash); } log.info("End replay"); } }
private void updateRevision(@NotNull SVNRepository srcRepo, @NotNull SVNRepository dstRepo, long revision) throws SVNException { final SVNPropertyValue message = srcRepo.getRevisionPropertyValue(revision, "svn:log"); final CopyFromSVNEditor editor = new CopyFromSVNEditor(dstRepo.getCommitEditor(message.getString(), null), "/", true); srcRepo.update(revision, "", SVNDepth.INFINITY, true, reporter -> { reporter.setPath("", null, revision - 1, SVNDepth.INFINITY, false); reporter.finishReport(); }, new FilterSVNEditor(editor, true)); checkCopyFrom(srcRepo, editor, revision); }