maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r448879 - in /maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src: main/java/org/apache/maven/scm/provider/svn/ main/java/org/apache/maven/scm/provider/svn/repository/ test/java/org/apache/maven/sc...
Date Fri, 22 Sep 2006 09:49:12 GMT
Author: evenisse
Date: Fri Sep 22 02:49:12 2006
New Revision: 448879

URL: http://svn.apache.org/viewvc?view=rev&rev=448879
Log:
initialized default value of tagBase/branchBase

Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtilsTest.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java?view=diff&rev=448879&r1=448878&r2=448879
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java
Fri Sep 22 02:49:12 2006
@@ -80,15 +80,35 @@
         return appendPath( repoPath, null );
     }
 
+    public static String resolveTagBase( SvnScmProviderRepository repository )
+    {
+        return resolveTagBase( repository.getUrl() );
+    }
+
+    public static String resolveTagBase( String repositoryUrl )
+    {
+        return appendPath( getProjectRoot( repositoryUrl ), SVN_TAGS );
+    }
+
+    public static String resolveBranchBase( SvnScmProviderRepository repository )
+    {
+        return resolveBranchBase( repository.getUrl() );
+    }
+
+    public static String resolveBranchBase( String repositoryUrl )
+    {
+        return appendPath( getProjectRoot( repositoryUrl ), SVN_BRANCHES );
+    }
+
     /**
      * Resolves a tag to a repository url.
-     * By supplying the repository to this function (rather than calling {@link #resolveTagUrl(String,
String)}
+     * By supplying the repository to this function (rather than calling {@link #resolveTagUrl(String,String)}
      * the resolution can use the repository's tagBase to override the default tag location.
      *
      * @param repository the repository to use as a base for tag resolution
      * @param tag        tag name
      * @return
-     * @see #resolveUrl(SvnScmProviderRepository, String, String)
+     * @see #resolveUrl(String,String,String,String)
      */
     public static String resolveTagUrl( SvnScmProviderRepository repository, String tag )
     {
@@ -102,7 +122,7 @@
      * @param repositoryUrl string url for the repository
      * @param tag           tag name
      * @return
-     * @see #resolveUrl(SvnScmProviderRepository, String, String)
+     * @see #resolveUrl(String,String,String,String)
      */
     public static String resolveTagUrl( String repositoryUrl, String tag )
     {
@@ -111,17 +131,17 @@
 
     /**
      * Resolves a branch name to a repository url.
-     * By supplying the repository to this function (rather than calling {@link #resolveBranchUrl(String,
String)}
+     * By supplying the repository to this function (rather than calling {@link #resolveBranchUrl(String,String)}
      * the resolution can use the repository's tagBase to override the default tag location.
      *
      * @param repository the repository to use as a base for tag resolution
      * @param branch     tag name
      * @return
-     * @see #resolveUrl(SvnScmProviderRepository, String, String)
+     * @see #resolveUrl(String,String,String,String)
      */
     public static String resolveBranchUrl( SvnScmProviderRepository repository, String branch
)
     {
-        return resolveUrl( repository.getUrl(), repository.getTagBase(), SVN_BRANCHES, branch
);
+        return resolveUrl( repository.getUrl(), repository.getBranchBase(), SVN_BRANCHES,
branch );
     }
 
     /**
@@ -131,11 +151,11 @@
      * @param repositoryUrl string url for the repository
      * @param branch        branch name
      * @return
-     * @see #resolveUrl(SvnScmProviderRepository, String, String)
+     * @see #resolveUrl(String,String,String,String)
      */
     public static String resolveBranchUrl( String repositoryUrl, String branch )
     {
-        return resolveUrl( repositoryUrl, null, SVN_BRANCHES, branch );
+        return resolveUrl( repositoryUrl, resolveBranchBase( repositoryUrl ), SVN_BRANCHES,
branch );
     }
 
     private static String addSuffix( String baseString, String suffix )
@@ -157,7 +177,8 @@
      * the <code>branchTagName</code> is appended to the <code>projectRoot</code>
without adding the subdir.<br>
      * Else, the result is in the format of <code>projectRoot/subdir/branchTagName</code>
directory.<br>
      *
-     * @param projectRoot   Project root to use when building the url.
+     * @param repositoryUrl string url for the repository
+     * @param tagBase       tagBase to use.
      * @param subdir        Subdirectory to append to the project root
      *                      (for branching use "branches", tags use "tags")
      * @param branchTagName Name of the actual branch or tag. Can be an absolute url, simple
tag/branch name,
@@ -188,7 +209,8 @@
         }
 
         // User has a tagBase specified so just return the name appended to the tagBase
-        if ( StringUtils.isNotEmpty( tagBase ) )
+        if ( StringUtils.isNotEmpty( tagBase ) && !tagBase.equals( resolveTagBase(
repositoryUrl ) ) &&
+            !tagBase.equals( resolveBranchBase( repositoryUrl ) ) )
         {
             return appendPath( tagBase, branchTagName );
         }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java?view=diff&rev=448879&r1=448878&r2=448879
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
Fri Sep 22 02:49:12 2006
@@ -18,6 +18,7 @@
 
 import org.apache.maven.scm.provider.ScmProviderRepository;
 import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
+import org.apache.maven.scm.provider.svn.SvnTagBranchUtils;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -36,9 +37,18 @@
      */
     private String tagBase;
 
+    /**
+     * The base directory for any branches. Can be relative to the repository URL or an absolute
URL.
+     */
+    private String branchBase;
+
     public SvnScmProviderRepository( String url )
     {
         parseUrl( url );
+
+        tagBase = SvnTagBranchUtils.resolveTagBase( url );
+
+        branchBase = SvnTagBranchUtils.resolveBranchBase( url );
     }
 
     public SvnScmProviderRepository( String url, String user, String password )
@@ -78,6 +88,29 @@
         this.tagBase = tagBase;
     }
 
+    /**
+     * Returns the url/directory to be used when tagging this repository.
+     */
+    public String getBranchBase()
+    {
+        return branchBase;
+    }
+
+    /**
+     * Sets the url/directory to be used when branching this repository.
+     * The BranchBase is a way to override the default branch location for the
+     * repository.  The default branch location is automatically determined
+     * for repositories in the standard subversion layout (with /tags /branches /trunk).
+     * Specify this value only if the repository is using a directory other than "/branches"
for branching.
+     *
+     * @param branchBase an absolute or relative url to the base directory to create branch
in.
+     *                   URL should be in a format that svn client understands, not the scm
url format.
+     */
+    public void setBranchBase( String branchBase )
+    {
+        this.branchBase = branchBase;
+    }
+
     private void setProtocol( String protocol )
     {
         this.protocol = protocol;
@@ -85,7 +118,7 @@
 
     /**
      * Get the protocol used in this repository (file://, http://, https://,...)
-     * 
+     *
      * @return the protocol
      */
     public String getProtocol()
@@ -165,7 +198,7 @@
 
     /**
      * A ScmProviderRepository like this but with the parent url (stripping the last directory)
-     * 
+     *
      * @return the parent repository or <code>null</null> if this is the top
level repository
      */
     public ScmProviderRepository getParent()

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtilsTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtilsTest.java?view=diff&rev=448879&r1=448878&r2=448879
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtilsTest.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtilsTest.java
Fri Sep 22 02:49:12 2006
@@ -65,6 +65,18 @@
     }
 
     // ----------------------------------------------------------------------
+    // resolveTagBase
+    // ----------------------------------------------------------------------
+
+    public void testResolveTagBase()
+    {
+        assertEquals( "http://foo.com/svn/myproject/tags",
+                      SvnTagBranchUtils.resolveTagBase( "http://foo.com/svn/myproject/trunk"
) );
+        assertEquals( "http://foo.com/svn/myproject/tags",
+                      SvnTagBranchUtils.resolveTagBase( "http://foo.com/svn/myproject/trunk/"
) );
+    }
+
+    // ----------------------------------------------------------------------
     // getProjectRoot
     // ----------------------------------------------------------------------
 
@@ -298,7 +310,15 @@
             repository.setTagBase( tagBase );
         }
 
-        assertEquals( repository.getTagBase(), tagBase );
+        if ( tagBase != null )
+        {
+            assertEquals( repository.getTagBase(), tagBase );
+        }
+        else
+        {
+            assertEquals( repository.getTagBase(), SvnTagBranchUtils.resolveTagBase( repository.getUrl()
) );
+        }
+
         assertEquals( expected, SvnTagBranchUtils.resolveTagUrl( repository, tag ) );
     }
 
@@ -308,16 +328,24 @@
         testResolveBranchUrl( scmUrl, null, branch, expected );
     }
 
-    private void testResolveBranchUrl( String scmUrl, String tagBase, String branch, String
expected )
+    private void testResolveBranchUrl( String scmUrl, String branchBase, String branch, String
expected )
         throws Exception
     {
         SvnScmProviderRepository repository = getSvnRepository( scmUrl );
-        if ( tagBase != null )
+        if ( branchBase != null )
         {
-            repository.setTagBase( tagBase );
+            repository.setBranchBase( branchBase );
+        }
+
+        if ( branchBase != null )
+        {
+            assertEquals( repository.getBranchBase(), branchBase );
+        }
+        else
+        {
+            assertEquals( repository.getBranchBase(), SvnTagBranchUtils.resolveBranchBase(
repository.getUrl() ) );
         }
 
-        assertEquals( repository.getTagBase(), tagBase );
         assertEquals( expected, SvnTagBranchUtils.resolveBranchUrl( repository, branch )
);
     }
 



Mime
View raw message