() {
- public Boolean invoke(File ws, VirtualChannel channel) throws IOException {
- Util.deleteContentsRecursive(ws);
- SVNUpdateClient svnuc = createSvnClientManager(authProvider).getUpdateClient();
- svnuc.setEventHandler(new SubversionUpdateEventHandler(listener));
-
- StringTokenizer tokens = new StringTokenizer(modules);
- while(tokens.hasMoreTokens()) {
- try {
- SVNURL url = SVNURL.parseURIEncoded(tokens.nextToken());
- listener.getLogger().println("Checking out "+url);
-
- svnuc.doCheckout(url, new File(ws, getLastPathComponent(url.getPath())), SVNRevision.HEAD, SVNRevision.HEAD, true );
- } catch (SVNException e) {
- e.printStackTrace(listener.error("Error in subversion"));
- return false;
- }
- }
-
- return true;
- }
- });
- }
- }
-
- /**
- * Creates {@link SVNClientManager}.
- *
- *
- * This method must be executed on the slave where svn operations are performed.
- *
- * @param authProvider
- * The value obtained from {@link DescriptorImpl#createAuthenticationProvider()}.
- * If the operation runs on slaves,
- * (and properly remoted, if the svn operations run on slaves.)
- */
- private static SVNClientManager createSvnClientManager(ISVNAuthenticationProvider authProvider) {
- ISVNAuthenticationManager sam = SVNWCUtil.createDefaultAuthenticationManager();
- sam.setAuthenticationProvider(authProvider);
- return SVNClientManager.newInstance(SVNWCUtil.createDefaultOptions(true),sam);
- }
-
- public static final class SvnInfo implements Serializable {
- /**
- * Decoded repository URL.
- */
- final String url;
- final long revision;
-
- public SvnInfo(String url, long revision) {
- this.url = url;
- this.revision = revision;
- }
-
- public SvnInfo(SVNInfo info) {
- this( info.getURL().toDecodedString(), info.getCommittedRevision().getNumber() );
- }
-
- public SVNURL getSVNURL() throws SVNException {
- return SVNURL.parseURIDecoded(url);
- }
-
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * Gets the SVN metadata for the given local workspace.
- *
- * @param workspace
- * The target to run "svn info".
- */
- private SVNInfo parseSvnInfo(File workspace, ISVNAuthenticationProvider authProvider) throws SVNException {
- SVNWCClient svnWc = createSvnClientManager(authProvider).getWCClient();
- return svnWc.doInfo(workspace,SVNRevision.WORKING);
- }
-
- /**
- * Gets the SVN metadata for the remote repository.
- *
- * @param remoteUrl
- * The target to run "svn info".
- */
- private SVNInfo parseSvnInfo(SVNURL remoteUrl, ISVNAuthenticationProvider authProvider) throws SVNException {
- SVNWCClient svnWc = createSvnClientManager(authProvider).getWCClient();
- return svnWc.doInfo(remoteUrl, SVNRevision.HEAD, SVNRevision.HEAD);
- }
-
- /**
- * Checks .svn files in the workspace and finds out revisions of the modules
- * that the workspace has.
- *
- * @return
- * null if the parsing somehow fails. Otherwise a map from the repository URL to revisions.
- */
- private Map buildRevisionMap(FilePath workspace, final TaskListener listener) throws IOException, InterruptedException {
- final ISVNAuthenticationProvider authProvider = getDescriptor().createAuthenticationProvider();
- return workspace.act(new FileCallable