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
38 public class SvnStatusCommand extends AbstractStatusCommand implements SvnCommand {
39
40 protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
41 Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet);
42
43 SvnStatusConsumer consumer = new SvnStatusConsumer(fileSet.getBasedir());
44
45 CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
46
47 if (logger.isInfoEnabled()) {
48 logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
49
50 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
51 logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
52 }
53 }
54
55 int exitCode;
56
57 try {
58 exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr);
59 } catch (CommandLineException ex) {
60 throw new ScmException("Error while executing command.", ex);
61 }
62
63 if (exitCode != 0) {
64 return new StatusScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
65 }
66
67 return new StatusScmResult(cl.toString(), consumer.getChangedFiles());
68 }
69
70
71
72
73
74 public static Commandline createCommandLine(SvnScmProviderRepository repository, ScmFileSet fileSet) {
75 Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository);
76
77 cl.createArg().setValue("status");
78
79 return cl;
80 }
81 }