1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.scm.provider.svn.svnexe.command.status;
20
21 import org.apache.maven.scm.ScmException;
22 import org.apache.maven.scm.ScmFileSet;
23 import org.apache.maven.scm.command.status.AbstractStatusCommand;
24 import org.apache.maven.scm.command.status.StatusScmResult;
25 import org.apache.maven.scm.provider.ScmProviderRepository;
26 import org.apache.maven.scm.provider.svn.command.SvnCommand;
27 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
28 import org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils;
29 import org.codehaus.plexus.util.Os;
30 import org.codehaus.plexus.util.cli.CommandLineException;
31 import org.codehaus.plexus.util.cli.CommandLineUtils;
32 import org.codehaus.plexus.util.cli.Commandline;
33
34
35
36
37 public class SvnStatusCommand extends AbstractStatusCommand implements SvnCommand {
38
39 private final boolean interactive;
40
41 public SvnStatusCommand(boolean interactive) {
42 this.interactive = interactive;
43 }
44
45
46
47
48 protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
49 Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet);
50
51 SvnStatusConsumer consumer = new SvnStatusConsumer(fileSet.getBasedir());
52
53 CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
54
55 if (logger.isInfoEnabled()) {
56 logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
57
58 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
59 logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
60 }
61 }
62
63 int exitCode;
64
65 try {
66 exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr);
67 } catch (CommandLineException ex) {
68 throw new ScmException("Error while executing command.", ex);
69 }
70
71 if (exitCode != 0) {
72 return new StatusScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
73 }
74
75 return new StatusScmResult(cl.toString(), consumer.getChangedFiles());
76 }
77
78
79
80
81
82 public Commandline createCommandLine(SvnScmProviderRepository repository, ScmFileSet fileSet) {
83 Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository, interactive);
84
85 cl.createArg().setValue("status");
86
87 return cl;
88 }
89 }