You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Dennis Lundberg (JIRA)" <ji...@codehaus.org> on 2008/07/27 20:48:26 UTC

[jira] Commented: (SCM-391) urls without subfolders were not parsed correctly.

    [ http://jira.codehaus.org/browse/SCM-391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=143257#action_143257 ] 

Dennis Lundberg commented on SCM-391:
-------------------------------------

What URL do you expect SCM to use?

> urls without subfolders were not parsed correctly.
> --------------------------------------------------
>
>                 Key: SCM-391
>                 URL: http://jira.codehaus.org/browse/SCM-391
>             Project: Maven SCM
>          Issue Type: Bug
>          Components: maven-scm-provider-mercurial (hg)
>            Reporter: Stefan Ackermann
>
> Following configuration within pom.xml failed to do checkins:
> {code:xml}
> <scm>
>   <connection>scm:hg:file:///${basedir}</connection>
>   <developerConnection>scm:hg:http://localhost:8000/</developerConnection>
> </scm>
> {code}
> The error is that it is trying to push to a wrong location.
> [INFO] EXECUTING: hg push http://localhost8000/
> I have traced it down to this function of this file:
> http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java?revision=528416&view=markup
> Here is a proposal from me on how to fix that.
> {code}
>     private String parseHostAndPort( String url )
>     {
>         if ( protocol != FILE )
>         {
>             String[] split = url.split( ":" );
>             if ( split.length == 2 )
>             {
>                 setHost( split[0] );
>                 url = url.substring( split[0].length() + 1 );
>                 split = split[1].split( "/" );
>                 if ( split.length == 2 )
>                 {
>                     url = url.substring( split[0].length() );
>                     try
>                     {
>                         setPort( Integer.valueOf( split[0] ).intValue() );
>                     }
>                     catch ( NumberFormatException e )
>                     {
>                         //Ignore - error will manifest itself later.
>                     }
>                 }
>                 else if (url.matches("\\d+/?"))
>                 {
>                 	url = url.replaceAll("/", "");
>                 	try {
> 						setPort(Integer.valueOf(url));
> 					} catch (NumberFormatException e) {
>                         //Ignore - error will manifest itself later.
> 					}
>                 }
>             }
>             else
>             {
>                 split = url.split( "/" );
>                 if ( split.length > 1 )
>                 {
>                     url = url.substring( split[0].length() );
>                     setHost( split[0] );
>                 }
>                 else if (url.matches("[^/]+/?"))
>                 {
>                 	url = url.replaceAll("/", "");
>                 	setHost(url);
>                 }
>             }
>         }
>         return url;
>     }
> {code}
> I have not run any unit tests, but I did run some tests against this function with some input strings. Seems to work.
> A URL like this is default if you just use hg serve so it is kind of common.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira