maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r528496 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-hg: maven-scm-provider-hg.iml src/main/java/org/apache/maven/scm/provider/hg/HgScmProvider.java
Date Fri, 13 Apr 2007 14:25:34 GMT
Author: evenisse
Date: Fri Apr 13 07:25:34 2007
New Revision: 528496

URL: http://svn.apache.org/viewvc?view=rev&rev=528496
Log:
[SCM-230] little fixes
1. Allow file/http/https URLs for checkout
2. Fix bug where checkout would only work while inside an existing repository
3. IntelliJ IDEA project file was accidently checked in.
Submitted by: Ryan Daum

Removed:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-hg/maven-scm-provider-hg.iml
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgScmProvider.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgScmProvider.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgScmProvider.java?view=diff&rev=528496&r1=528495&r2=528496
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgScmProvider.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgScmProvider.java
Fri Apr 13 07:25:34 2007
@@ -66,10 +66,80 @@
         return ".hg";
     }
 
+    private static class HgUrlParserResult
+    {
+        List messages = new ArrayList();
+
+        ScmProviderRepository repository;
+    }
+
+
     public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter
)
-        throws ScmRepositoryException
+            throws ScmRepositoryException
+        {
+            HgUrlParserResult result = parseScmUrl( scmSpecificUrl );
+
+            if ( result.messages.size() > 0 )
+            {
+                throw new ScmRepositoryException( "The scm url is invalid.", result.messages
);
+            }
+
+            return result.repository;
+        }
+
+
+    private HgUrlParserResult parseScmUrl( String scmSpecificUrl )
     {
-        return new HgScmProviderRepository( scmSpecificUrl );
+        HgUrlParserResult result = new HgUrlParserResult();
+
+        String url = scmSpecificUrl;
+
+        // ----------------------------------------------------------------------
+        // Do some sanity checking of the SVN url
+        // ----------------------------------------------------------------------
+
+        if ( url.startsWith( "file" ) )
+        {
+            if ( !url.startsWith( "file:///" ) && !url.startsWith( "file://localhost/"
) )
+            {
+                result.messages.add( "An hg 'file' url must be on the form 'file:///' or
'file://localhost/'." );
+
+                return result;
+            }
+        }
+        else if ( url.startsWith( "https" ) )
+        {
+            if ( !url.startsWith( "https://" ) )
+            {
+                result.messages.add( "An hg 'http' url must be on the form 'https://'." );
+
+                return result;
+            }
+        }
+        else if ( url.startsWith( "http" ) )
+        {
+            if ( !url.startsWith( "http://" ) )
+            {
+                result.messages.add( "An hg 'http' url must be on the form 'http://'." );
+
+                return result;
+            }
+        } else {
+            try {
+
+                File file = new File(url);
+
+            } catch (Throwable e) {
+                result.messages.add( "The filename provided is not valid" );
+
+                return result;
+            }
+
+        }
+
+        result.repository = new HgScmProviderRepository( url );
+
+        return result;
     }
 
     /**
@@ -93,29 +163,19 @@
         return makeProviderScmRepository( path.getAbsolutePath(), ':' );
     }
 
+    
+    /**
+     * Validate the scm url.
+     *
+     * @param scmSpecificUrl The SCM url
+     * @param delimiter      The delimiter used in the SCM url
+     * @return Returns a list of messages if the validation failed
+     */ 
     public List validateScmUrl( String scmSpecificUrl, char delimiter )
     {
+        HgUrlParserResult result = parseScmUrl( scmSpecificUrl );
 
-        List errorMessages = new ArrayList();
-
-        String[] checkCmd = new String[]{HgCommand.CHECK, scmSpecificUrl};
-        ScmResult result;
-        try
-        {
-            File tmpDir = new File( System.getProperty( "java.io.tmpdir" ) );
-            result = HgUtils.execute( tmpDir, checkCmd );
-            if ( !result.isSuccess() )
-            {
-                errorMessages.add( result.getCommandOutput() );
-                errorMessages.add( result.getProviderMessage() );
-            }
-        }
-        catch ( ScmException e )
-        {
-            errorMessages.add( e.getMessage() );
-        }
-
-        return errorMessages;
+        return result.messages;
     }
 
     public String getScmType()



Mime
View raw message