diff --git a/core/src/main/java/hudson/scm/SubversionSCM.java b/core/src/main/java/hudson/scm/SubversionSCM.java
index 89d672415a..db0d500562 100644
--- a/core/src/main/java/hudson/scm/SubversionSCM.java
+++ b/core/src/main/java/hudson/scm/SubversionSCM.java
@@ -76,6 +76,11 @@ import java.util.regex.Pattern;
/**
* Subversion SCM.
*
+ *
+ * Because this instance refers to some other classes that are not necessarily
+ * Java serializable (like {@link #browser}), remotable {@link FileCallable}s all
+ * need to be declared as static inner classes.
+ *
* @author Kohsuke Kawaguchi
*/
public class SubversionSCM extends SCM implements Serializable {
@@ -291,7 +296,7 @@ public class SubversionSCM extends SCM implements Serializable {
// write out the revision file
PrintWriter w = new PrintWriter(new FileOutputStream(getRevisionFile(build)));
try {
- Map revMap = buildRevisionMap(workspace,listener,externals);
+ Map revMap = workspace.act(new BuildRevisionMapTask(this, listener, externals));
for (Entry e : revMap.entrySet()) {
w.println( e.getKey() +'/'+ e.getValue().revision );
}
@@ -324,55 +329,70 @@ public class SubversionSCM extends SCM implements Serializable {
* if the operation failed. Otherwise the set of local workspace paths
* (relative to the workspace root) that has loaded due to svn:external.
*/
- private List checkout(final Date timestamp, FilePath workspace, final TaskListener listener) throws IOException, InterruptedException {
- final ISVNAuthenticationProvider authProvider = getDescriptor().createAuthenticationProvider();
+ private List checkout(Date timestamp, FilePath workspace, TaskListener listener) throws IOException, InterruptedException {
+ boolean isUpdatable = useUpdate && workspace.act(new IsUpdatableTask(this, listener));
+ return workspace.act(new CheckOutTask(this, timestamp, isUpdatable, listener));
+ }
+ private static class CheckOutTask implements FileCallable> {
+ private final ISVNAuthenticationProvider authProvider;
+ private final Date timestamp;
// true to "svn update", false to "svn checkout".
- final boolean update = useUpdate && isUpdatable(workspace, listener);
+ private final boolean update;
+ private final TaskListener listener;
+ private final ModuleLocation[] locations;
- return workspace.act(new FileCallable>() {
- public List invoke(File ws, VirtualChannel channel) throws IOException {
- SVNUpdateClient svnuc = createSvnClientManager(authProvider).getUpdateClient();
- List externals = new ArrayList(); // store discovered externals to here
- SVNRevision revision = SVNRevision.create(timestamp);
- if(update) {
+ public CheckOutTask(SubversionSCM parent, Date timestamp, boolean update, TaskListener listener) {
+ this.authProvider = parent.getDescriptor().createAuthenticationProvider();
+ this.timestamp = timestamp;
+ this.update = update;
+ this.listener = listener;
+ this.locations = parent.getLocations();
+ }
- for (ModuleLocation l : getLocations()) {
- try {
- listener.getLogger().println("Updating "+ l.remote);
+ public List invoke(File ws, VirtualChannel channel) throws IOException {
+ SVNUpdateClient svnuc = createSvnClientManager(authProvider).getUpdateClient();
+ List externals = new ArrayList(); // store discovered externals to here
+ SVNRevision revision = SVNRevision.create(timestamp);
+ if(update) {
- svnuc.setEventHandler(new SubversionUpdateEventHandler(listener, externals, l.local));
- svnuc.doUpdate(new File(ws, l.local).getCanonicalFile(), revision, true);
+ for (ModuleLocation l : locations) {
+ try {
+ listener.getLogger().println("Updating "+ l.remote);
- } catch (SVNException e) {
- e.printStackTrace(listener.error("Failed to update "+l.remote));
- // trouble-shooting probe for #591
- if(e.getErrorMessage().getErrorCode()==SVNErrorCode.WC_NOT_LOCKED) {
- listener.getLogger().println("Polled jobs are "+SCMTrigger.DESCRIPTOR.getItemsBeingPolled());
- }
- return null;
- }
- }
- } else {
- Util.deleteContentsRecursive(ws);
-
- for (ModuleLocation l : getLocations()) {
- try {
- SVNURL url = SVNURL.parseURIEncoded(l.remote);
- listener.getLogger().println("Checking out "+url);
-
- svnuc.setEventHandler(new SubversionUpdateEventHandler(listener, externals, l.local));
- svnuc.doCheckout(url, new File(ws, l.local).getCanonicalFile(), SVNRevision.HEAD, revision, true);
-
- } catch (SVNException e) {
- e.printStackTrace(listener.error("Failed to check out "+l.remote));
- return null;
+ svnuc.setEventHandler(new SubversionUpdateEventHandler(listener, externals, l.local));
+ svnuc.doUpdate(new File(ws, l.local).getCanonicalFile(), revision, true);
+
+ } catch (SVNException e) {
+ e.printStackTrace(listener.error("Failed to update "+l.remote));
+ // trouble-shooting probe for #591
+ if(e.getErrorMessage().getErrorCode()== SVNErrorCode.WC_NOT_LOCKED) {
+ listener.getLogger().println("Polled jobs are "+ SCMTrigger.DESCRIPTOR.getItemsBeingPolled());
}
+ return null;
+ }
+ }
+ } else {
+ Util.deleteContentsRecursive(ws);
+
+ for (ModuleLocation l : locations) {
+ try {
+ SVNURL url = SVNURL.parseURIEncoded(l.remote);
+ listener.getLogger().println("Checking out "+url);
+
+ svnuc.setEventHandler(new SubversionUpdateEventHandler(listener, externals, l.local));
+ svnuc.doCheckout(url, new File(ws, l.local).getCanonicalFile(), SVNRevision.HEAD, revision, true);
+
+ } catch (SVNException e) {
+ e.printStackTrace(listener.error("Failed to check out "+l.remote));
+ return null;
}
}
- return externals;
}
- });
+ return externals;
+ }
+
+ private static final long serialVersionUID = 1L;
}
/**
@@ -428,9 +448,8 @@ public class SubversionSCM extends SCM implements Serializable {
SvnInfo svnInfo = (SvnInfo) o;
if (revision != svnInfo.revision) return false;
- if (!url.equals(svnInfo.url)) return false;
+ return url.equals(svnInfo.url);
- return true;
}
public int hashCode() {
@@ -453,7 +472,7 @@ public class SubversionSCM extends SCM implements Serializable {
* @param workspace
* The target to run "svn info".
*/
- private SVNInfo parseSvnInfo(File workspace, ISVNAuthenticationProvider authProvider) throws SVNException {
+ private static SVNInfo parseSvnInfo(File workspace, ISVNAuthenticationProvider authProvider) throws SVNException {
SVNWCClient svnWc = createSvnClientManager(authProvider).getWCClient();
return svnWc.doInfo(workspace,SVNRevision.WORKING);
}
@@ -476,35 +495,45 @@ public class SubversionSCM extends SCM implements Serializable {
* @return
* null if the parsing somehow fails. Otherwise a map from the repository URL to revisions.
*/
- private Map buildRevisionMap(FilePath workspace, final TaskListener listener, final List externals) throws IOException, InterruptedException {
- final ISVNAuthenticationProvider authProvider = getDescriptor().createAuthenticationProvider();
- return workspace.act(new FileCallable