1 | |
package org.apache.maven.scm.provider.cvslib.command.list; |
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 | |
|
25 | |
import org.apache.maven.scm.ScmException; |
26 | |
import org.apache.maven.scm.ScmFileSet; |
27 | |
import org.apache.maven.scm.ScmVersion; |
28 | |
import org.apache.maven.scm.command.list.AbstractListCommand; |
29 | |
import org.apache.maven.scm.command.list.ListScmResult; |
30 | |
import org.apache.maven.scm.provider.ScmProviderRepository; |
31 | |
import org.apache.maven.scm.provider.cvslib.command.CvsCommand; |
32 | |
import org.apache.maven.scm.provider.cvslib.command.CvsCommandUtils; |
33 | |
import org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository; |
34 | |
import org.codehaus.plexus.util.StringUtils; |
35 | |
import org.codehaus.plexus.util.cli.Commandline; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public abstract class AbstractCvsListCommand |
42 | |
extends AbstractListCommand |
43 | |
implements CvsCommand |
44 | |
{ |
45 | |
|
46 | |
protected ListScmResult executeListCommand( ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, |
47 | |
ScmVersion version ) |
48 | |
throws ScmException |
49 | |
{ |
50 | 0 | CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; |
51 | |
|
52 | 0 | Commandline cl = CvsCommandUtils.getBaseCommand( "rls", repository, fileSet, "-n" ); |
53 | |
|
54 | 0 | if ( version != null && !StringUtils.isEmpty( version.getName() ) ) |
55 | |
{ |
56 | 0 | cl.createArg().setValue( "-r" ); |
57 | 0 | cl.createArg().setValue( version.getName() ); |
58 | |
} |
59 | |
|
60 | 0 | cl.createArg().setValue( "-d" ); |
61 | 0 | cl.createArg().setValue( "-e" ); |
62 | |
|
63 | 0 | if ( recursive ) |
64 | |
{ |
65 | 0 | cl.createArg().setValue( "-R" ); |
66 | |
} |
67 | |
|
68 | 0 | for ( Iterator<File> it = fileSet.getFileList().iterator(); it.hasNext(); ) |
69 | |
{ |
70 | 0 | File target = (File) it.next(); |
71 | 0 | String path = target.getPath(); |
72 | 0 | if ( path.startsWith( "\\" ) ) |
73 | |
{ |
74 | 0 | path = path.substring( 1 ); |
75 | |
} |
76 | 0 | cl.createArg().setValue( path ); |
77 | 0 | } |
78 | |
|
79 | 0 | if ( getLogger().isInfoEnabled() ) |
80 | |
{ |
81 | 0 | getLogger().info( "Executing: " + cl ); |
82 | 0 | getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); |
83 | |
} |
84 | |
|
85 | 0 | return executeCvsCommand( cl ); |
86 | |
} |
87 | |
|
88 | |
protected abstract ListScmResult executeCvsCommand( Commandline cl ) |
89 | |
throws ScmException; |
90 | |
} |