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:
        <scm>
                <connection>scm:hg:file:///${basedir}</connection>
                
<developerConnection>scm:hg:http://localhost:8000/</developerConnection>
        </scm>

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.

    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;
    }

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

        

Reply via email to