/** * Returns <code>String</code> representation of the object * * @return object as <code>String</code> */ @Override public String toString() { return getSource().toString() + " r" + getRevision(); } }
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; }
/** * Calculates whether <code>source</code> is local and <code>revision</code> is local. * * @return <code>true</code> if the <code>source</code> and <code>revision</code> are local, otherwise <code>false</code> */ public boolean isLocal() { return getSource().isLocal() && getRevision().isLocal(); }
@Override public boolean isApplicable(SvnRemoteCopy operation, SvnWcGeneration wcGeneration) throws SVNException { if (operation.getFirstTarget().isURL()) { for (SvnCopySource source : operation.getSources()) { if (source.getSource().getFile() != null) { SvnWcGeneration sourceFormat = SvnOperationFactory.detectWcGeneration(source.getSource().getFile(), false); if (sourceFormat != SvnWcGeneration.V16) { return false; } } } // copy from old_wc[@rev] to url return true; } return false; }
private boolean areAllSourcesRemote(SvnCopy operation) { for(SvnCopySource source : operation.getSources()) { if (source.getSource().isFile()) { if (operation.isMove()) { return false; } if (isLocalRevision(source.getRevision()) && isLocalRevision(source.getSource().getResolvedPegRevision())) { return false; } } } return true; }
private boolean areAllSourcesLocal(SvnCopy operation) { for(SvnCopySource source : operation.getSources()) { if (source.getSource().isFile()) { if (operation.isMove()) { continue; } if (isLocalRevision(source.getRevision()) && isLocalRevision(source.getSource().getResolvedPegRevision())) { continue; } } return false; } return true; }
private boolean areAllSourcesRemote(SvnRemoteCopy operation) { for(SvnCopySource source : operation.getSources()) { if (source.getSource().isURL() || (source.getRevision() != SVNRevision.WORKING && source.getRevision() != SVNRevision.UNDEFINED)) { continue; } return false; } return true; }
private boolean areAllSourcesLocal(SvnRemoteCopy operation) { // need all sources to be wc files at WORKING. // BASE revision meas repos_to_repos copy for(SvnCopySource source : operation.getSources()) { if (source.getSource().isFile() && (source.getRevision() == SVNRevision.WORKING || source.getRevision() == SVNRevision.UNDEFINED)) { continue; } return false; } return true; }
protected Collection<SvnCopySource> expandCopySources(Collection<SvnCopySource> sources) throws SVNException { Collection<SvnCopySource> expanded = new ArrayList<SvnCopySource>(sources.size()); for (SvnCopySource source : sources) { if (source.isCopyContents() && source.getSource().isURL()) { // get children at revision. SVNRevision pegRevision = source.getSource().getResolvedPegRevision(); if (!pegRevision.isValid()) { pegRevision = SVNRevision.HEAD; } SVNRevision startRevision = source.getRevision(); if (!startRevision.isValid()) { startRevision = pegRevision; } final SVNRepository svnRepository = getRepositoryAccess().createRepository(source.getSource().getURL(), null, true); final Structure<LocationsInfo> locations = getRepositoryAccess().getLocations(svnRepository, source.getSource(), pegRevision, startRevision, SVNRevision.UNDEFINED); long revision = locations.lng(LocationsInfo.startRevision); Collection<SVNDirEntry> entries = new ArrayList<SVNDirEntry>(); svnRepository.getDir("", revision, null, 0, entries); for (Iterator<SVNDirEntry> ents = entries.iterator(); ents.hasNext();) { SVNDirEntry entry = (SVNDirEntry) ents.next(); // add new copy source. expanded.add(SvnCopySource.create(SvnTarget.fromURL(entry.getURL()), source.getRevision())); } } else { expanded.add(source); } } return expanded; }
protected SVNCommitInfo doRun(SVNWCContext context, SVNURL target) throws SVNException { if (getOperation().isMove()) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Moves between the working copy and the repository are not supported"); SVNErrorManager.error(err, SVNLogType.WC); } Collection<SvnCopySource> sources = getOperation().getSources(); Collection<SvnCopyPair> copyPairs = new ArrayList<SvnNgWcToReposCopy.SvnCopyPair>(); if (sources.size() > 1) { for (SvnCopySource copySource : sources) { SvnCopyPair copyPair = new SvnCopyPair(); String baseName; copyPair.source = copySource.getSource().getFile(); baseName = copyPair.source.getName(); copyPair.dst = target; copyPair.dst = copyPair.dst.appendPath(baseName, false); copyPairs.add(copyPair); } } else if (sources.size() == 1) { SvnCopyPair copyPair = new SvnCopyPair(); SvnCopySource source = sources.iterator().next(); copyPair.source= source.getSource().getFile(); copyPair.dst = target; copyPairs.add(copyPair); } return copy(copyPairs, getOperation().isMakeParents(), getOperation().getRevisionProperties(), getOperation().getCommitMessage(), getOperation().getCommitHandler()); }
@Override protected Void run(SVNWCContext context) throws SVNException { boolean timestampSleep = false; Collection<SvnCopySource> sources = getOperation().getSources(); try { timestampSleep = tryRun(context, sources, getFirstTarget()); return null; } catch (SVNException e) { SVNErrorCode code = e.getErrorMessage().getErrorCode(); if (!getOperation().isFailWhenDstExists() && getOperation().getSources().size() == 1 && (code == SVNErrorCode.ENTRY_EXISTS || code == SVNErrorCode.FS_ALREADY_EXISTS)) { SvnCopySource source = sources.iterator().next(); timestampSleep = tryRun(context, sources, new File(getFirstTarget(), source.getSource().getFile().getName())); return null; } throw e; } finally { if (timestampSleep) { sleepForTimestamp(); } } }
boolean srcsAreUrls = sources.iterator().next().getSource().isURL(); if (sources.size() > 1) { for (SvnCopySource copySource : sources) { SvnCopyPair copyPair = new SvnCopyPair(); String baseName; if (copySource.getSource().isFile()) { copyPair.sourceFile = copySource.getSource().getFile(); baseName = copyPair.sourceFile.getName(); if (srcsAreUrls) { if (copySource.getSource().getResolvedPegRevision() == SVNRevision.WORKING) { Structure<RevisionsPair> pair = getRepositoryAccess().getRevisionNumber(null, copySource.getSource(), copySource.getSource().getResolvedPegRevision(), null); copyPair.sourcePegRevision = SVNRevision.create(pair.lng(RevisionsPair.revNumber)); pair.release(); } else { copyPair.sourcePegRevision = copySource.getSource().getResolvedPegRevision(); copyPair.source = copySource.getSource().getURL(); baseName = SVNPathUtil.tail(copyPair.source.getPath()); copyPair.sourcePegRevision = copySource.getSource().getResolvedPegRevision(); copyPair.sourceRevision = copySource.getRevision(); SvnCopySource source = sources.iterator().next(); String baseName; if (source.getSource().isFile()) { copyPair.sourceFile = source.getSource().getFile(); baseName = copyPair.sourceFile.getName(); } else {
public SvnCopySource createRemoteCopySource(SVNWCContext context, SvnCopySource localCopySource) throws SVNException { Structure<NodeOriginInfo> origin = context.getNodeOrigin(localCopySource.getSource().getFile(), true, NodeOriginInfo.reposRelpath, NodeOriginInfo.reposRootUrl, NodeOriginInfo.revision); SVNURL url = origin.get(NodeOriginInfo.reposRootUrl); url = url.appendPath(SVNFileUtil.getFilePath(origin.<File>get(NodeOriginInfo.reposRelpath)), false); SVNRevision pegRevision = localCopySource.getSource().getResolvedPegRevision(); SVNRevision revision = localCopySource.getRevision(); if (pegRevision == SVNRevision.UNDEFINED || pegRevision == SVNRevision.WORKING || pegRevision == SVNRevision.BASE) { pegRevision = SVNRevision.create(origin.lng(NodeOriginInfo.revision)); } if (revision == SVNRevision.BASE) { revision = SVNRevision.create(origin.lng(NodeOriginInfo.revision)); } origin.release(); localCopySource = SvnCopySource.create(SvnTarget.fromURL(url, pegRevision), revision); return localCopySource; }
@Override protected SVNCommitInfo run(SVNWCContext context) throws SVNException { SVNCommitInfo info = null; try { info = doRun(context, getOperation().getFirstTarget().getURL()); } catch (SVNException e) { SVNErrorCode code = e.getErrorMessage().getErrorCode(); if (!getOperation().isFailWhenDstExists() && getOperation().getSources().size() == 1 && (code == SVNErrorCode.ENTRY_EXISTS || code == SVNErrorCode.FS_ALREADY_EXISTS)) { SvnCopySource source = getOperation().getSources().iterator().next(); SVNURL target = getOperation().getFirstTarget().getURL(); target = target.appendPath(source.getSource().getFile().getName(), false); info = doRun(context, target); } else { throw e; } } if (info != null) { getOperation().receive(getOperation().getFirstTarget(), info); } return info; }
copyPair.source = copySource.getSource().getFile(); String baseName = copyPair.source.getName(); copyPair.dst = new File(target, baseName); SvnCopyPair copyPair = new SvnCopyPair(); SvnCopySource source = sources.iterator().next(); copyPair.source = new File(SVNPathUtil.validateFilePath(source.getSource().getFile().getAbsolutePath())); copyPair.dst = target; copyPairs.add(copyPair);
public SvnCopySource createRemoteCopySource(SVNWCContext context, SvnCopySource localCopySource) throws SVNException { final SVNWCAccess wcAccess = SVNWCAccess.newInstance(null); final File path = localCopySource.getSource().getFile(); try { wcAccess.probeOpen(path, false, 0); SVNEntry entry = wcAccess.getEntry(path, false); SVNURL url = entry.isCopied() ? entry.getCopyFromSVNURL() : entry.getSVNURL(); if (url == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_MISSING_URL, "''{0}'' does not have a URL associated with it", path); SVNErrorManager.error(err, SVNLogType.WC); } SVNRevision pegRevision = localCopySource.getSource().getResolvedPegRevision(); SVNRevision revision = localCopySource.getRevision(); if (pegRevision == SVNRevision.UNDEFINED || pegRevision == SVNRevision.WORKING || pegRevision == SVNRevision.BASE) { pegRevision = entry.isCopied() ? SVNRevision.create(entry.getCopyFromRevision()) : SVNRevision.create(entry.getRevision()); } if (revision == SVNRevision.BASE) { revision= entry.isCopied() ? SVNRevision.create(entry.getCopyFromRevision()) : SVNRevision.create(entry.getRevision()); } return SvnCopySource.create(SvnTarget.fromURL(url, pegRevision), revision); } finally { wcAccess.close(); } }
int i = 0; for (SvnCopySource newSource : getOperation().getSources()) { if (newSource.getSource().isFile()) { SvnWcGeneration wcGeneration = SvnOperationFactory.detectWcGeneration(newSource.getSource().getFile(), false); if (wcGeneration == SvnWcGeneration.V16) { newSource = new SvnOldRepositoryAccess(getOperation()).createRemoteCopySource(getWcContext(), newSource);