[ 
https://issues.apache.org/jira/browse/SCM-269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17959866#comment-17959866
 ] 

ASF GitHub Bot commented on SCM-269:
------------------------------------

jira-importer commented on issue #260:
URL: https://github.com/apache/maven-scm/issues/260#issuecomment-2964581655

   **[Cliff 
Evans](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mipper)** 
commented
   
   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.)
   
   ```
       /*
        * 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();
       }
   ```
   
   A unit test for it might look something like:
   
   ```
   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/...\"" );
   }
   ```
   
   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: https://issues.apache.org/jira/browse/SCM-269
>             Project: Maven SCM (Moved to GitHub Issues)
>          Issue Type: Bug
>          Components: maven-scm-provider-perforce
>    Affects Versions: 1.0-beta-4
>            Reporter: David Jackman
>            Assignee: Mike Perham
>            Priority: Major
>
> 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 was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to