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

Cliff Evans commented on SCM-269:
---------------------------------

To make this work the Repo path in the Clientspec needs to be quoted.  Changing 
the createClientspec method in the 
org/apache/maven/scm/provider/perforce/PerforceScmProvider.java file to that 
shown below fixes the issue.  (I've changed the style of the section I changed 
to make it standout more.)

{noformat}
    /*
     * Clientspec name can be overridden with the system property below.  I 
don't
     * know of any way for this code to get access to maven's settings.xml so 
this
     * is the best I can do.
     *
     * Sample clientspec:

     Client: mperham-mikeperham-dt-maven
     Root: d:\temp\target
     Owner: mperham
     View:
     //depot/sandbox/mperham/tsa/tsa-domain/... 
//mperham-mikeperham-dt-maven/...
     Description:
     Created by maven-scm-provider-perforce

     */
    public static String createClientspec( ScmLogger logger, 
PerforceScmProviderRepository repo, File workDir,
                                           String repoPath )
    {
        String clientspecName = getClientspecName( logger, repo, workDir );
        String userName = getUsername( logger, repo );

        String rootDir;
        try
        {
            // SCM-184
            rootDir = workDir.getCanonicalPath();
        }
        catch ( IOException ex )
        {
            //getLogger().error("Error getting canonical path for working 
directory: " + workDir, ex);
            rootDir = workDir.getAbsolutePath();
        }

        StringBuffer buf = new StringBuffer();
        buf.append( "Client: " ).append( clientspecName ).append( NEWLINE );
        buf.append( "Root: " ).append( rootDir ).append( NEWLINE );
        buf.append( "Owner: " ).append( userName ).append( NEWLINE );
        // SCM-269
        buf.append( "View:" ).append( NEWLINE )
           .append( "\t\"" ).append( PerforceScmProvider.getCanonicalRepoPath( 
repoPath ) )
           .append( "\" //" ).append( clientspecName ).append( "/..." ).append( 
NEWLINE );
        buf.append( "Description:" ).append( NEWLINE );
        buf.append( "\t" ).append( "Created by maven-scm-provider-perforce" 
).append( NEWLINE );
        return buf.toString();
    }
{noformat}

A unit test for it might look something like:

{noformat}
    public void testCreateClientSpec ()
        throws
            Exception
    {
        File workDir = new File ( "/work/directory" );
        ScmRepository repo = makeScmRepository( 
"scm:perforce:host://depot/projects/path name" );
        PerforceScmProviderRepository p4Repo = (PerforceScmProviderRepository) 
repo.getProviderRepository();
        String cs = createClientspec ( null, p4Repo, workDir, 
"//depot/projects/path name" );
        
        assertTrue( cs.contains ( "\"//depot/projects/path name/...\"" );
    }
{noformat}

but I haven't tested this since I don't have access to the SVN repo other than 
through a browser.  Paranoid SAs.

Regards,

Cliff

> Perforce support doesn't work when there's a space in the local path
> --------------------------------------------------------------------
>
>                 Key: SCM-269
>                 URL: http://jira.codehaus.org/browse/SCM-269
>             Project: Maven SCM
>          Issue Type: Bug
>          Components: maven-scm-provider-perforce
>    Affects Versions: 1.0-beta-4
>            Reporter: David Jackman
>            Assignee: Mike Perham
>             Fix For: future
>
>
> Create a view of a Maven project in Perforce in a local directory whose path 
> contains a space.  Perform some SCM goal (I was trying to scm:update).  It 
> won't work.  The error message is very cryptic ("Unable to sync.  Are you 
> logged in?").  From the looks of it, the client command (which is run just 
> before the sync command) has problems, but these problems aren't reported.  I 
> think the main problem is the fact that the local path is used in the client 
> name, and client names can't contain spaces.  Other elements of the client 
> (root and view) also will contain spaces, but I don't know if Perforce has a 
> problem with these.

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