From a67abfa5fed475c9840ae41ff739ffc2a482d261 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 19 Oct 2011 10:30:16 +0200 Subject: [PATCH] fix bug in SvnRepositoryClient --- .../client/SvnRepositoryClient.java | 56 ++++++++++++++----- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/scm-test/src/main/java/sonia/scm/repository/client/SvnRepositoryClient.java b/scm-test/src/main/java/sonia/scm/repository/client/SvnRepositoryClient.java index f61958f93d..e9f0652860 100644 --- a/scm-test/src/main/java/sonia/scm/repository/client/SvnRepositoryClient.java +++ b/scm-test/src/main/java/sonia/scm/repository/client/SvnRepositoryClient.java @@ -44,13 +44,13 @@ import org.tmatesoft.svn.core.wc.SVNClientManager; import org.tmatesoft.svn.core.wc.SVNCommitClient; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNUpdateClient; +import org.tmatesoft.svn.core.wc.SVNWCClient; //~--- JDK imports ------------------------------------------------------------ import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -107,12 +107,22 @@ public class SvnRepositoryClient extends AbstractRepositoryClient public void add(String file, String... others) throws RepositoryClientException { - files.add(file); + checkout(); + + List files = new ArrayList(); + + files.add(new File(localRepository, file)); if (others != null) { - files.addAll(Arrays.asList(others)); + for (String f : others) + { + files.add(new File(localRepository, f)); + } } + + addFiles(files); + pendingFiles.addAll(files); } /** @@ -155,13 +165,9 @@ public class SvnRepositoryClient extends AbstractRepositoryClient try { - for (String name : files) - { - File file = new File(localRepository, name); - - cc.doImport(file, remoteRepositoryURL.appendPath(name, true), message, - null, false, true, SVNDepth.FILES); - } + cc.doCommit(pendingFiles.toArray(new File[0]), true, message, null, null, + true, true, SVNDepth.INFINITY); + pendingFiles.clear(); } catch (SVNException ex) { @@ -182,14 +188,38 @@ public class SvnRepositoryClient extends AbstractRepositoryClient // do nothing } + /** + * Method description + * + * + * + * @param files + * + * @throws RepositoryClientException + */ + private void addFiles(List files) throws RepositoryClientException + { + SVNWCClient wClient = client.getWCClient(); + + try + { + wClient.doAdd(files.toArray(new File[0]), true, false, false, + SVNDepth.INFINITY, false, false, false); + } + catch (SVNException ex) + { + throw new RepositoryClientException(ex); + } + } + //~--- fields --------------------------------------------------------------- + /** Field description */ + List pendingFiles = new ArrayList(); + /** Field description */ private SVNClientManager client; - /** Field description */ - private List files = new ArrayList(); - /** Field description */ private SVNURL remoteRepositoryURL; }