merge with branch 1.x

This commit is contained in:
Sebastian Sdorra
2017-01-14 13:25:25 +01:00
22 changed files with 260 additions and 377 deletions

View File

@@ -113,11 +113,8 @@ public class SvnBrowseCommand extends AbstractSvnCommand
String path = request.getPath();
long revisionNumber = SvnUtil.getRevisionNumber(request.getRevision());
if (logger.isDebugEnabled())
{
logger.debug("browser repository {} in path {} at revision {}",
new Object[] { repository.getName(),
path, revisionNumber });
if (logger.isDebugEnabled()) {
logger.debug("browser repository {} in path {} at revision {}", repository.getName(), path, revisionNumber);
}
BrowserResult result = null;

View File

@@ -32,7 +32,6 @@ package sonia.scm.repository.client.spi;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.tmatesoft.svn.core.SVNCommitInfo;
@@ -46,8 +45,10 @@ import org.tmatesoft.svn.core.wc2.SvnCommit;
import org.tmatesoft.svn.core.wc2.SvnLog;
import org.tmatesoft.svn.core.wc2.SvnRevisionRange;
import org.tmatesoft.svn.core.wc2.SvnTarget;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.SvnUtil;
import sonia.scm.repository.client.api.RepositoryClientException;
/**
*
@@ -71,18 +72,14 @@ public class SvnCommitCommand implements CommitCommand {
public Changeset commit(CommitRequest request) throws IOException {
SVNWCClient wClient = client.getWCClient();
List<File> filesToCommit = new ArrayList<>();
// add files
try {
wClient.doAdd(addedFiles.toArray(new File[0]), true, false, false,
SVNDepth.INFINITY, false, false, false);
filesToCommit.addAll(addedFiles);
addedFiles.clear();
} catch (SVNException ex) {
throw new IOException("failed to add files", ex);
throw new RepositoryClientException("failed to add files", ex);
}
// remove files
@@ -92,19 +89,15 @@ public class SvnCommitCommand implements CommitCommand {
File file = removeIt.next();
wClient.doDelete(file, false, true, false);
removeIt.remove();
filesToCommit.add(file);
}
} catch (SVNException ex) {
throw new IOException("failed to remove files", ex);
throw new RepositoryClientException("failed to remove files", ex);
}
SvnTarget workingCopyTarget = SvnTarget.fromFile(workingCopy);
Changeset changeset;
SVNCommitInfo info;
// commit files
try {
SvnCommit commit = client.getOperationFactory().createCommit();
@@ -120,7 +113,7 @@ public class SvnCommitCommand implements CommitCommand {
}
} catch (SVNException ex) {
throw new IOException("failed to commit", ex);
throw new RepositoryClientException("failed to commit", ex);
}
// get log for commit
@@ -133,7 +126,7 @@ public class SvnCommitCommand implements CommitCommand {
changeset = SvnUtil.createChangeset(log.run());
} catch (SVNException ex) {
throw new IOException("failed to create log entry for last commit", ex);
throw new RepositoryClientException("failed to create log entry for last commit", ex);
}
return changeset;

View File

@@ -44,6 +44,7 @@ import org.tmatesoft.svn.core.wc.SVNUpdateClient;
import org.tmatesoft.svn.core.wc.SVNWCUtil;
import org.tmatesoft.svn.core.wc2.SvnOperationFactory;
import sonia.scm.repository.SvnRepositoryHandler;
import sonia.scm.repository.client.api.RepositoryClientException;
/**
* Client provider factory for subversion.
@@ -60,7 +61,7 @@ public class SvnRepositoryClientFactoryProvider implements RepositoryClientFacto
try {
source = SVNURL.fromFile(workingCopy);
} catch (SVNException ex) {
throw new IOException("failed to parse svn url", ex);
throw new RepositoryClientException("failed to parse svn url", ex);
}
// create client
@@ -69,11 +70,11 @@ public class SvnRepositoryClientFactoryProvider implements RepositoryClientFacto
try {
updateClient.doCheckout(source, workingCopy, SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.INFINITY, true);
} catch (SVNException ex) {
throw new IOException("failed to checkout repository", ex);
throw new RepositoryClientException("failed to checkout repository", ex);
}
// return client provider
return new SvnRepositoryClientProvider(client, source, workingCopy);
return new SvnRepositoryClientProvider(client, workingCopy);
}
@Override
@@ -101,7 +102,7 @@ public class SvnRepositoryClientFactoryProvider implements RepositoryClientFacto
try {
remoteUrl = SVNURL.parseURIEncoded(url);
} catch (SVNException ex) {
throw new IOException("failed to parse svn url", ex);
throw new RepositoryClientException("failed to parse svn url", ex);
}
// initial checkout
@@ -109,11 +110,11 @@ public class SvnRepositoryClientFactoryProvider implements RepositoryClientFacto
try {
updateClient.doCheckout(remoteUrl, workingCopy, SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.INFINITY, true);
} catch (SVNException ex) {
throw new IOException("failed to checkout repository", ex);
throw new RepositoryClientException("failed to checkout repository", ex);
}
// return client provider
return new SvnRepositoryClientProvider(client, remoteUrl, workingCopy);
return new SvnRepositoryClientProvider(client, workingCopy);
}
@Override

View File

@@ -52,15 +52,13 @@ public class SvnRepositoryClientProvider extends RepositoryClientProvider {
);
private final SVNClientManager client;
private final SVNURL remoteRepositoryURL;
private final File workingCopy;
private final List<File> addedFiles = new ArrayList<>();
private final List<File> removedFiles = new ArrayList<>();
SvnRepositoryClientProvider(SVNClientManager client, SVNURL remoteRepositoryURL, File workingCopy) {
SvnRepositoryClientProvider(SVNClientManager client, File workingCopy) {
this.client = client;
this.remoteRepositoryURL = remoteRepositoryURL;
this.workingCopy = workingCopy;
}
@@ -78,6 +76,11 @@ public class SvnRepositoryClientProvider extends RepositoryClientProvider {
public SvnCommitCommand getCommitCommand() {
return new SvnCommitCommand(client, workingCopy, addedFiles, removedFiles);
}
@Override
public File getWorkingCopy() {
return workingCopy;
}
@Override
public Set<ClientCommand> getSupportedClientCommands() {