1 package org.apache.maven.scm.provider.vss.commands.status;
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.ScmException;
23 import org.apache.maven.scm.ScmFileSet;
24 import org.apache.maven.scm.command.changelog.ChangeLogCommand;
25 import org.apache.maven.scm.command.status.AbstractStatusCommand;
26 import org.apache.maven.scm.command.status.StatusScmResult;
27 import org.apache.maven.scm.provider.ScmProviderRepository;
28 import org.apache.maven.scm.provider.vss.commands.VssCommandLineUtils;
29 import org.apache.maven.scm.provider.vss.commands.VssConstants;
30 import org.apache.maven.scm.provider.vss.commands.changelog.VssHistoryCommand;
31 import org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository;
32 import org.codehaus.plexus.util.cli.CommandLineUtils;
33 import org.codehaus.plexus.util.cli.Commandline;
34
35
36
37
38
39 public class VssStatusCommand
40 extends AbstractStatusCommand
41 {
42 protected StatusScmResult executeStatusCommand( ScmProviderRepository repository, ScmFileSet fileSet )
43 throws ScmException
44 {
45 getLogger().debug( "executing status command..." );
46
47 VssScmProviderRepository repo = (VssScmProviderRepository) repository;
48
49 Commandline cl = buildCmdLine( repo, fileSet );
50
51 VssStatusConsumer consumer = new VssStatusConsumer( repo, getLogger(), fileSet );
52
53 CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
54
55 int exitCode;
56
57 getLogger().debug( "Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString() );
58
59 exitCode = VssCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() );
60
61 if ( exitCode != 0 )
62 {
63 String error = stderr.getOutput();
64 getLogger().debug( "VSS returns error: [" + error + "] return code: [" + exitCode + "]" );
65 if ( false )
66 {
67 return new StatusScmResult( cl.toString(), "The vss command failed.", error, false );
68 }
69
70
71 }
72
73 return new StatusScmResult( cl.toString(), consumer.getUpdatedFiles() );
74 }
75
76 public Commandline buildCmdLine( VssScmProviderRepository repo, ScmFileSet fileSet )
77 throws ScmException
78 {
79
80 Commandline command = new Commandline();
81
82 command.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
83
84 try
85 {
86 command.addSystemEnvironment();
87 }
88 catch ( Exception e )
89 {
90 throw new ScmException( "Can't add system environment.", e );
91 }
92
93 command.addEnvironment( "SSDIR", repo.getVssdir() );
94
95 String ssDir = VssCommandLineUtils.getSsDir();
96
97 command.setExecutable( ssDir + VssConstants.SS_EXE );
98
99 command.createArgument().setValue( VssConstants.COMMAND_DIFF );
100
101 command.createArgument().setValue( VssConstants.PROJECT_PREFIX + repo.getProject() );
102
103
104 if ( repo.getUserPassword() != null )
105 {
106 command.createArgument().setValue( VssConstants.FLAG_LOGIN + repo.getUserPassword() );
107 }
108
109
110 command.createArgument().setValue( VssConstants.FLAG_RECURSION );
111
112
113 command.createArgument().setValue( VssConstants.FLAG_AUTORESPONSE_DEF );
114
115
116
117
118 return command;
119 }
120
121
122
123
124 protected ChangeLogCommand getChangeLogCommand()
125 {
126 VssHistoryCommand command = new VssHistoryCommand();
127
128 command.setLogger( getLogger() );
129
130 return command;
131 }
132
133 }