private String checkout(SvnOperationFactory svnOperationFactory) throws SVNException { logger.debug("Checking out " + getUri() + " to: " + getWorkingDirectory().getAbsolutePath()); final SvnCheckout checkout = svnOperationFactory.createCheckout(); checkout.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(getUri()))); checkout.setSingleTarget(SvnTarget.fromFile(getWorkingDirectory())); Long id = checkout.run(); if (id == null) { return null; } return id.toString(); }
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; }
/** * Creates a target from URL * @param url target URL * @return a new <code>SvnTarget</code> object representing URL */ public static SvnTarget fromURL(SVNURL url) { return fromURL(url, SVNRevision.UNDEFINED); }
private void printInhertiedProperties(SvnTarget target, List<SvnInheritedProperties> propsList) { final String name; if (target.isURL()) { name = target.getPathOrUrlString(); } else { name = SVNCommandUtil.getLocalPath(getSVNEnvironment().getRelativePath(target.getFile())); } for (SvnInheritedProperties props : propsList) { if (!getSVNEnvironment().isQuiet()) { getSVNEnvironment().getOut().println("Inherited properties on '" + name + "',"); if (props.getTarget().isURL()) { getSVNEnvironment().getOut().println("from '" + props.getTarget().getPathOrUrlString() + "':"); } else { final String localPath = SVNCommandUtil.getLocalPath(getSVNEnvironment().getRelativePath(props.getTarget().getFile())); getSVNEnvironment().getOut().println("from '" + localPath + "':"); } } final List<SVNPropertyData> propdataList = getPropdataList(props.getProperties()); printProplist(propdataList, false); } }
/** * Determines whether target is remote or local, and returns corresponding <code>String</code> * representation of the target's path and peg revision. * * @return <code>String</code> of the target's path and peg revision */ public String toString() { if (isFile()) { return getFile().getAbsolutePath() + '@' + getPegRevision(); } else if (isURL()) { return getURL().toString() + '@' + getPegRevision(); } return "INVALID TARGET"; } }
@Override protected SVNCommitInfo run() throws SVNException { SVNCommitInfo info = doRun(); if (info != null) { Collection<SvnTarget> targets = getOperation().getTargets(); if (targets != null && targets.size() != 0) { SvnTarget firstTarget = targets.iterator().next(); SVNRepository repository = getRepositoryAccess().createRepository(firstTarget.getURL(), null, true); SVNURL repositoryRoot = repository.getRepositoryRoot(true); getOperation().receive(SvnTarget.fromURL(repositoryRoot), info); } } return info; }
@Override public boolean isApplicable(SvnLogMergeInfo operation, SvnWcGeneration wcGeneration) throws SVNException { boolean targetOk = operation.getFirstTarget().isURL() || SvnOperationFactory.detectWcGeneration(operation.getFirstTarget().getFile(), true) == SvnWcGeneration.V17; boolean sourceOk = operation.getSource().isURL() || SvnOperationFactory.detectWcGeneration(operation.getSource().getFile(), true) == SvnWcGeneration.V17; return targetOk && sourceOk; }
@Override protected Map<SVNURL, SVNMergeRangeList> run() throws SVNException { SVNDiffClient16 dc = new SVNDiffClient16(getOperation().getAuthenticationManager(), getOperation().getOptions()); if (getOperation().getFirstTarget().isURL()) { return dc.doGetMergedMergeInfo(getOperation().getFirstTarget().getURL(), getOperation().getFirstTarget().getResolvedPegRevision()); } return dc.doGetMergedMergeInfo(getOperation().getFirstTarget().getFile(), getOperation().getFirstTarget().getResolvedPegRevision()); }
private String getDisplayPath(SvnTarget path) { if (path.isFile()) { final String absolutePath = path.getFile().getAbsolutePath().replace(File.separatorChar, '/'); final String currentPath = new File("").getAbsolutePath().replace(File.separatorChar, '/'); String relativePath = getRelativePath(absolutePath, currentPath); if (relativePath != null) { return relativePath; } else { return absolutePath; } } return path.getPathOrUrlString(); }
@Override protected void ensureArgumentsAreValid() throws SVNException { if (getSource() == null || getSource().getPegRevision() == null || getSource().getPegRevision() == SVNRevision.UNDEFINED) { final SvnTarget firstSource = getFirstSource(); final SvnTarget secondSource = getSecondSource(); ensureArgumentsAreValid(firstSource.getURL(), firstSource.getFile(), firstSource.getPegRevision(), secondSource.getURL(), secondSource.getFile(), secondSource.getPegRevision(), null); } else { final SvnTarget source = getSource(); ensureArgumentsAreValid(source.getURL(), source.getFile(), getStartRevision(), source.getURL(), source.getFile(), getEndRevision(), source.getPegRevision()); } }
public void flush() { if (lastTarget != null) { callback.singlePath(lastTarget == null ? null : lastTarget.getPathOrUrlString(), null, getInheritedProperties(lastInheritedProperties)); lastTarget = null; } } }
public static SVNCopySource copySource(SvnCopySource newSource) { if (newSource.getSource().getURL() != null) { final SVNCopySource copySource = new SVNCopySource(newSource.getSource().getResolvedPegRevision(), newSource.getRevision(), newSource.getSource().getURL()); copySource.setCopyContents(newSource.isCopyContents()); return copySource; } final SVNCopySource copySource = new SVNCopySource(newSource.getSource().getResolvedPegRevision(), newSource.getRevision(), newSource.getSource().getFile()); copySource.setCopyContents(newSource.isCopyContents()); return copySource; }
public void receive(SvnTarget target, SVNPropertyData object) throws SVNException { if (handler != null) { handler.handleProperty(target.getFile(), object); } } };
public void receive(SvnTarget target, SVNCommitInfo commitInfo) throws SVNException { try { SVNURL repositoryRoot = target.getURL(); callback.commitInfo(getCommitInfo(commitInfo, repositoryRoot)); } catch (ParseException e) { throwSvnException(e); } } };
@Override protected Long run(SVNWCContext context) throws SVNException { SvnTarget source = getOperation().getSource(); int targetWorkingCopyFormat = getOperation().getTargetWorkingCopyFormat(); return checkout(source.getURL(), getFirstTarget(), source.getResolvedPegRevision(), getOperation().getRevision(), getOperation().getDepth(), getOperation().isIgnoreExternals(), getOperation().isAllowUnversionedObstructions(), getOperation().isSleepForTimestamp(), targetWorkingCopyFormat < 0 ? ISVNWCDb.WC_FORMAT_18 : targetWorkingCopyFormat); }
private String getRelativeToRootPath(SvnTarget target, SvnTarget originalTarget) { String relativePath; if (repositoryRoot == null) { relativePath = null; } else { if (repositoryRoot.isFile() == target.isFile()) { String targetString = target.getPathOrUrlDecodedString(); String baseTargetString = repositoryRoot.getPathOrUrlDecodedString(); relativePath = getRelativePath(targetString, baseTargetString); } else { String targetString = target.getPathOrUrlDecodedString(); String baseTargetString = new File("").getAbsolutePath(); relativePath = getRelativePath(targetString, baseTargetString); } } return relativePath != null ? relativePath : target.getPathOrUrlString(); }
@Override protected void ensureArgumentsAreValid() throws SVNException { for (SvnTarget target : getTargets()) { if (target.isURL()) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ILLEGAL_TARGET, "''{0}'' is not a local path", target.getURL()); SVNErrorManager.error(err, SVNLogType.WC); } } if (getDepth() == null) { setDepth(SVNDepth.UNKNOWN); } if (getDepth() == SVNDepth.UNKNOWN) { setDepthIsSticky(false); } super.ensureArgumentsAreValid(); }
private String getDisplayPath(SvnTarget target) { String relativePath; if (baseTarget == null) { relativePath = null; } else { String targetString = target.getPathOrUrlDecodedString(); String baseTargetString = baseTarget.getPathOrUrlDecodedString(); relativePath = getRelativePath(targetString, baseTargetString); } return relativePath != null ? relativePath : target.getPathOrUrlString(); }