Coverage Report - org.apache.maven.scm.provider.cvslib.command.add.AbstractCvsAddCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractCvsAddCommand
0 %
0/18
0 %
0/10
3,5
 
 1  
 package org.apache.maven.scm.provider.cvslib.command.add;
 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 org.apache.maven.scm.ScmException;
 23  
 import org.apache.maven.scm.ScmFile;
 24  
 import org.apache.maven.scm.ScmFileSet;
 25  
 import org.apache.maven.scm.ScmFileStatus;
 26  
 import org.apache.maven.scm.ScmResult;
 27  
 import org.apache.maven.scm.command.add.AbstractAddCommand;
 28  
 import org.apache.maven.scm.command.add.AddScmResult;
 29  
 import org.apache.maven.scm.provider.ScmProviderRepository;
 30  
 import org.apache.maven.scm.provider.cvslib.command.CvsCommand;
 31  
 import org.apache.maven.scm.provider.cvslib.command.CvsCommandUtils;
 32  
 import org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository;
 33  
 import org.codehaus.plexus.util.cli.Commandline;
 34  
 
 35  
 import java.io.File;
 36  
 import java.util.ArrayList;
 37  
 import java.util.List;
 38  
 
 39  
 /**
 40  
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
 41  
  * @version $Id: AbstractCvsAddCommand.java 1054126 2010-12-31 15:18:11Z olamy $
 42  
  * @todo separate the CVSlib stuff from the cvs command line so it is clear what needs to be updated eventually
 43  
  */
 44  0
 public abstract class AbstractCvsAddCommand
 45  
     extends AbstractAddCommand
 46  
     implements CvsCommand
 47  
 {
 48  
     /** {@inheritDoc} */
 49  
     protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message,
 50  
                                            boolean binary )
 51  
         throws ScmException
 52  
     {
 53  0
         CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
 54  
 
 55  0
         Commandline cl = CvsCommandUtils.getBaseCommand( "add", repository, fileSet );
 56  
 
 57  0
         if ( binary )
 58  
         {
 59  0
             cl.createArg().setValue( "-kb" );
 60  
         }
 61  
 
 62  0
         if ( message != null && message.length() > 0 )
 63  
         {
 64  0
             cl.createArg().setValue( "-m" );
 65  
 
 66  0
             cl.createArg().setValue( "\"" + message + "\"" );
 67  
         }
 68  
 
 69  
 
 70  0
         List<ScmFile> addedFiles = new ArrayList<ScmFile>( fileSet.getFileList().size() );
 71  
 
 72  0
         for ( File file : fileSet.getFileList() )
 73  
         {
 74  0
             String path = file.getPath().replace( '\\', '/' );
 75  
 
 76  0
             cl.createArg().setValue( path );
 77  
 
 78  0
             addedFiles.add( new ScmFile( path, ScmFileStatus.ADDED ) );
 79  0
         }
 80  
 
 81  0
         if ( getLogger().isInfoEnabled() )
 82  
         {
 83  0
             getLogger().info( "Executing: " + cl );
 84  0
             getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
 85  
         }
 86  
 
 87  0
         return executeCvsCommand( cl, addedFiles );
 88  
     }
 89  
 
 90  
     protected abstract AddScmResult executeCvsCommand( Commandline cl, List<ScmFile> addedFiles )
 91  
         throws ScmException;
 92  
 }