Coverage Report - org.apache.maven.scm.provider.cvslib.command.list.AbstractCvsListCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractCvsListCommand
0 %
0/21
0 %
0/12
4
 
 1  
 package org.apache.maven.scm.provider.cvslib.command.list;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  * http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.io.File;
 23  
 import java.util.Iterator;
 24  
 
 25  
 import org.apache.maven.scm.ScmException;
 26  
 import org.apache.maven.scm.ScmFileSet;
 27  
 import org.apache.maven.scm.ScmVersion;
 28  
 import org.apache.maven.scm.command.list.AbstractListCommand;
 29  
 import org.apache.maven.scm.command.list.ListScmResult;
 30  
 import org.apache.maven.scm.provider.ScmProviderRepository;
 31  
 import org.apache.maven.scm.provider.cvslib.command.CvsCommand;
 32  
 import org.apache.maven.scm.provider.cvslib.command.CvsCommandUtils;
 33  
 import org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository;
 34  
 import org.codehaus.plexus.util.StringUtils;
 35  
 import org.codehaus.plexus.util.cli.Commandline;
 36  
 
 37  
 /**
 38  
  * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
 39  
  * @version $Id: AbstractCvsListCommand.java 1055646 2011-01-05 21:22:58Z olamy $
 40  
  */
 41  0
 public abstract class AbstractCvsListCommand
 42  
     extends AbstractListCommand
 43  
     implements CvsCommand
 44  
 {
 45  
     /** {@inheritDoc} */
 46  
     protected ListScmResult executeListCommand( ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive,
 47  
                                                 ScmVersion version )
 48  
         throws ScmException
 49  
     {
 50  0
         CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
 51  
 
 52  0
         Commandline cl = CvsCommandUtils.getBaseCommand( "rls", repository, fileSet, "-n" );
 53  
 
 54  0
         if ( version != null && !StringUtils.isEmpty( version.getName() ) )
 55  
         {
 56  0
             cl.createArg().setValue( "-r" );
 57  0
             cl.createArg().setValue( version.getName() );
 58  
         }
 59  
 
 60  0
         cl.createArg().setValue( "-d" );
 61  0
         cl.createArg().setValue( "-e" ); // szakusov: to fix "Unknown file status" problem
 62  
 
 63  0
         if ( recursive )
 64  
         {
 65  0
             cl.createArg().setValue( "-R" );
 66  
         }
 67  
 
 68  0
         for ( Iterator<File> it = fileSet.getFileList().iterator(); it.hasNext(); )
 69  
         {
 70  0
             File target = (File) it.next();
 71  0
             String path = target.getPath();
 72  0
             if ( path.startsWith( "\\" ) )
 73  
             {
 74  0
                 path = path.substring( 1 );
 75  
             }
 76  0
             cl.createArg().setValue( path );
 77  0
         }
 78  
 
 79  0
         if ( getLogger().isInfoEnabled() )
 80  
         {
 81  0
             getLogger().info( "Executing: " + cl );
 82  0
             getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
 83  
         }
 84  
 
 85  0
         return executeCvsCommand( cl );
 86  
     }
 87  
 
 88  
     protected abstract ListScmResult executeCvsCommand( Commandline cl )
 89  
         throws ScmException;
 90  
 }