From 2eee703c3f242d0a52b25caec640b024d76712bf Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sun, 25 Mar 2007 23:25:19 +0000 Subject: [PATCH] Revised the FishEye setting so that Hudson can work with FishEye repositories that only partially mirror a SVN repository. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2660 71c3de6d-444a-0410-be80-ed276b4c234a --- .../java/hudson/scm/browsers/FishEyeSVN.java | 38 +++++++++++++++++-- .../scm/browsers/FishEyeSVN/config.jelly | 3 ++ .../scm-browsers/fisheye-svn/root-module.html | 7 ++++ .../help/scm-browsers/fisheye-svn/url.html | 2 +- 4 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 war/resources/help/scm-browsers/fisheye-svn/root-module.html diff --git a/core/src/main/java/hudson/scm/browsers/FishEyeSVN.java b/core/src/main/java/hudson/scm/browsers/FishEyeSVN.java index 7d40df35c1..cfe5d12a42 100644 --- a/core/src/main/java/hudson/scm/browsers/FishEyeSVN.java +++ b/core/src/main/java/hudson/scm/browsers/FishEyeSVN.java @@ -31,25 +31,55 @@ public class FishEyeSVN extends SubversionRepositoryBrowser { */ public final URL url; + /** + * Root SVN module name (like 'foo/bar' — normalized to + * have no leading nor trailing slash.) Can be empty. + */ + private final String rootModule; + /** * @stapler-constructor */ - public FishEyeSVN(URL url) throws MalformedURLException { + public FishEyeSVN(URL url, String rootModule) throws MalformedURLException { if(!url.toExternalForm().endsWith("/")) url = new URL(url.toExternalForm()+"/"); this.url = url; + + // normalize + rootModule = rootModule.trim(); + if(rootModule.startsWith("/")) + rootModule = rootModule.substring(1); + if(rootModule.endsWith("/")) + rootModule = rootModule.substring(0,rootModule.length()-1); + + this.rootModule = rootModule; + } + + public String getRootModule() { + if(rootModule==null) + return ""; // compatibility + return rootModule; } @Override public URL getDiffLink(Path path) throws IOException { int r = path.getLogEntry().getRevision(); - return new URL(url,trimHeadSlash(path.getValue())+ - MessageFormat.format("?r1={0}&r2={1}",r-1,r)); + return new URL(url, getPath(path)+MessageFormat.format("?r1={0}&r2={1}",r-1,r)); } @Override public URL getFileLink(Path path) throws IOException { - return new URL(url,trimHeadSlash(path.getValue())); + return new URL(url, getPath(path)); + } + + /** + * Trims off the root module portion to compute the path within FishEye. + */ + private String getPath(Path path) { + String s = trimHeadSlash(path.getValue()); + if(s.startsWith(rootModule)) // this should be always true, but be defensive + s = trimHeadSlash(s.substring(rootModule.length())); + return s; } /** diff --git a/core/src/main/resources/hudson/scm/browsers/FishEyeSVN/config.jelly b/core/src/main/resources/hudson/scm/browsers/FishEyeSVN/config.jelly index c981b90732..d3aa387de1 100644 --- a/core/src/main/resources/hudson/scm/browsers/FishEyeSVN/config.jelly +++ b/core/src/main/resources/hudson/scm/browsers/FishEyeSVN/config.jelly @@ -3,4 +3,7 @@ + + + \ No newline at end of file diff --git a/war/resources/help/scm-browsers/fisheye-svn/root-module.html b/war/resources/help/scm-browsers/fisheye-svn/root-module.html new file mode 100644 index 0000000000..bf1fbac508 --- /dev/null +++ b/war/resources/help/scm-browsers/fisheye-svn/root-module.html @@ -0,0 +1,7 @@ +
+ Specify the root subversion module that this FishEye monitors. + For example, for http://fisheye6.cenqua.com/browse/ant/, + this field would be ant because it displays the directory "/ant" + of ASF repo. If FishEye is configured to display the whole SVN repository, + leave this field empty. +
\ No newline at end of file diff --git a/war/resources/help/scm-browsers/fisheye-svn/url.html b/war/resources/help/scm-browsers/fisheye-svn/url.html index 7a2a7c0801..4b7ac698fa 100644 --- a/war/resources/help/scm-browsers/fisheye-svn/url.html +++ b/war/resources/help/scm-browsers/fisheye-svn/url.html @@ -1,4 +1,4 @@
Specify the URL of this module in FishEye. - (such as http://fisheye5.cenqua.com/browse/glassfish/.) + (such as http://fisheye6.cenqua.com/browse/ant/)
\ No newline at end of file