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