Uploaded image for project: 'Maven SCM'
  1. Maven SCM
  2. SCM-391

urls without subfolders were not parsed correctly.

    XMLWordPrintableJSON

Details

    • Patch

    Description

      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.

      Attachments

        Activity

          People

            siveton Siveton Vincent
            stivo Stefan Ackermann
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: