SVNCopySource cs = new SVNCopySource(SVNRevision.UNDEFINED,srcRevision,srcURL); return doCopy( new SVNCopySource[]{cs}, dstURL, isMove, true, failWhenDstExists, commitMessage, null);
private SVNCopySource processCopySource(SVNCopySource copySource, long targetRevision) throws SVNException { if (copySource == null) { return null; } if (copySource.isURL() && (copySource.getRevision() != null && copySource.getRevision().getID() == 10)) { return copySource; } SVNRevision pegRevision; SVNRevision revision; try { pegRevision = processCopySourceRevision(copySource.getPegRevision(), copySource, targetRevision); revision = processCopySourceRevision(copySource.getRevision(), copySource, targetRevision); } catch (SVNException e) { SVNDebugLog.getDefaultLog().logFine(SVNLogType.WC, "merge ext: Error while fetching copy source revision"); return null; } SVNURL url = copySource.getURL(); if (url == null) { url = getCopySourceURL(copySource); if (url == null) { return null; } } return new SVNCopySource(pegRevision, revision, url); }
public static SvnCopySource copySource(SVNCopySource oldSource) { SvnTarget target; if (oldSource.isURL()) { target = SvnTarget.fromURL(oldSource.getURL(), oldSource.getPegRevision()); } else { target = SvnTarget.fromFile(oldSource.getFile(), oldSource.getPegRevision()); } final SvnCopySource copySource = SvnCopySource.create(target, oldSource.getRevision()); copySource.setCopyContents(oldSource.isCopyContents()); return copySource; }
protected long getRevision(SVNCopySource copySource) throws SVNException { return getRevisionNumber(copySource.getRevision(), getRepository(copySource.getURL()), copySource.getFile()); }
public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("[merge target: path = "); buffer.append(myPath); buffer.append("; wc file = "); buffer.append(myWCFile); buffer.append("; file = "); buffer.append(myFile); buffer.append("; base file = "); buffer.append(myCurrentFile.myBaseFile); buffer.append("; copyFromURL = "); buffer.append(myCopySource == null ? null : myCopySource.getURL()); buffer.append("; copyFromRevision = "); buffer.append(myCopySource == null ? "unknown" : String.valueOf(myCopySource.getRevision())); buffer.append("]"); return buffer.toString(); } }
private void doCopy(SVNCopySource[] sources, File dst, boolean isMove, boolean makeParents, boolean failWhenDstExists, boolean pinExternals, Map<SvnTarget, List<SVNExternal>> externalsToPin) throws SVNException { if (sources.length > 1 && failWhenDstExists) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_MULTIPLE_SOURCES_DISALLOWED); SVNErrorManager.error(err, SVNLogType.DEFAULT); } sources = expandCopySources(sources); if (sources.length == 0) { return; } try { setupCopy(sources, new SVNPath(dst.getAbsolutePath(), false, false), isMove, makeParents, pinExternals, externalsToPin, null, null, getCommitHandler(), getCommitParameters(), getExternalsHandler()); } catch (SVNException e) { SVNErrorCode err = e.getErrorMessage().getErrorCode(); if (!failWhenDstExists && sources.length == 1 && (err == SVNErrorCode.ENTRY_EXISTS || err == SVNErrorCode.FS_ALREADY_EXISTS)) { SVNCopySource source = sources[0]; String baseName = source.getName(); if (source.isURL()) { baseName = SVNEncodingUtil.uriDecode(baseName); } try { setupCopy(sources, new SVNPath(new File(dst, baseName).getAbsolutePath(), false, false), isMove, makeParents, pinExternals, externalsToPin, null, null, getCommitHandler(), getCommitParameters(), getExternalsHandler()); } catch (SVNException second) { throw second; } return; } throw e; } }
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; }
private SVNURL getCopySourceURL(SVNCopySource source) throws SVNException { if (source == null) { return null; } if (source.isURL()) { return source.getURL(); } String relativePath = SVNPathUtil.getPathAsChild(myTarget.getAbsolutePath(), source.getFile().getAbsolutePath()); if (relativePath == null) { SVNDebugLog.getDefaultLog().logFine(SVNLogType.WC, "merge ext: illegal file path passed as copy source"); return null; } return myTargetURL.appendPath(relativePath, false); }
/** * Returns the name of this copy source. * @return copy source name */ public String getName() { if (isURL()) { return SVNPathUtil.tail(myURL.getPath()); } return myPath.getName(); }
private Void virtualCopy() throws SVNException { SVNMoveClient16 client = new SVNMoveClient16(getOperation().getRepositoryPool(), getOperation().getOptions()); client.setEventHandler(getOperation().getEventHandler()); client.setOptions(getOperation().getOptions()); final SvnTarget target = getOperation().getFirstTarget(); if (target.isURL()) { throwCannotPerformOnUrl(target, "virtual", getOperation().isMove() ? "move" : "copy"); } final SVNCopySource[] sources = getCopySources(); for (SVNCopySource source : sources) { client.doVirtualCopy(source.getFile(), target.getFile(), getOperation().isMove()); } return null; }
private File getCopySourcePath(SVNCopySource source) { if (source == null) { return null; } if (!source.isURL()) { return source.getFile(); } File target = null; String sPath = SVNPathUtil.getPathAsChild(mySourceURL.getPath(), source.getURL().getPath()); String tPath = SVNPathUtil.getPathAsChild(myTargetURL.getPath(), source.getURL().getPath()); if (sPath != null) { target = getFile(sPath); } else if (tPath != null) { target = getFile(tPath); } else { SVNDebugLog.getDefaultLog().logFine(SVNLogType.WC, "merge ext: Neither merge source URL nor merge target URL are not ancestors of copy source URL"); } return target; }
protected void doVirtualCopy(SVNEntry dstEntry, SVNCopySource copySource, boolean save) throws SVNException { dstEntry.setCopyFromURL(copySource.getURL().toString()); long cfRevision = copySource.getRevision().getNumber(); dstEntry.setCopyFromRevision(cfRevision); if (save) { SVNAdminArea dir = dstEntry.getAdminArea(); dir.saveEntries(false); } }
/** * Returns the name of this copy source. * @return copy source name */ public String getName() { if (isURL()) { return SVNPathUtil.tail(myURL.getPath()); } return myPath.getName(); }
copySource = null; } else if (SVNPathUtil.isURL(path)) { copySource = new SVNCopySource(pegRevision, revision, SVNURL.parseURIEncoded(path)); } else { copySource = new SVNCopySource(pegRevision, revision, new File(path));
protected SVNCopySource[] expandCopySources(SVNCopySource[] sources) throws SVNException { Collection expanded = new ArrayList(sources.length); for (int i = 0; i < sources.length; i++) { SVNCopySource source = sources[i]; if (source.isCopyContents() && source.isURL()) { // get children at revision. SVNRevision pegRevision = source.getPegRevision(); if (!pegRevision.isValid()) { pegRevision = SVNRevision.HEAD; } SVNRevision startRevision = source.getRevision(); if (!startRevision.isValid()) { startRevision = pegRevision; } SVNRepositoryLocation[] locations = getLocations(source.getURL(), null, null, pegRevision, startRevision, SVNRevision.UNDEFINED); SVNRepository repository = createRepository(locations[0].getURL(), null, null, true); long revision = locations[0].getRevisionNumber(); Collection entries = new ArrayList(); repository.getDir("", revision, null, 0, entries); for (Iterator ents = entries.iterator(); ents.hasNext();) { SVNDirEntry entry = (SVNDirEntry) ents.next(); // add new copy source. expanded.add(new SVNCopySource(SVNRevision.UNDEFINED, source.getRevision(), entry.getURL())); } } else { expanded.add(source); } } return (SVNCopySource[]) expanded.toArray(new SVNCopySource[expanded.size()]); }
String path = source.getURL() == null ? source.getFile().getAbsolutePath() : source.getURL().toString(); writer.write(path); SVNRevision pegRevision = source.getPegRevision() == null ? SVNRevision.UNDEFINED : source.getPegRevision(); writer.write(pegRevision.toString()); SVNRevision revision = source.getRevision() == null ? SVNRevision.UNDEFINED : source.getRevision(); writer.write(revision.toString());
protected void close() throws SVNException { SVNDebugLog.getDefaultLog().logFine(SVNLogType.WC, "ext merge: close " + myPath); closeFile(myPath, myCurrentFile.myIsAdded, myWCFile, myFile, myCurrentFile.myPropertyDiff, myCurrentFile.myBaseProperties, myCurrentFile.myBaseFile, null); if (myCopySource == null) { return; } SVNEntry targetEntry = myWCAccess.getEntry(myWCFile, false); if (targetEntry != null) { SVNURL copyFromLocation = targetEntry.getCopyFromSVNURL(); long copyFromRevision = targetEntry.getCopyFromRevision(); SVNURL sourceURL = myCopySource.getURL(); long sourceRevision = myCopySource.getRevision().getNumber(); if (copyFromLocation == null || !copyFromLocation.equals(sourceURL) || copyFromRevision != sourceRevision) { getMergeDriver().copy(myCopySource, myWCFile, true); } } }
/** * Returns the name of this copy source. * @return copy source name */ public String getName() { if (isURL()) { return SVNPathUtil.tail(myURL.getPath()); } return myPath.getName(); }