Java Code Examples for org.tigris.subversion.svnclientadapter.SVNUrl#toString()

The following examples show how to use org.tigris.subversion.svnclientadapter.SVNUrl#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void checkout(SVNUrl moduleName, File destPath,
		SVNRevision revision, int depth, boolean ignoreExternals,
		boolean force) throws SVNClientException {
	try {
		String url = moduleName.toString();
		Depth d = JhlConverter.depth(depth);
		notificationHandler.setCommand(ISVNNotifyListener.Command.CHECKOUT);
		StringBuffer commandLine = new StringBuffer("checkout " + url
				+ " -r " + revision.toString() + depthCommandLine(d));
		if (ignoreExternals)
			commandLine.append(" --ignore-externals");
		if (force)
			commandLine.append(" --force");
		notificationHandler.logCommandLine(commandLine.toString());
		notificationHandler.setBaseDir(new File("."));
		svnClient.checkout(url, fileToSVNPath(destPath, false),
				JhlConverter.convert(revision),
				JhlConverter.convert(revision), d, ignoreExternals, force);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 2
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void move(SVNUrl srcUrl, SVNUrl destUrl, String message,
		SVNRevision revision) throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);

		// NOTE: The revision arg is ignored as you cannot move
		// a specific revision, only HEAD.
		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.MOVE);
		Set<String> src = new HashSet<String>();
		src.add(srcUrl.toString());
		String dest = destUrl.toString();
		notificationHandler.logCommandLine("move -m \""
				+ getFirstMessageLine(fixedMessage) + ' '
				+ srcUrl.toString() + ' ' + dest);
		notificationHandler.setBaseDir();
		svnClient.move(src, dest, false, false, false, null,
				new JhlCommitMessage(fixedMessage), null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 3
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void doImport(File path, SVNUrl url, String message, boolean recurse)
		throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);

		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.IMPORT);
		String src = fileToSVNPath(path, false);
		String dest = url.toString();
		notificationHandler.logCommandLine("import -m \""
				+ getFirstMessageLine(fixedMessage) + "\" "
				+ (recurse ? "" : "-N ") + src + ' ' + dest);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		svnClient
				.doImport(src, dest, Depth.infinityOrEmpty(recurse), false,
						true, null, new JhlCommitMessage(fixedMessage),
						null);
		notificationHandler.logCompleted(Messages
				.bind("notify.import.complete"));
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 4
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void doExport(SVNUrl srcUrl, File destPath, SVNRevision revision,
		boolean force) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.EXPORT);
		String src = srcUrl.toString();
		String dest = fileToSVNPath(destPath, false);
		notificationHandler.logCommandLine("export -r "
				+ revision.toString() + ' ' + src + ' ' + dest);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(destPath));
		svnClient.doExport(src, dest, JhlConverter.convert(revision),
				Revision.HEAD, force, false, Depth.infinity, null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 5
Source File: SvnClientExceptionHandler.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages("CTL_Action_Cancel=Cancel")
public static boolean handleAuth (SVNUrl url) {
    SvnKenaiAccessor support = SvnKenaiAccessor.getInstance();
    String sUrl = url.toString();
    if(support.isKenai(sUrl)) {
        return support.showLogin() && support.getPasswordAuthentication(sUrl, true) != null;
    } else {
        Repository repository = new Repository(Repository.FLAG_SHOW_PROXY, org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "MSG_Error_ConnectionParameters"));  // NOI18N
        repository.selectUrl(url, true);

        JButton retryButton = new JButton(org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "CTL_Action_Retry"));           // NOI18N
        String title = org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "MSG_Error_AuthFailed");
        Object option = repository.show(
                title, 
                new HelpCtx("org.netbeans.modules.subversion.client.SvnClientExceptionHandler"), //NOI18N
                new Object[] { retryButton,
                    Bundle.CTL_Action_Cancel()
                }, retryButton);

        boolean ret = (option == retryButton);
        if(ret) {
            SvnModuleConfig.getDefault().insertRecentUrl(repository.getSelectedRC());
        }
        return ret;
    }
}
 
Example 6
Source File: CommitOperation.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private String getRootURL(ISVNLocalResource localResource) {
	if (!atomicCommit)
		return null;
	ISVNInfo info = getSVNInfo(localResource);
	if (info == null)
		return null;
	SVNUrl repos = info.getRepository();
	if (repos == null)
		return null;
   	return repos.toString();
}
 
Example 7
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ISVNProperty[] getRevProperties(SVNUrl url,
		SVNRevision.Number revisionNo) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.PROPLIST);
		String target = url.toString();
		notificationHandler.logCommandLine("proplist --revprop -r "
				+ revisionNo.toString() + target);

		notificationHandler.setBaseDir();
		Map<String, byte[]> propertiesData = svnClient.revProperties(
				target, Revision.getInstance(revisionNo.getNumber()));
		if (propertiesData == null) {
			// no properties
			return new JhlPropertyData[0];
		}
		Set<String> keys = propertiesData.keySet();
		JhlPropertyData[] svnProperties = new JhlPropertyData[keys.size()];
		int i = 0;
		for (String key : keys) {
			svnProperties[i] = JhlPropertyData.newForUrl(target, key,
					propertiesData.get(key));
			i++;
		}
		return svnProperties;
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 8
Source File: SVNUrlUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get path of url relative to rootUrl 
 * @param rootUrl
 * @param url
 * @param includeStartingSlash whether the realtive url should start with / or not
 * @return relative path or null if rootUrl is not a parent of url
 */
public static String getRelativePath(SVNUrl rootUrl, SVNUrl url, boolean includeStartingSlash ) 
{
	//TODO Isn't there a more efficient way than to convert those urls to Strings ?
    String rootUrlStr = rootUrl.toString();
    String urlStr = url.toString();
    if (urlStr.indexOf(rootUrlStr) == -1) {
        return null;
    }
    if (urlStr.length() == rootUrlStr.length()) {
        return "";
    }
    return urlStr.substring(rootUrlStr.length() + (includeStartingSlash ? 0 : 1));
}
 
Example 9
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void diff(File path, SVNUrl url, SVNRevision urlRevision,
		File outFile, boolean recurse) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF);

		// we don't want canonical file path (otherwise the complete file
		// name
		// would be in the patch). This way the user can choose to use a
		// relative
		// path
		String wcPath = fileToSVNPath(path, false);
		String svnOutFile = fileToSVNPath(outFile, false);

		String commandLine = "diff --old " + wcPath + " ";
		commandLine += "--new " + url.toString();
		if (!urlRevision.equals(SVNRevision.HEAD))
			commandLine += "@" + urlRevision.toString();

		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		svnClient.diff(wcPath, Revision.WORKING, url.toString(),
				JhlConverter.convert(urlRevision), null, svnOutFile,
				Depth.infinityOrEmpty(recurse), null, false, true, false,
				true);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 10
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void getLogMessages(SVNUrl url, SVNRevision pegRevision,
		SVNRevision revisionStart, SVNRevision revisionEnd,
		boolean stopOnCopy, boolean fetchChangePath, long limit,
		boolean includeMergedRevisions, String[] requestedProperties,
		ISVNLogMessageCallback worker) throws SVNClientException {

	String target = url.toString();
	notificationHandler.setBaseDir();
	this.getLogMessages(target, pegRevision, revisionStart, revisionEnd,
			stopOnCopy, fetchChangePath, limit, includeMergedRevisions,
			requestedProperties, worker);
}
 
Example 11
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void copy(SVNUrl[] srcUrls, SVNUrl destUrl, String message,
		SVNRevision revision, boolean copyAsChild, boolean makeParents)
		throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);

		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.COPY);
		List<CopySource> copySources = new ArrayList<CopySource>(
				srcUrls.length);
		for (int i = 0; i < srcUrls.length; i++)
			copySources.add(new CopySource(srcUrls[i].toString(),
					JhlConverter.convert(revision), JhlConverter
							.convert(SVNRevision.HEAD)));
		String dest = destUrl.toString();
		String commandLine = "copy -r" + revision.toString();
		Set<String> paths = new HashSet<String>(srcUrls.length);
		for (int i = 0; i < srcUrls.length; i++) {
			paths.add(srcUrls[i].toString());
		}
		commandLine = appendPaths(commandLine, paths) + " " + dest;
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();
		svnClient.copy(copySources, dest, copyAsChild, makeParents, true,
				null, new JhlCommitMessage(fixedMessage), null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 12
Source File: AbstractSvnTestCase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void cliRemove(SVNUrl... urls) throws SVNClientException, IOException, InterruptedException {
    for (SVNUrl url : urls) {
        String[] cmd = new String[] {"svn", "remove", url.toString(), "-m", "remove"};
        Process p = Runtime.getRuntime().exec(cmd);
        p.waitFor();
    }
}
 
Example 13
Source File: RevisionSetupsSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void cacheSummaries (SVNDiffSummary[] diffSummaries, SVNUrl leftUrl,
        SVNRevision leftRevision, SVNRevision rightRevision) {
    String revisionString = "@" + leftRevision + ":" + rightRevision;
    Map<String, List<SVNDiffSummary>> sums = new LinkedHashMap<>();
    sums.put("", new ArrayList<SVNDiffSummary>(diffSummaries.length));
    for (SVNDiffSummary s : diffSummaries) {
        String path = s.getPath();
        do {
            List<SVNDiffSummary> list = sums.get(path);
            if (list == null) {
                list = new ArrayList<>();
                sums.put(path, list);
            }
            String suffix = s.getPath().substring(path.length());
            if (suffix.startsWith("/")) {
                suffix = suffix.substring(1);
            }
            list.add(new SVNDiffSummary(suffix, s.getDiffKind(), s.propsChanged(), s.getNodeKind()));
            int index = path.lastIndexOf("/");
            if (index > -1) {
                path = path.substring(0, index);
            } else if (!path.isEmpty()) {
                path = "";
            } else {
                path = null;
            }
        } while (path != null);
    }
    for (Map.Entry<String, List<SVNDiffSummary>> e : sums.entrySet()) {
        SVNDiffSummary[] summaryArray = e.getValue().toArray(new SVNDiffSummary[e.getValue().size()]);
        String key;
        if (e.getKey().isEmpty()) {
            key = leftUrl.toString();
        } else {
            key = leftUrl.toString() + "/" + e.getKey();
        }
        key += revisionString;
        diffSummaryCache.put(key, summaryArray);
    }
}
 
Example 14
Source File: SvnConfigFilesTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testSSL() throws MalformedURLException, IOException {
    SVNUrl url = new SVNUrl("https://feher.lo.nem.lo.com/kuon");
    RepositoryConnection rc = new RepositoryConnection(
            url.toString(),
            "usr", "psswd".toCharArray(), null, false, "/cert/file", "pssphrs".toCharArray(), -1);

    SvnModuleConfig.getDefault().insertRecentUrl(rc);
    String path = "/tmp" + File.separator + "svn" + File.separator + "config" + System.currentTimeMillis();
    System.setProperty("netbeans.t9y.svn.nb.config.path", path);
    SvnConfigFiles scf = SvnConfigFiles.getInstance();
    scf.storeSvnServersSettings(url, ConnectionType.cli);

    File serversFile = new File(path + "/servers");
    long lastMod = serversFile.lastModified();
    Section s = getSection(serversFile);
    assertNotNull(s);

    // values were written
    assertEquals("/cert/file", s.get("ssl-client-cert-file"));
    assertEquals("pssphrs", s.get("ssl-client-cert-password"));

    // nothing was changed ...
    scf.storeSvnServersSettings(url, ConnectionType.cli);
    // ... the file so also the file musn't change
    assertEquals(lastMod, serversFile.lastModified());

    // lets change the credentials ...
    rc = new RepositoryConnection(
            url.toString(),
            "usr", "psswd".toCharArray(), null, false, "/cert/file2", "pssphrs2".toCharArray(), -1);
    SvnModuleConfig.getDefault().insertRecentUrl(rc);
    scf.storeSvnServersSettings(url, ConnectionType.cli);
    s = getSection(serversFile);
    // values were written
    assertNotNull(s);
    assertNotSame(lastMod, serversFile.lastModified());
    assertEquals("/cert/file2", s.get("ssl-client-cert-file"));
    assertEquals("pssphrs2", s.get("ssl-client-cert-password"));

    // lets test a new url
    url = url.appendPath("whatever");
    rc = new RepositoryConnection(
            url.toString(),
            "usr", "psswd".toCharArray(), null, false, "/cert/file3", "pssphrs3".toCharArray(), -1);
    SvnModuleConfig.getDefault().insertRecentUrl(rc);
    lastMod = serversFile.lastModified();
    scf.storeSvnServersSettings(url, ConnectionType.cli);
    s = getSection(serversFile);
    // values were written
    assertNotNull(s);
    assertNotSame(lastMod, serversFile.lastModified());
    assertEquals("/cert/file3", s.get("ssl-client-cert-file"));
    assertEquals("pssphrs3", s.get("ssl-client-cert-password"));
}
 
Example 15
Source File: ResourceStatus.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param status
 * @param url - Only needed when status.getUrl is Null, such as
 *  for an svn:externals folder
 */
public ResourceStatus(ISVNStatus status, String url, boolean useUrlHack) {
	super();
   	/** a temporary variable serving as immediate cache for various status values */
   	Object aValue = null;

   	aValue = status.getUrlString();
       if (aValue == null) {
       	if (url == null)
       		this.url = null;
       	else
       		this.url = url;
       } else {
           this.url = (String) aValue;
       }

       // This is a hack to get the URL for incoming additions if when URL is null due to a JavaHL bug.
       // See Issue #1312 for details.  This should only be done for RemoteResourceStatus (useUrlHack == true),
       // not LocalResourceStatus.
       if (this.url == null && useUrlHack) {
       	File file = status.getFile();
       	if (file != null) {
       		List<String> segments = new ArrayList<String>();
       		segments.add(file.getName());
       		File parentFile = file.getParentFile();
       		while (parentFile != null) {
       			if (parentFile.exists()) {
       				IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(new Path(parentFile.getPath()));
       				if (container != null) {
						ISVNLocalFolder localFolder = SVNWorkspaceRoot.getSVNFolderFor(container);
						SVNUrl parentUrl = localFolder.getUrl();
						if (parentUrl != null) {
							StringBuffer sb = new StringBuffer(parentUrl.toString());
							for (int i = segments.size() - 1; i >= 0; i--) {
								sb.append("/" + segments.get(i));
							}
							this.url = sb.toString();
							break;
						}
       				}
       			}
       			segments.add(parentFile.getName());
       			parentFile = parentFile.getParentFile();
       		}
       	}
       }

       aValue = status.getLastChangedRevision();
       if (aValue == null) {
           this.lastChangedRevision = SVNRevision.SVN_INVALID_REVNUM;
       } else {
           this.lastChangedRevision = ((SVNRevision.Number) aValue).getNumber();
       }

       aValue = status.getLastChangedDate();
       if (aValue == null) {
           this.lastChangedDate = -1;
       } else {
           this.lastChangedDate = ((Date) aValue).getTime();
       }

       this.lastCommitAuthor = status.getLastCommitAuthor();
       this.textStatus = status.getTextStatus().toInt();
       this.propStatus = status.getPropStatus().toInt();
       this.treeConflicted = status.hasTreeConflict();
       this.fileExternal = status.isFileExternal();
       this.conflictDescriptor = status.getConflictDescriptor();

       this.nodeKind = status.getNodeKind().toInt();
       
       this.file = status.getFile();
}
 
Example 16
Source File: SvnClientExceptionHandler.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private boolean handleRepositoryConnectError() throws SVNClientException {
    SVNUrl url = getRemoteHostUrl(); // try to get the repository url from the svnclientdescriptor
    if (url == null) {
        // god knows why this can happen
        return false;
    }

    SvnKenaiAccessor support = SvnKenaiAccessor.getInstance();
    String sUrl = url.toString();
    if(support.isKenai(sUrl)) {
        if ("commit".equals(methodName)) { //NOI18N
            if (!support.canWrite(sUrl)) {
                throw new SVNClientException(NbBundle.getMessage(Repository.class, "MSG_Repository.kenai.insufficientRights.write"));//NOI18N
            }
        } else if (!support.canRead(sUrl)) {
            throw new SVNClientException(NbBundle.getMessage(Repository.class, "MSG_Repository.kenai.insufficientRights.read"));//NOI18N
        }
        return support.showLogin() && handleKenaiAuthorization(support, sUrl);
    } else {
        if (Thread.interrupted()) {
            Subversion.LOG.log(Level.FINE, "SvnClientExceptionHandler.handleRepositoryConnectError(): canceled"); //NOI18N
            return false;
        }
        Repository repository = new Repository(Repository.FLAG_SHOW_PROXY, org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "MSG_Error_ConnectionParameters"));  // NOI18N
        repository.selectUrl(url, true);

        JButton retryButton = new JButton(org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "CTL_Action_Retry"));           // NOI18N
        String title = ((exceptionMask & EX_NO_HOST_CONNECTION) == exceptionMask) ?
                            org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "MSG_Error_CouldNotConnect") :
                            org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "MSG_Error_AuthFailed");
        Object option = repository.show(title, new HelpCtx(this.getClass()), new Object[] {retryButton, org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "CTL_Action_Cancel")},    // NOI18N
                retryButton);

        boolean ret = (option == retryButton);
        if(ret) {
            RepositoryConnection rc = repository.getSelectedRC();
            String username = rc.getUsername();
            char[] password = rc.getPassword();

            adapter.setUsername(username);
            if (connectionType != ConnectionType.javahl) {
                adapter.setPassword(password != null ? new String(password) : ""); //NOI18N
            }
            SvnModuleConfig.getDefault().insertRecentUrl(rc);
        }
        return ret;
    }
}
 
Example 17
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public ISVNDirEntry[] getList(SVNUrl url, SVNRevision revision,
		boolean recurse) throws SVNClientException {
	String target = url.toString();
	return list(target, revision, SVNRevision.HEAD, recurse);
}
 
Example 18
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public ISVNDirEntry[] getList(SVNUrl url, SVNRevision revision,
		SVNRevision pegRevision, boolean recurse) throws SVNClientException {
	String target = url.toString();
	return list(target, revision, pegRevision, recurse);
}
 
Example 19
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public ISVNDirEntryWithLock[] getListWithLocks(SVNUrl url,
		SVNRevision revision, SVNRevision pegRevision, boolean recurse)
		throws SVNClientException {
	final List<JhlDirEntryWithLock> dirEntryList = new ArrayList<JhlDirEntryWithLock>();
	ListCallback callback = new ListCallback() {
		public void doEntry(DirEntry dirent, Lock lock) {
			if (dirent.getPath().length() == 0) {
				if (dirent.getNodeKind() == org.apache.subversion.javahl.types.NodeKind.file) {
					String absPath = dirent.getAbsPath();
					int lastSeparator = absPath.lastIndexOf('/');
					String path = absPath.substring(lastSeparator,
							absPath.length());
					dirent.setPath(path);
				} else {
					// Don't add requested directory.
					return;
				}
			}

			dirEntryList.add(new JhlDirEntryWithLock(dirent, lock));

		}

	};
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.LS);
		String commandLine = "list -r " + revision.toString()
				+ (recurse ? "-R" : "") + " " + url.toString();
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir(new File("."));
		svnClient.list(url.toString(), JhlConverter.convert(revision),
				JhlConverter.convert(pegRevision),
				Depth.infinityOrImmediates(recurse), DirEntry.Fields.all,
				true, callback);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
	ISVNDirEntryWithLock[] dirEntries = new ISVNDirEntryWithLock[dirEntryList
			.size()];
	dirEntryList.toArray(dirEntries);
	return dirEntries;
}
 
Example 20
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void copy(File[] srcPaths, SVNUrl destUrl, String message,
		boolean copyAsChild, boolean makeParents) throws SVNClientException {

	String fixedMessage = fixSVNString(message);

	// This is a hack for now since copy of multiple isolated WC's is
	// currently not working.
	if (srcPaths.length > 1) {
		mkdir(destUrl, makeParents, fixedMessage);
		for (int i = 0; i < srcPaths.length; i++) {
			File[] file = { srcPaths[i] };
			copy(file, destUrl, fixedMessage, copyAsChild, makeParents);
		}
		return;
	}

	try {
		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.COPY);
		List<CopySource> copySources = new ArrayList<CopySource>(
				srcPaths.length);
		for (int i = 0; i < srcPaths.length; i++)
			copySources.add(new CopySource(
					fileToSVNPath(srcPaths[i], false), Revision.WORKING,
					Revision.WORKING));
		String dest = destUrl.toString();
		String commandLine = "copy";
		Set<String> paths = new HashSet<String>(srcPaths.length);
		for (int i = 0; i < srcPaths.length; i++) {
			paths.add(fileToSVNPath(srcPaths[i], false));
		}
		commandLine = appendPaths(commandLine, paths) + " " + dest;
		notificationHandler.logCommandLine(commandLine.toString());
		notificationHandler.setBaseDir();
		svnClient.copy(copySources, dest, copyAsChild, makeParents, true,
				null, new JhlCommitMessage(fixedMessage), null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}