View Javadoc

1   package org.apache.maven.scm.provider.accurev.command.tag;
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.List;
24  
25  import org.apache.maven.scm.CommandParameter;
26  import org.apache.maven.scm.CommandParameters;
27  import org.apache.maven.scm.ScmException;
28  import org.apache.maven.scm.ScmFileSet;
29  import org.apache.maven.scm.ScmFileStatus;
30  import org.apache.maven.scm.ScmResult;
31  import org.apache.maven.scm.command.tag.TagScmResult;
32  import org.apache.maven.scm.log.ScmLogger;
33  import org.apache.maven.scm.provider.ScmProviderRepository;
34  import org.apache.maven.scm.provider.accurev.AccuRev;
35  import org.apache.maven.scm.provider.accurev.AccuRevException;
36  import org.apache.maven.scm.provider.accurev.AccuRevInfo;
37  import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
38  import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommand;
39  
40  public class AccuRevTagCommand
41      extends AbstractAccuRevCommand
42  {
43  
44      public AccuRevTagCommand( ScmLogger logger )
45      {
46          super( logger );
47      }
48  
49      @Override
50      protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
51                                                 CommandParameters parameters )
52          throws ScmException, AccuRevException
53      {
54  
55          AccuRev accuRev = repository.getAccuRev();
56  
57          String snapshotName = parameters.getString( CommandParameter.TAG_NAME );
58  
59          snapshotName = repository.getSnapshotName( snapshotName );
60  
61          File basedir = fileSet.getBasedir();
62          boolean success = true;
63  
64          AccuRevInfo info = accuRev.info( basedir );
65          List<File> taggedFiles = null;
66  
67          success = accuRev.mksnap( snapshotName, info.getBasis() );
68          if ( success )
69          {
70              taggedFiles = accuRev.statTag( snapshotName );
71          }
72  
73          if ( success && taggedFiles != null )
74          {
75              return new TagScmResult( accuRev.getCommandLines(), getScmFiles( taggedFiles, ScmFileStatus.TAGGED ) );
76          }
77          else
78          {
79              return new TagScmResult( accuRev.getCommandLines(), "AccuRev error", accuRev.getErrorOutput(), false );
80          }
81      }
82  
83      public TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
84          throws ScmException
85      {
86          return (TagScmResult) execute( repository, fileSet, parameters );
87      }
88  
89  }