1 | |
package org.apache.maven.scm.provider.cvslib.cvsexe.command.update; |
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.command.changelog.ChangeLogCommand; |
24 | |
import org.apache.maven.scm.command.update.UpdateScmResult; |
25 | |
import org.apache.maven.scm.provider.cvslib.command.update.AbstractCvsUpdateCommand; |
26 | |
import org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer; |
27 | |
import org.apache.maven.scm.provider.cvslib.cvsexe.command.changelog.CvsExeChangeLogCommand; |
28 | |
import org.codehaus.plexus.util.cli.CommandLineException; |
29 | |
import org.codehaus.plexus.util.cli.CommandLineUtils; |
30 | |
import org.codehaus.plexus.util.cli.Commandline; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 2 | public class CvsExeUpdateCommand |
37 | |
extends AbstractCvsUpdateCommand |
38 | |
{ |
39 | |
|
40 | |
protected UpdateScmResult executeCvsCommand( Commandline cl ) |
41 | |
throws ScmException |
42 | |
{ |
43 | 2 | CvsUpdateConsumer consumer = new CvsUpdateConsumer( getLogger() ); |
44 | |
|
45 | 2 | CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); |
46 | |
|
47 | |
int exitCode; |
48 | |
|
49 | |
try |
50 | |
{ |
51 | 2 | exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); |
52 | |
} |
53 | 0 | catch ( CommandLineException ex ) |
54 | |
{ |
55 | 0 | throw new ScmException( "Error while executing command.", ex ); |
56 | 2 | } |
57 | |
|
58 | 2 | if ( exitCode != 0 ) |
59 | |
{ |
60 | 0 | return new UpdateScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); |
61 | |
} |
62 | |
|
63 | 2 | return new UpdateScmResult( cl.toString(), consumer.getUpdatedFiles() ); |
64 | |
} |
65 | |
|
66 | |
protected ChangeLogCommand getChangeLogCommand() |
67 | |
{ |
68 | 2 | CvsExeChangeLogCommand command = new CvsExeChangeLogCommand(); |
69 | |
|
70 | 2 | command.setLogger( getLogger() ); |
71 | |
|
72 | 2 | return command; |
73 | |
} |
74 | |
} |