private String update(SvnOperationFactory svnOperationFactory, String label) throws SVNException { logger.debug("Repo already checked out - updating instead."); try { final SvnUpdate update = svnOperationFactory.createUpdate(); update.setSingleTarget(SvnTarget.fromFile(getWorkingDirectory())); long[] ids = update.run(); StringBuilder version = new StringBuilder(); for (long id : ids) { if (version.length() > 0) { version.append(","); } version.append(id); } return version.toString(); } catch (Exception e) { String message = "Could not update remote for " + label + " (current local=" + getWorkingDirectory().getPath() + "), remote: " + this.getUri() + ")"; if (logger.isDebugEnabled()) { logger.debug(message, e); } else if (logger.isWarnEnabled()) { logger.warn(message); } } final SVNStatus status = SVNClientManager.newInstance().getStatusClient() .doStatus(getWorkingDirectory(), false); return status != null ? status.getRevision().toString() : null; }
private String asString(SVNRevision revision, String path) throws SVNException { if (revision == SVNRevision.HEAD || SVNRevision.isValidRevisionNumber(revision.getNumber())) { return revision.toString(); } SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.INCORRECT_PARAMS, "Illegal file external revision kind {0} for path ''{1}''", new Object[] { revision.toString(), path }); SVNErrorManager.error(err, SVNLogType.WC); return null; }
public static String asString(SVNRevision revision, String path) throws SVNException { if (revision == SVNRevision.HEAD || SVNRevision.isValidRevisionNumber(revision.getNumber())) { return revision.toString(); } SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.INCORRECT_PARAMS, "Illegal file external revision kind {0} for path ''{1}''", new Object[] { revision.toString(), path }); SVNErrorManager.error(err, SVNLogType.WC); return null; }
private String asString(SVNRevision revision, String path) throws SVNException { if (revision == SVNRevision.HEAD || SVNRevision.isValidRevisionNumber(revision.getNumber())) { return revision.toString(); } SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.INCORRECT_PARAMS, "Illegal file external revision kind {0} for path ''{1}''", new Object[] { revision.toString(), path }); SVNErrorManager.error(err, SVNLogType.WC); return null; }
/** * Updates an existing local working copy from the repository. * * @return the revision of the fetched content * * @throws IOException thrown if there is a problem updating the working copy */ private SVNRevision updateResourceDirectory() throws IOException { try { final long newRevision = clientManager.getUpdateClient().doUpdate(workingCopyDirectory, retrievalRevision, SVNDepth.INFINITY, true, true); log.debug("Updated local working directory {} to revision {} from remote repository {}", new Object[] { workingCopyDirectory.getAbsolutePath(), newRevision, remoteRepository.toDecodedString(),}); return SVNRevision.create(newRevision); } catch (final SVNException e) { final String errMsg = "Unable to update working copy of resoure " + remoteRepository.toDecodedString() + " in working copy " + workingCopyDirectory.getAbsolutePath() + " to revsion " + retrievalRevision.toString(); log.error(errMsg, e); throw new IOException(errMsg, e); } }
/** * Checks out the resource specified by the {@link #remoteRepository} in to the working copy * {@link #workingCopyDirectory}. If the working copy is empty than an SVN checkout is performed if the working copy * already exists then an SVN update is performed. * * @throws ResourceException thrown if there is a problem communicating with the remote repository, the revision * does not exist, or the working copy is unusable */ protected void checkoutOrUpdateResource() throws ResourceException { log.debug("checking out or updating working copy"); SVNRevision newRevision; if (!workingCopyDirectoryExists()) { log.debug("working copy does not yet exist, checking it out"); newRevision = checkoutResourceDirectory(); } else { if (retrievalRevision != SVNRevision.HEAD) { log.debug("Working copy exists and version is pegged at {}, no need to update", retrievalRevision.toString()); return; } log.debug("Working copy exists, updating to latest version."); newRevision = updateResourceDirectory(); } log.debug("Determing last modification date of revision {}", newRevision.getNumber()); lastModified = getLastModificationForRevision(newRevision); }
/** * Fetches the content from the SVN repository and creates the local working copy. * * @return the revision of the fetched content * * @throws IOException thrown if there is a problem checking out the content from the repository */ private SVNRevision checkoutResourceDirectory() throws IOException { try { final long newRevision = clientManager.getUpdateClient().doCheckout(remoteRepository, workingCopyDirectory, retrievalRevision, retrievalRevision, SVNDepth.INFINITY, true); log.debug( "Checked out revision {} from remote repository {} and stored it in local working directory {}", new Object[] {newRevision, remoteRepository.toDecodedString(), workingCopyDirectory.getAbsolutePath(),}); return SVNRevision.create(newRevision); } catch (final SVNException e) { final String errMsg = "Unable to check out revsion " + retrievalRevision.toString() + " from remote repository " + remoteRepository.toDecodedString() + " to local working directory " + workingCopyDirectory.getAbsolutePath(); log.error(errMsg, e); throw new IOException(errMsg, e); } }
/** * Checks out the resource specified by the {@link #remoteRepository} in to the working copy * {@link #workingCopyDirectory}. If the working copy is empty than an SVN checkout is performed if the working copy * already exists then an SVN update is performed. * * @throws IOException thrown if there is a problem communicating with the remote repository, the revision does not * exist, or the working copy is unusable */ protected void checkoutOrUpdateResource() throws IOException { log.debug("checking out or updating working copy"); final SVNRevision newRevision; if (!workingCopyDirectoryExists()) { log.debug("Working copy does not yet exist, checking it out to {}", workingCopyDirectory.getAbsolutePath()); newRevision = checkoutResourceDirectory(); } else { if (retrievalRevision != SVNRevision.HEAD) { lastModified = getLastModificationForRevision(SVNRevision.HEAD); log.debug("Working copy exists and version is pegged at {}, no need to update", retrievalRevision.toString()); return; } log.debug("Working copy exists, updating to latest version."); newRevision = updateResourceDirectory(); } if (getFile().exists()) { log.debug("Determining last modification date of revision {}", newRevision.getNumber()); lastModified = getLastModificationForRevision(newRevision); } }
/** * Updates an existing local working copy from the repository. * * @return the revision of the fetched content * * @throws ResourceException thrown if there is a problem updating the working copy */ private SVNRevision updateResourceDirectory() throws ResourceException { try { long newRevision = clientManager.getUpdateClient().doUpdate(workingCopyDirectory, retrievalRevision, SVNDepth.INFINITY, true, true); log.debug("Updated local working directory {} to revision {} from remote repository {}", new Object[] { workingCopyDirectory.getAbsolutePath(), newRevision, remoteRepository.toDecodedString(), }); return SVNRevision.create(newRevision); } catch (SVNException e) { String errMsg = "Unable to update working copy of resoure " + remoteRepository.toDecodedString() + " in working copy " + workingCopyDirectory.getAbsolutePath() + " to revsion " + retrievalRevision.toString(); log.error(errMsg, e); throw new ResourceException(errMsg, e); } }
/** * Fetches the content from the SVN repository and creates the local working copy. * * @return the revision of the fetched content * * @throws ResourceException thrown if there is a problem checking out the content from the repository */ private SVNRevision checkoutResourceDirectory() throws ResourceException { try { long newRevision = clientManager.getUpdateClient().doCheckout(remoteRepository, workingCopyDirectory, retrievalRevision, retrievalRevision, SVNDepth.INFINITY, true); log.debug( "Checked out revision {} from remote repository {} and stored it in local working directory {}", new Object[] { newRevision, remoteRepository.toDecodedString(), workingCopyDirectory.getAbsolutePath(), }); return SVNRevision.create(newRevision); } catch (SVNException e) { String errMsg = "Unable to check out revsion " + retrievalRevision.toString() + " from remote repository " + remoteRepository.toDecodedString() + " to local working directory " + workingCopyDirectory.getAbsolutePath(); log.error(errMsg, e); throw new ResourceException(errMsg, e); } }
public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("merge task: source from "); buffer.append(getMergeSource()); buffer.append("; source to"); buffer.append(getMergeSource2()); buffer.append("; target "); buffer.append(getMergeTarget()); buffer.append("; revision ranges "); if (getRemainingRanges() == null) { buffer.append("[NULL]"); } else { buffer.append(getRemainingRanges().toString()); } buffer.append("; copy source "); if (getTargetCopySource() != null) { buffer.append(getTargetCopySource().isURL() ? getTargetCopySource().getURL().toString() : getTargetCopySource().getFile().getAbsolutePath()); buffer.append("@"); buffer.append(getTargetCopySource().getPegRevision().toString()); buffer.append(" revision "); buffer.append(getTargetCopySource().getRevision()); } else { buffer.append("[NULL]"); } return buffer.toString(); } }
@Override public String getHeadRevisionNumber(String path, String username, String password) throws AuthenticationException { if (log.isDebugEnabled()) { log.debug("headRevisionNumber expected " + addressSvn + " ; got " + path); } ISVNAuthenticationManager svnAuthManager = SVNWCUtil.createDefaultAuthenticationManager(username, password); DefaultSVNOptions svnOptions = new DefaultSVNOptions(); svnOptions.setPropertyValue(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_LF); SVNWCClient wcClient = new SVNWCClient(svnAuthManager, svnOptions); SVNInfo info = null; try { info = wcClient.doInfo(SVNURL.parseURIEncoded(path), SVNRevision.HEAD, SVNRevision.HEAD); } catch (SVNAuthenticationException e) { throw new AuthenticationException("Auth fail"); } catch (SVNException e) { if (log.isErrorEnabled()) { log.error("Can not get info from SVN repository", e); } } String headRevision = ""; if (info != null) { headRevision = info.getRevision().toString(); } return headRevision; }
if (listener != null) { listener.getLogger().println("Checking out " + l.remote + " revision: " + (revision != null ? revision.toString() : "null") + " depth:" + svnDepth + " ignoreExternals: " + l.isIgnoreExternalsOption());
(revision != null ? revision.toString() : "null") + " depth:" + svnDepth + " ignoreExternals: " + l.isIgnoreExternalsOption()); svnuc.doUpdate(local.getCanonicalFile(), revision, svnDepth, true, false);
(revision != null ? revision.toString() : "null") + " depth:" + svnDepth + " ignoreExternals: " + l.isIgnoreExternalsOption()); svnuc.doSwitch(local.getCanonicalFile(), l.getSVNURL(), SVNRevision.HEAD, revision, svnDepth, true, false);
(revision != null ? revision.toString() : "null") + " depth:" + svnDepth + " ignoreExternals: " + l.isIgnoreExternalsOption()); svnuc.doUpdate(local.getCanonicalFile(), revision, svnDepth, true, false);