return new UpdateTask() {
private static final long serialVersionUID = 8349986526712487762L;
@Override
public List<External> perform() throws IOException, InterruptedException {
final SVNUpdateClient svnuc = clientManager.getUpdateClient();
final List<External> externals = new ArrayList<External>(); // store discovered externals to here
listener.getLogger().println("Cleaning local Directory " + location.getLocalDir());
Util.deleteContentsRecursive(new File(ws, location.getLocalDir()));
// buffer the output by a separate thread so that the update operation
// won't be blocked by the remoting of the data
PipedOutputStream pos = new PipedOutputStream();
StreamCopyThread sct = new StreamCopyThread("svn log copier", new PipedInputStream(pos), listener.getLogger());
sct.start();
try {
SVNRevision r = getRevision(location);
String revisionName = r.getDate() != null ?
fmt.format(r.getDate()) : r.toString();
listener.getLogger().println("Checking out " + location.remote + " at revision " + revisionName);
File local = new File(ws, location.getLocalDir());
SubversionUpdateEventHandler eventHandler = new SubversionUpdateEventHandler(new PrintStream(pos), externals, local, location.getLocalDir());
svnuc.setEventHandler(eventHandler);
svnuc.setExternalsHandler(eventHandler);
svnuc.setIgnoreExternals(location.isIgnoreExternalsOption());
SVNDepth svnDepth = getSvnDepth(location.getDepthOption());
SvnCheckout checkout = svnuc.getOperationsFactory().createCheckout();
checkout.setSource(SvnTarget.fromURL(location.getSVNURL(), SVNRevision.HEAD));
checkout.setSingleTarget(SvnTarget.fromFile(local.getCanonicalFile()));
checkout.setDepth(svnDepth);
checkout.setRevision(r);
checkout.setAllowUnversionedObstructions(true);
checkout.setIgnoreExternals(location.isIgnoreExternalsOption());
checkout.setExternalsHandler(SvnCodec.externalsHandler(svnuc.getExternalsHandler()));
// Workaround for SVNKIT-430 is to set the working copy format when
// a checkout is performed.
checkout.setTargetWorkingCopyFormat(SubversionWorkspaceSelector.workspaceFormat);
checkout.run();