maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r374533 - in /maven/scm/trunk: maven-scm-api/src/main/java/org/apache/maven/scm/provider/ maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/repository/ maven-scm-providers/maven-scm-provider-perfo...
Date Thu, 02 Feb 2006 22:37:48 GMT
Author: evenisse
Date: Thu Feb  2 14:37:33 2006
New Revision: 374533

URL: http://svn.apache.org/viewcvs?rev=374533&view=rev
Log:
Remove duplicate code for Scm repositories that use host/port

Added:
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java
  (with props)
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/repository/CvsScmProviderRepository.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/repository/PerforceScmProviderRepository.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/repository/StarteamScmProviderRepository.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java

Added: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java?rev=374533&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java
(added)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java
Thu Feb  2 14:37:33 2006
@@ -0,0 +1,49 @@
+package org.apache.maven.scm.provider;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public abstract class ScmProviderRepositoryWithHost
+    extends ScmProviderRepository
+{
+    private String host;
+
+    private int port;
+
+    public String getHost()
+    {
+        return host;
+    }
+
+    public void setHost( String host )
+    {
+        this.host = host;
+    }
+
+    public int getPort()
+    {
+        return port;
+    }
+
+    public void setPort( int port )
+    {
+        this.port = port;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/repository/CvsScmProviderRepository.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/repository/CvsScmProviderRepository.java?rev=374533&r1=374532&r2=374533&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/repository/CvsScmProviderRepository.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/repository/CvsScmProviderRepository.java
Thu Feb  2 14:37:33 2006
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
 import org.apache.maven.scm.provider.cvslib.CvsScmProvider;
 
 /**
@@ -25,7 +25,7 @@
  * @version $Id$
  */
 public class CvsScmProviderRepository
-    extends ScmProviderRepository
+    extends ScmProviderRepositoryWithHost
 {
     /** */
     private String cvsroot;
@@ -34,12 +34,6 @@
     private String transport;
 
     /** */
-    private String host;
-
-    /** */
-    private int port;
-
-    /** */
     private String path;
 
     /** */
@@ -62,9 +56,9 @@
 
         setPassword( password );
 
-        this.host = host;
+        setHost( host );
 
-        this.port = port;
+        setPort( port );
 
         this.path = path;
 
@@ -114,24 +108,6 @@
     public String getTransport()
     {
         return transport;
-    }
-
-    /**
-     * @return The host.
-     */
-    public String getHost()
-    {
-        return host;
-    }
-
-    /**
-     * Returns the port or -1 if it isn't set.
-     *
-     * @return The port.
-     */
-    public int getPort()
-    {
-        return port;
     }
 
     /**

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/repository/PerforceScmProviderRepository.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/repository/PerforceScmProviderRepository.java?rev=374533&r1=374532&r2=374533&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/repository/PerforceScmProviderRepository.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/repository/PerforceScmProviderRepository.java
Thu Feb  2 14:37:33 2006
@@ -16,26 +16,22 @@
  * limitations under the License.
  */
 
-import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
  */
 public class PerforceScmProviderRepository
-    extends ScmProviderRepository
+    extends ScmProviderRepositoryWithHost
 {
-    private String host;
-
-    private int port;
-
     private String path;
 
     public PerforceScmProviderRepository( String host, int port, String path, String user,
String password )
     {
-        this.host = host;
+        setHost( host );
 
-        this.port = port;
+        setPort( port );
 
         this.path = path;
 
@@ -47,16 +43,6 @@
     // ----------------------------------------------------------------------
     // ScmProviderRepository Implementation
     // ----------------------------------------------------------------------
-
-    public String getHost()
-    {
-        return host;
-    }
-
-    public int getPort()
-    {
-        return port;
-    }
 
     public String getPath()
     {

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/repository/StarteamScmProviderRepository.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/repository/StarteamScmProviderRepository.java?rev=374533&r1=374532&r2=374533&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/repository/StarteamScmProviderRepository.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/repository/StarteamScmProviderRepository.java
Thu Feb  2 14:37:33 2006
@@ -16,19 +16,15 @@
  * limitations under the License.
  */
 
-import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
  */
 public class StarteamScmProviderRepository
-    extends ScmProviderRepository
+    extends ScmProviderRepositoryWithHost
 {
-    private String host;
-
-    private int port;
-
     private String path;
 
     // ----------------------------------------------------------------------
@@ -41,9 +37,9 @@
 
         setPassword( password );
 
-        this.host = host;
+        setHost( host );
 
-        this.port = port;
+        setPort( port );
 
         if ( !path.startsWith( "/" ) )
         {
@@ -55,7 +51,7 @@
 
     public String getUrl()
     {
-        return host + ":" + port + path;
+        return getHost() + ":" + getPort() + path;
     }
 
     public String getFullUrl()
@@ -73,26 +69,10 @@
     }
 
     /**
-     * @return Returns the host.
-     */
-    public String getHost()
-    {
-        return host;
-    }
-
-    /**
      * @return Returns the path.
      */
     public String getPath()
     {
         return path;
-    }
-
-    /**
-     * @return Returns the port.
-     */
-    public int getPort()
-    {
-        return port;
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java?rev=374533&r1=374532&r2=374533&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
Thu Feb  2 14:37:33 2006
@@ -16,14 +16,14 @@
  * limitations under the License.
  */
 
-import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
  */
 public class SvnScmProviderRepository
-    extends ScmProviderRepository
+    extends ScmProviderRepositoryWithHost
 {
     /** */
     private String url;
@@ -103,11 +103,29 @@
         {
             setUser( urlPath.substring( 0, indexAt ) );
 
-            this.url = protocol + urlPath.substring( indexAt + 1 );
+            urlPath = urlPath.substring( indexAt + 1 );
+
+            this.url = protocol + urlPath;
         }
         else
         {
             this.url = protocol + urlPath;
+        }
+
+        if ( !"file://".equals( protocol ) )
+        {
+            int indexSlash = urlPath.indexOf( "/" );
+            if ( indexSlash > 0 )
+            {
+                String hostPort = urlPath.substring( 0, indexSlash );
+                int indexColon = hostPort.indexOf( ":" );
+
+                if ( indexColon > 0 )
+                {
+                    setHost( hostPort.substring( 0, indexColon ) );
+                    setPort( Integer.parseInt( hostPort.substring( indexColon ) ) );
+                }
+            }
         }
     }
 }



Mime
View raw message