1 package org.apache.maven.scm.command.branch;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.scm.CommandParameter;
23 import org.apache.maven.scm.CommandParameters;
24 import org.apache.maven.scm.ScmBranchParameters;
25 import org.apache.maven.scm.ScmException;
26 import org.apache.maven.scm.ScmFileSet;
27 import org.apache.maven.scm.ScmResult;
28 import org.apache.maven.scm.command.AbstractCommand;
29 import org.apache.maven.scm.provider.ScmProviderRepository;
30 import org.codehaus.plexus.util.StringUtils;
31
32
33
34
35
36
37 public abstract class AbstractBranchCommand
38 extends AbstractCommand
39 {
40 protected abstract ScmResult executeBranchCommand( ScmProviderRepository repository, ScmFileSet fileSet,
41 String branchName, String message )
42 throws ScmException;
43
44
45
46
47
48
49
50
51
52
53
54 protected ScmResult executeBranchCommand( ScmProviderRepository repository, ScmFileSet fileSet, String branchName,
55 ScmBranchParameters scmBranchParameters )
56 throws ScmException
57 {
58 return executeBranchCommand( repository, fileSet, branchName, scmBranchParameters.getMessage() );
59 }
60
61
62 public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet,
63 CommandParameters parameters )
64 throws ScmException
65 {
66 String branchName = parameters.getString( CommandParameter.BRANCH_NAME );
67
68 ScmBranchParameters scmBranchParameters =
69 parameters.getScmBranchParameters( CommandParameter.SCM_BRANCH_PARAMETERS );
70
71 String message = parameters.getString( CommandParameter.MESSAGE, "[maven-scm] copy for branch " + branchName );
72
73 if ( StringUtils.isBlank( scmBranchParameters.getMessage() ) && StringUtils.isNotBlank( message ) )
74 {
75 scmBranchParameters.setMessage( message );
76 }
77
78 return executeBranchCommand( repository, fileSet, branchName, scmBranchParameters );
79 }
80 }