diff --git a/core/src/main/java/hudson/scm/SubversionChangeLogBuilder.java b/core/src/main/java/hudson/scm/SubversionChangeLogBuilder.java index c031c6f26d68c0e3304dcd802949baa6552ac975..29d439ea0e100db512e9ce54e6b988c138bbdbad 100644 --- a/core/src/main/java/hudson/scm/SubversionChangeLogBuilder.java +++ b/core/src/main/java/hudson/scm/SubversionChangeLogBuilder.java @@ -60,29 +60,29 @@ final class SubversionChangeLogBuilder { final SVNClientManager manager = SubversionSCM.createSvnClientManager(createAuthenticationProvider()); try { - SVNLogClient svnlc = manager.getLogClient(); - TransformerHandler th = createTransformerHandler(); - th.setResult(changeLog); - SVNXMLLogHandler logHandler = new SVNXMLLogHandler(th); - // work around for http://svnkit.com/tracker/view.php?id=175 - th.setDocumentLocator(DUMMY_LOCATOR); - logHandler.startDocument(); - - for (ModuleLocation l : scm.getLocations()) { - changelogFileCreated |= buildModule(l.remote, svnlc, logHandler); - } - for(String path : externals) { - changelogFileCreated |= buildModule( - getUrlForPath(build.getProject().getWorkspace().child(path)), svnlc, logHandler); - } + SVNLogClient svnlc = manager.getLogClient(); + TransformerHandler th = createTransformerHandler(); + th.setResult(changeLog); + SVNXMLLogHandler logHandler = new SVNXMLLogHandler(th); + // work around for http://svnkit.com/tracker/view.php?id=175 + th.setDocumentLocator(DUMMY_LOCATOR); + logHandler.startDocument(); + + for (ModuleLocation l : scm.getLocations()) { + changelogFileCreated |= buildModule(l.remote, svnlc, logHandler); + } + for(String path : externals) { + changelogFileCreated |= buildModule( + getUrlForPath(build.getProject().getWorkspace().child(path)), svnlc, logHandler); + } - if(changelogFileCreated) { - logHandler.endDocument(); - } + if(changelogFileCreated) { + logHandler.endDocument(); + } - return changelogFileCreated; + return changelogFileCreated; } finally { - manager.dispose(); + manager.dispose(); } } @@ -103,8 +103,8 @@ final class SubversionChangeLogBuilder { } Long thisRev = thisRevisions.get(url); if (thisRev == null) { - listener.error("No revision found for URL: " + url + " in " + SubversionSCM.getRevisionFile(build) + ". Revision file contains: " + thisRevisions.keySet()); - return true; + listener.error("No revision found for URL: " + url + " in " + SubversionSCM.getRevisionFile(build) + ". Revision file contains: " + thisRevisions.keySet()); + return true; } if(thisRev.equals(prevRev)) { logger.println("no change for "+url+" since the previous build"); @@ -150,18 +150,18 @@ final class SubversionChangeLogBuilder { public String invoke(File p, VirtualChannel channel) throws IOException { final SVNClientManager manager = SubversionSCM.createSvnClientManager(authProvider); try { - final SVNWCClient svnwc = manager.getWCClient(); - - SVNInfo info; - try { - info = svnwc.doInfo(p, SVNRevision.WORKING); - return info.getURL().toDecodedString(); - } catch (SVNException e) { - e.printStackTrace(); - return null; - } + final SVNWCClient svnwc = manager.getWCClient(); + + SVNInfo info; + try { + info = svnwc.doInfo(p, SVNRevision.WORKING); + return info.getURL().toDecodedString(); + } catch (SVNException e) { + e.printStackTrace(); + return null; + } } finally { - manager.dispose(); + manager.dispose(); } } diff --git a/core/src/main/java/hudson/scm/SubversionSCM.java b/core/src/main/java/hudson/scm/SubversionSCM.java index b3760c2b8be05603214b8c2517df39aac45ef58a..a9334ffb461b0d6a9eeda910b90f2092064a03cb 100644 --- a/core/src/main/java/hudson/scm/SubversionSCM.java +++ b/core/src/main/java/hudson/scm/SubversionSCM.java @@ -369,46 +369,46 @@ public class SubversionSCM extends SCM implements Serializable { public List invoke(File ws, VirtualChannel channel) throws IOException { final SVNClientManager manager = createSvnClientManager(authProvider); try { - final SVNUpdateClient svnuc = manager.getUpdateClient(); - final List externals = new ArrayList(); // store discovered externals to here - final SVNRevision revision = SVNRevision.create(timestamp); - if(update) { - for (final ModuleLocation l : locations) { - try { - listener.getLogger().println("Updating "+ l.remote); - - svnuc.setEventHandler(new SubversionUpdateEventHandler(listener, externals, l.local)); - svnuc.doUpdate(new File(ws, l.local).getCanonicalFile(), revision, true); - - } catch (final 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()); + final SVNUpdateClient svnuc = manager.getUpdateClient(); + final List externals = new ArrayList(); // store discovered externals to here + final SVNRevision revision = SVNRevision.create(timestamp); + if(update) { + for (final ModuleLocation l : locations) { + try { + listener.getLogger().println("Updating "+ l.remote); + + svnuc.setEventHandler(new SubversionUpdateEventHandler(listener, externals, l.local)); + svnuc.doUpdate(new File(ws, l.local).getCanonicalFile(), revision, true); + + } catch (final 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; } - return null; } - } - } else { - Util.deleteContentsRecursive(ws); + } else { + Util.deleteContentsRecursive(ws); - for (final ModuleLocation l : locations) { - try { - final SVNURL url = SVNURL.parseURIEncoded(l.remote); - listener.getLogger().println("Checking out "+url); + for (final ModuleLocation l : locations) { + try { + final 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); + svnuc.setEventHandler(new SubversionUpdateEventHandler(listener, externals, l.local)); + svnuc.doCheckout(url, new File(ws, l.local).getCanonicalFile(), SVNRevision.HEAD, revision, true); - } catch (final SVNException e) { - e.printStackTrace(listener.error("Failed to check out "+l.remote)); - return null; + } catch (final SVNException e) { + e.printStackTrace(listener.error("Failed to check out "+l.remote)); + return null; + } } } - } - return externals; + return externals; } finally { - manager.dispose(); + manager.dispose(); } } @@ -495,10 +495,10 @@ public class SubversionSCM extends SCM implements Serializable { private static SVNInfo parseSvnInfo(File workspace, ISVNAuthenticationProvider authProvider) throws SVNException { final SVNClientManager manager = createSvnClientManager(authProvider); try { - final SVNWCClient svnWc = manager.getWCClient(); - return svnWc.doInfo(workspace,SVNRevision.WORKING); + final SVNWCClient svnWc = manager.getWCClient(); + return svnWc.doInfo(workspace,SVNRevision.WORKING); } finally { - manager.dispose(); + manager.dispose(); } } @@ -511,10 +511,10 @@ public class SubversionSCM extends SCM implements Serializable { private static SVNInfo parseSvnInfo(SVNURL remoteUrl, ISVNAuthenticationProvider authProvider) throws SVNException { final SVNClientManager manager = createSvnClientManager(authProvider); try { - final SVNWCClient svnWc = manager.getWCClient(); - return svnWc.doInfo(remoteUrl, SVNRevision.HEAD, SVNRevision.HEAD); + final SVNWCClient svnWc = manager.getWCClient(); + return svnWc.doInfo(remoteUrl, SVNRevision.HEAD, SVNRevision.HEAD); } finally { - manager.dispose(); + manager.dispose(); } } @@ -543,29 +543,29 @@ public class SubversionSCM extends SCM implements Serializable { final SVNClientManager manager = createSvnClientManager(authProvider); try { - final SVNWCClient svnWc = manager.getWCClient(); - // invoke the "svn info" - for( ModuleLocation module : locations ) { - try { - SvnInfo info = new SvnInfo(svnWc.doInfo(new File(ws,module.local), SVNRevision.WORKING)); - revisions.put(info.url,info); - } catch (SVNException e) { - e.printStackTrace(listener.error("Failed to parse svn info for "+module.remote)); - } - } - for(String local : externals){ - try { - SvnInfo info = new SvnInfo(svnWc.doInfo(new File(ws, local),SVNRevision.WORKING)); - revisions.put(info.url,info); - } catch (SVNException e) { - e.printStackTrace(listener.error("Failed to parse svn info for external "+local)); + final SVNWCClient svnWc = manager.getWCClient(); + // invoke the "svn info" + for( ModuleLocation module : locations ) { + try { + SvnInfo info = new SvnInfo(svnWc.doInfo(new File(ws,module.local), SVNRevision.WORKING)); + revisions.put(info.url,info); + } catch (SVNException e) { + e.printStackTrace(listener.error("Failed to parse svn info for "+module.remote)); + } } + for(String local : externals){ + try { + SvnInfo info = new SvnInfo(svnWc.doInfo(new File(ws, local),SVNRevision.WORKING)); + revisions.put(info.url,info); + } catch (SVNException e) { + e.printStackTrace(listener.error("Failed to parse svn info for external "+local)); + } - } + } - return revisions; + return revisions; } finally { - manager.dispose(); + manager.dispose(); } } private static final long serialVersionUID = 1L; @@ -1021,7 +1021,7 @@ public class SubversionSCM extends SCM implements Serializable { if(item!=null) item.delete(); if (repository != null) - repository.closeSession(); + repository.closeSession(); } } @@ -1054,37 +1054,37 @@ public class SubversionSCM extends SCM implements Serializable { if (checkRepositoryPath(repoURL)==SVNNodeKind.NONE) { SVNRepository repository = null; try { - repository = getRepository(repoURL); - long rev = repository.getLatestRevision(); - // now go back the tree and find if there's anything that exists - String repoPath = getRelativePath(repoURL, repository); - String p = repoPath; - while(p.length()>0) { - p = SVNPathUtil.removeTail(p); - if(repository.checkPath(p,rev)==SVNNodeKind.DIR) { - // found a matching path - List entries = new ArrayList(); - repository.getDir(p,rev,false,entries); - - // build up the name list - List paths = new ArrayList(); - for (SVNDirEntry e : entries) - if(e.getKind()==SVNNodeKind.DIR) - paths.add(e.getName()); - - String head = SVNPathUtil.head(repoPath.substring(p.length() + 1)); - String candidate = EditDistance.findNearest(head,paths); - - error("'%1$s/%2$s' doesn't exist in the repository. Maybe you meant '%1$s/%3$s'?", - p, head, candidate); - return; - } - } - - error(repoPath+" doesn't exist in the repository"); + repository = getRepository(repoURL); + long rev = repository.getLatestRevision(); + // now go back the tree and find if there's anything that exists + String repoPath = getRelativePath(repoURL, repository); + String p = repoPath; + while(p.length()>0) { + p = SVNPathUtil.removeTail(p); + if(repository.checkPath(p,rev)==SVNNodeKind.DIR) { + // found a matching path + List entries = new ArrayList(); + repository.getDir(p,rev,false,entries); + + // build up the name list + List paths = new ArrayList(); + for (SVNDirEntry e : entries) + if(e.getKind()==SVNNodeKind.DIR) + paths.add(e.getName()); + + String head = SVNPathUtil.head(repoPath.substring(p.length() + 1)); + String candidate = EditDistance.findNearest(head,paths); + + error("'%1$s/%2$s' doesn't exist in the repository. Maybe you meant '%1$s/%3$s'?", + p, head, candidate); + return; + } + } + + error(repoPath+" doesn't exist in the repository"); } finally { - if (repository != null) - repository.closeSession(); + if (repository != null) + repository.closeSession(); } } else ok(); @@ -1109,18 +1109,18 @@ public class SubversionSCM extends SCM implements Serializable { } public SVNNodeKind checkRepositoryPath(SVNURL repoURL) throws SVNException { - SVNRepository repository = null; + SVNRepository repository = null; - try { - repository = getRepository(repoURL); - repository.testConnection(); + try { + repository = getRepository(repoURL); + repository.testConnection(); - long rev = repository.getLatestRevision(); - String repoPath = getRelativePath(repoURL, repository); - return repository.checkPath(repoPath, rev); + long rev = repository.getLatestRevision(); + String repoPath = getRelativePath(repoURL, repository); + return repository.checkPath(repoPath, rev); } finally { - if (repository != null) - repository.closeSession(); + if (repository != null) + repository.closeSession(); } } diff --git a/core/src/main/java/hudson/scm/SubversionTagAction.java b/core/src/main/java/hudson/scm/SubversionTagAction.java index 6d042b317a4b180e9ae7d58ac75f53dcaca0bc8d..e643486b87018154f066adea64fac2fd6a1c92cd 100644 --- a/core/src/main/java/hudson/scm/SubversionTagAction.java +++ b/core/src/main/java/hudson/scm/SubversionTagAction.java @@ -150,29 +150,29 @@ public class SubversionTagAction extends AbstractScmTagAction { try { final SVNClientManager cm = SubversionSCM.createSvnClientManager(SubversionSCM.DescriptorImpl.DESCRIPTOR.createAuthenticationProvider()); try { - for (Entry e : tagSet.entrySet()) { - PrintStream logger = listener.getLogger(); - logger.println("Tagging "+e.getKey()+" to "+e.getValue()); - - try { - SVNURL src = SVNURL.parseURIDecoded(e.getKey().url); - SVNURL dst = SVNURL.parseURIDecoded(e.getValue()); - - SVNCopyClient svncc = cm.getCopyClient(); - svncc.doCopy(src, SVNRevision.create(e.getKey().revision), dst, false, true, "Tagged from "+build ); - } catch (SVNException x) { - x.printStackTrace(listener.error("Failed to tag")); - return; + for (Entry e : tagSet.entrySet()) { + PrintStream logger = listener.getLogger(); + logger.println("Tagging "+e.getKey()+" to "+e.getValue()); + + try { + SVNURL src = SVNURL.parseURIDecoded(e.getKey().url); + SVNURL dst = SVNURL.parseURIDecoded(e.getValue()); + + SVNCopyClient svncc = cm.getCopyClient(); + svncc.doCopy(src, SVNRevision.create(e.getKey().revision), dst, false, true, "Tagged from "+build ); + } catch (SVNException x) { + x.printStackTrace(listener.error("Failed to tag")); + return; + } } - } - // completed successfully - for (Entry e : tagSet.entrySet()) - SubversionTagAction.this.tags.get(e.getKey()).add(e.getValue()); - build.save(); - workerThread = null; + // completed successfully + for (Entry e : tagSet.entrySet()) + SubversionTagAction.this.tags.get(e.getKey()).add(e.getValue()); + build.save(); + workerThread = null; } finally { - cm.dispose(); + cm.dispose(); } } catch (Throwable e) { e.printStackTrace(listener.fatalError(e.getMessage()));