Coverage Report - org.apache.maven.scm.provider.bazaar.command.changelog.BazaarChangeLogCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
BazaarChangeLogCommand
0 %
0/14
0 %
0/12
7
 
 1  
 package org.apache.maven.scm.provider.bazaar.command.changelog;
 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.util.ArrayList;
 23  
 import java.util.Date;
 24  
 import java.util.List;
 25  
 
 26  
 import org.apache.maven.scm.ChangeSet;
 27  
 import org.apache.maven.scm.ScmBranch;
 28  
 import org.apache.maven.scm.ScmException;
 29  
 import org.apache.maven.scm.ScmFileSet;
 30  
 import org.apache.maven.scm.ScmResult;
 31  
 import org.apache.maven.scm.command.Command;
 32  
 import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand;
 33  
 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
 34  
 import org.apache.maven.scm.command.changelog.ChangeLogSet;
 35  
 import org.apache.maven.scm.provider.ScmProviderRepository;
 36  
 import org.apache.maven.scm.provider.bazaar.BazaarUtils;
 37  
 import org.apache.maven.scm.provider.bazaar.command.BazaarConstants;
 38  
 
 39  
 /**
 40  
  * @author <a href="mailto:torbjorn@smorgrav.org">Torbjorn Eikli Smorgrav</a>
 41  
  * @author Olivier Lamy
 42  
  * @version $Id: BazaarChangeLogCommand.java 1054408 2011-01-02 14:05:25Z olamy $
 43  
  */
 44  0
 public class BazaarChangeLogCommand
 45  
     extends AbstractChangeLogCommand
 46  
     implements Command
 47  
 {
 48  
     /** {@inheritDoc} */
 49  
     protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet,
 50  
                                                           Date startDate, Date endDate, ScmBranch branch,
 51  
                                                           String datePattern )
 52  
         throws ScmException
 53  
     {
 54  0
         String[] cmd = new String[]{BazaarConstants.LOG_CMD, BazaarConstants.VERBOSE_OPTION};
 55  0
         BazaarChangeLogConsumer consumer = new BazaarChangeLogConsumer( getLogger(), datePattern );
 56  0
         ScmResult result = BazaarUtils.execute( consumer, getLogger(), fileSet.getBasedir(), cmd );
 57  
 
 58  0
         List<ChangeSet> logEntries = consumer.getModifications();
 59  0
         List<ChangeSet> inRangeAndValid = new ArrayList<ChangeSet>();
 60  0
         startDate = startDate == null ? new Date( 0 ) : startDate; //From 1. Jan 1970
 61  0
         endDate = endDate == null ? new Date() : endDate; //Upto now
 62  
 
 63  0
         for ( ChangeSet change : logEntries )
 64  
         {
 65  0
             if ( change.getFiles().size() > 0 )
 66  
             {
 67  0
                 if ( !change.getDate().before( startDate ) && !change.getDate().after( endDate ) )
 68  
                 {
 69  0
                     inRangeAndValid.add( change );
 70  
                 }
 71  
             }
 72  
         }
 73  
 
 74  0
         ChangeLogSet changeLogSet = new ChangeLogSet( inRangeAndValid, startDate, endDate );
 75  0
         return new ChangeLogScmResult( changeLogSet, result );
 76  
     }
 77  
 }