1 | |
package org.apache.maven.scm.provider.cvslib.command.update; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.io.File; |
23 | |
import java.util.Iterator; |
24 | |
import java.util.List; |
25 | |
|
26 | |
import org.apache.maven.scm.ScmException; |
27 | |
import org.apache.maven.scm.ScmFileSet; |
28 | |
import org.apache.maven.scm.ScmVersion; |
29 | |
import org.apache.maven.scm.command.update.AbstractUpdateCommand; |
30 | |
import org.apache.maven.scm.command.update.UpdateScmResult; |
31 | |
import org.apache.maven.scm.provider.ScmProviderRepository; |
32 | |
import org.apache.maven.scm.provider.cvslib.command.CvsCommand; |
33 | |
import org.apache.maven.scm.provider.cvslib.command.CvsCommandUtils; |
34 | |
import org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository; |
35 | |
import org.codehaus.plexus.util.StringUtils; |
36 | |
import org.codehaus.plexus.util.cli.Commandline; |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | 0 | public abstract class AbstractCvsUpdateCommand |
45 | |
extends AbstractUpdateCommand |
46 | |
implements CvsCommand |
47 | |
{ |
48 | |
|
49 | |
public UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version ) |
50 | |
throws ScmException |
51 | |
{ |
52 | 0 | CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; |
53 | |
|
54 | 0 | Commandline cl = CvsCommandUtils.getBaseCommand( "update", repository, fileSet, false ); |
55 | |
|
56 | 0 | cl.createArg().setValue( "-d" ); |
57 | |
|
58 | 0 | if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) |
59 | |
{ |
60 | 0 | cl.createArg().setValue( "-r" + version.getName() ); |
61 | |
} |
62 | |
|
63 | 0 | List<File> files = fileSet.getFileList(); |
64 | 0 | if ( !files.isEmpty() ) |
65 | |
{ |
66 | 0 | Iterator<File> fileIterator = files.iterator(); |
67 | 0 | while ( fileIterator.hasNext() ) |
68 | |
{ |
69 | 0 | cl.createArg().setValue( ( (File) fileIterator.next() ).getPath() ); |
70 | |
} |
71 | |
} |
72 | |
|
73 | 0 | if ( getLogger().isInfoEnabled() ) |
74 | |
{ |
75 | 0 | getLogger().info( "Executing: " + cl ); |
76 | 0 | getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); |
77 | |
} |
78 | |
|
79 | 0 | return executeCvsCommand( cl ); |
80 | |
} |
81 | |
|
82 | |
protected abstract UpdateScmResult executeCvsCommand( Commandline cl ) |
83 | |
throws ScmException; |
84 | |
} |