1 package org.apache.maven.scm.provider.jazz.command.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.ScmFile;
24 import org.apache.maven.scm.ScmFileSet;
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.jazz.command.JazzConstants;
29 import org.apache.maven.scm.provider.jazz.command.JazzScmCommand;
30 import org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 public class JazzStatusCommand
46 extends AbstractStatusCommand
47 {
48
49
50
51 public StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
52 throws ScmException
53 {
54 if ( getLogger().isDebugEnabled() )
55 {
56 getLogger().debug( "Executing status command..." );
57 }
58
59 JazzStatusConsumer statusConsumer = new JazzStatusConsumer( repo, getLogger() );
60 ErrorConsumer errConsumer = new ErrorConsumer( getLogger() );
61
62 JazzScmCommand statusCmd = createStatusCommand( repo, fileSet );
63 int status = statusCmd.execute( statusConsumer, errConsumer );
64 if ( status != 0 || errConsumer.hasBeenFed() )
65 {
66 return new StatusScmResult( statusCmd.getCommandString(),
67 "Error code for Jazz SCM status command - " + status, errConsumer.getOutput(),
68 false );
69 }
70
71 if ( getLogger().isDebugEnabled() )
72 {
73 if ( !statusConsumer.getChangedFiles().isEmpty() )
74 {
75 getLogger().debug( "Iterating over \"Status\" results" );
76 for ( ScmFile file : statusConsumer.getChangedFiles() )
77 {
78 getLogger().debug( file.getPath() + " : " + file.getStatus() );
79 }
80 }
81 else
82 {
83 getLogger().debug( "There are no differences" );
84 }
85 }
86
87 return new StatusScmResult( statusCmd.getCommandString(), statusConsumer.getChangedFiles() );
88 }
89
90 public JazzScmCommand createStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
91 {
92 JazzScmCommand command =
93 new JazzScmCommand( JazzConstants.CMD_STATUS, null, repo, false, fileSet, getLogger() );
94
95 command.addArgument( JazzConstants.ARG_STATUS_WIDE_PRINT_OUT );
96 return command;
97 }
98 }