Coverage Report - org.apache.maven.scm.provider.bazaar.BazaarScmProvider
 
Classes in this File Line Coverage Branch Coverage Complexity
BazaarScmProvider
0 %
0/51
0 %
0/8
1,467
 
 1  
 package org.apache.maven.scm.provider.bazaar;
 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.CommandParameters;
 23  
 import org.apache.maven.scm.ScmException;
 24  
 import org.apache.maven.scm.ScmFileSet;
 25  
 import org.apache.maven.scm.ScmResult;
 26  
 import org.apache.maven.scm.command.add.AddScmResult;
 27  
 import org.apache.maven.scm.command.blame.BlameScmResult;
 28  
 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
 29  
 import org.apache.maven.scm.command.checkin.CheckInScmResult;
 30  
 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
 31  
 import org.apache.maven.scm.command.diff.DiffScmResult;
 32  
 import org.apache.maven.scm.command.remove.RemoveScmResult;
 33  
 import org.apache.maven.scm.command.status.StatusScmResult;
 34  
 import org.apache.maven.scm.command.tag.TagScmResult;
 35  
 import org.apache.maven.scm.command.update.UpdateScmResult;
 36  
 import org.apache.maven.scm.provider.AbstractScmProvider;
 37  
 import org.apache.maven.scm.provider.ScmProviderRepository;
 38  
 import org.apache.maven.scm.provider.bazaar.command.BazaarConstants;
 39  
 import org.apache.maven.scm.provider.bazaar.command.add.BazaarAddCommand;
 40  
 import org.apache.maven.scm.provider.bazaar.command.blame.BazaarBlameCommand;
 41  
 import org.apache.maven.scm.provider.bazaar.command.changelog.BazaarChangeLogCommand;
 42  
 import org.apache.maven.scm.provider.bazaar.command.checkin.BazaarCheckInCommand;
 43  
 import org.apache.maven.scm.provider.bazaar.command.checkout.BazaarCheckOutCommand;
 44  
 import org.apache.maven.scm.provider.bazaar.command.diff.BazaarDiffCommand;
 45  
 import org.apache.maven.scm.provider.bazaar.command.remove.BazaarRemoveCommand;
 46  
 import org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand;
 47  
 import org.apache.maven.scm.provider.bazaar.command.tag.BazaarTagCommand;
 48  
 import org.apache.maven.scm.provider.bazaar.command.update.BazaarUpdateCommand;
 49  
 import org.apache.maven.scm.provider.bazaar.repository.BazaarScmProviderRepository;
 50  
 import org.apache.maven.scm.repository.ScmRepositoryException;
 51  
 import org.apache.maven.scm.repository.UnknownRepositoryStructure;
 52  
 
 53  
 import java.io.File;
 54  
 import java.util.ArrayList;
 55  
 import java.util.List;
 56  
 
 57  
 /**
 58  
  * Bazaar NG http://bazaar-vcs.org/ is a decentralized revision control system. <br>
 59  
  *
 60  
  * @author <a href="mailto:torbjorn@smorgrav.org">Torbj�rn Eikli Sm�rgrav</a>
 61  
  * @version $Id: BazaarScmProvider.java 1056992 2011-01-09 18:09:41Z olamy $
 62  
  * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="bazaar"
 63  
  */
 64  0
 public class BazaarScmProvider
 65  
     extends AbstractScmProvider
 66  
 {
 67  
     /** {@inheritDoc} */
 68  
     public String getScmSpecificFilename()
 69  
     {
 70  0
         return ".bzr";
 71  
     }
 72  
 
 73  
     /** {@inheritDoc} */
 74  
     public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter )
 75  
         throws ScmRepositoryException
 76  
     {
 77  0
         return new BazaarScmProviderRepository( scmSpecificUrl );
 78  
     }
 79  
 
 80  
     /** {@inheritDoc} */
 81  
     public ScmProviderRepository makeProviderScmRepository( File path )
 82  
         throws ScmRepositoryException, UnknownRepositoryStructure
 83  
     {
 84  0
         if ( path == null || !path.isDirectory() )
 85  
         {
 86  0
             throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a valid directory." );
 87  
         }
 88  
 
 89  0
         File bzrDir = new File( path, ".bzr" );
 90  
 
 91  0
         if ( !bzrDir.exists() )
 92  
         {
 93  0
             throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a bazaar directory." );
 94  
         }
 95  
 
 96  0
         return makeProviderScmRepository( "file:///" + path.getAbsolutePath(), ':' );
 97  
     }
 98  
 
 99  
     /** {@inheritDoc} */
 100  
     public List<String> validateScmUrl( String scmSpecificUrl, char delimiter )
 101  
     {
 102  
 
 103  0
         List<String> errorMessages = new ArrayList<String>();
 104  
 
 105  0
         String[] checkCmd = new String[]{BazaarConstants.CHECK, scmSpecificUrl};
 106  
         ScmResult result;
 107  
         try
 108  
         {
 109  0
             File tmpDir = new File( System.getProperty( "java.io.tmpdir" ) );
 110  0
             result = BazaarUtils.execute( tmpDir, checkCmd );
 111  0
             if ( !result.isSuccess() )
 112  
             {
 113  0
                 errorMessages.add( result.getCommandOutput() );
 114  0
                 errorMessages.add( result.getProviderMessage() );
 115  
             }
 116  
         }
 117  0
         catch ( ScmException e )
 118  
         {
 119  0
             errorMessages.add( e.getMessage() );
 120  0
         }
 121  
 
 122  0
         return errorMessages;
 123  
     }
 124  
 
 125  
     /** {@inheritDoc} */
 126  
     public String getScmType()
 127  
     {
 128  0
         return "bazaar";
 129  
     }
 130  
 
 131  
     /** {@inheritDoc} */
 132  
     public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
 133  
         throws ScmException
 134  
     {
 135  0
         BazaarAddCommand command = new BazaarAddCommand();
 136  
 
 137  0
         command.setLogger( getLogger() );
 138  
 
 139  0
         return (AddScmResult) command.execute( repository, fileSet, parameters );
 140  
     }
 141  
 
 142  
     /** {@inheritDoc} */
 143  
     public ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet,
 144  
                                          CommandParameters parameters )
 145  
         throws ScmException
 146  
     {
 147  0
         BazaarChangeLogCommand command = new BazaarChangeLogCommand();
 148  
 
 149  0
         command.setLogger( getLogger() );
 150  
 
 151  0
         return (ChangeLogScmResult) command.execute( repository, fileSet, parameters );
 152  
     }
 153  
 
 154  
     /** {@inheritDoc} */
 155  
     public CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet,
 156  
                                      CommandParameters parameters )
 157  
         throws ScmException
 158  
     {
 159  0
         BazaarCheckInCommand command = new BazaarCheckInCommand();
 160  
 
 161  0
         command.setLogger( getLogger() );
 162  
 
 163  0
         return (CheckInScmResult) command.execute( repository, fileSet, parameters );
 164  
     }
 165  
 
 166  
     /** {@inheritDoc} */
 167  
     public CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet,
 168  
                                        CommandParameters parameters )
 169  
         throws ScmException
 170  
     {
 171  0
         BazaarCheckOutCommand command = new BazaarCheckOutCommand();
 172  
 
 173  0
         command.setLogger( getLogger() );
 174  
 
 175  0
         return (CheckOutScmResult) command.execute( repository, fileSet, parameters );
 176  
     }
 177  
 
 178  
     /** {@inheritDoc} */
 179  
     public DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
 180  
         throws ScmException
 181  
     {
 182  0
         BazaarDiffCommand command = new BazaarDiffCommand();
 183  
 
 184  0
         command.setLogger( getLogger() );
 185  
 
 186  0
         return (DiffScmResult) command.execute( repository, fileSet, parameters );
 187  
     }
 188  
 
 189  
     /** {@inheritDoc} */
 190  
     public RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
 191  
         throws ScmException
 192  
     {
 193  0
         BazaarRemoveCommand command = new BazaarRemoveCommand();
 194  
 
 195  0
         command.setLogger( getLogger() );
 196  
 
 197  0
         return (RemoveScmResult) command.execute( repository, fileSet, parameters );
 198  
     }
 199  
 
 200  
     /** {@inheritDoc} */
 201  
     public StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
 202  
         throws ScmException
 203  
     {
 204  0
         BazaarStatusCommand command = new BazaarStatusCommand();
 205  
 
 206  0
         command.setLogger( getLogger() );
 207  
 
 208  0
         return (StatusScmResult) command.execute( repository, fileSet, parameters );
 209  
     }
 210  
 
 211  
     /** {@inheritDoc} */
 212  
     public TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
 213  
         throws ScmException
 214  
     {
 215  0
         BazaarTagCommand command = new BazaarTagCommand();
 216  
 
 217  0
         command.setLogger( getLogger() );
 218  
 
 219  0
         return (TagScmResult) command.execute( repository, fileSet, parameters );
 220  
     }
 221  
 
 222  
     /** {@inheritDoc} */
 223  
     public UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
 224  
         throws ScmException
 225  
     {
 226  0
         BazaarUpdateCommand command = new BazaarUpdateCommand();
 227  
 
 228  0
         command.setLogger( getLogger() );
 229  
 
 230  0
         return (UpdateScmResult) command.execute( repository, fileSet, parameters );
 231  
     }
 232  
 
 233  
     /** {@inheritDoc} */
 234  
     protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
 235  
         throws ScmException
 236  
     {
 237  0
         BazaarBlameCommand command = new BazaarBlameCommand();
 238  
 
 239  0
         command.setLogger( getLogger() );
 240  
 
 241  0
         return (BlameScmResult) command.execute( repository, fileSet, parameters );
 242  
     }
 243  
 }