1 package org.apache.maven.scm.provider.cvslib.command.remove;
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.ScmFile;
24 import org.apache.maven.scm.ScmFileSet;
25 import org.apache.maven.scm.ScmFileStatus;
26 import org.apache.maven.scm.ScmResult;
27 import org.apache.maven.scm.command.remove.AbstractRemoveCommand;
28 import org.apache.maven.scm.command.remove.RemoveScmResult;
29 import org.apache.maven.scm.provider.ScmProviderRepository;
30 import org.apache.maven.scm.provider.cvslib.command.CvsCommand;
31 import org.apache.maven.scm.provider.cvslib.command.CvsCommandUtils;
32 import org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository;
33 import org.codehaus.plexus.util.cli.Commandline;
34
35 import java.io.File;
36 import java.util.ArrayList;
37 import java.util.List;
38
39
40
41
42
43
44
45 public abstract class AbstractCvsRemoveCommand
46 extends AbstractRemoveCommand
47 implements CvsCommand
48 {
49
50 protected ScmResult executeRemoveCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message )
51 throws ScmException
52 {
53 CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
54
55 Commandline cl = CvsCommandUtils.getBaseCommand( "remove", repository, fileSet );
56
57 cl.createArg().setValue( "-f" );
58
59 cl.createArg().setValue( "-l" );
60
61 List<File> files = fileSet.getFileList();
62
63 List<ScmFile> removedFiles = new ArrayList<ScmFile>();
64
65 for ( File file : files )
66 {
67 String path = file.getPath().replace( '\\', '/' );
68
69 cl.createArg().setValue( path );
70
71 removedFiles.add( new ScmFile( path, ScmFileStatus.DELETED ) );
72 }
73
74 if ( getLogger().isInfoEnabled() )
75 {
76 getLogger().info( "Executing: " + cl );
77 getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
78 }
79
80 return executeCvsCommand( cl, removedFiles );
81 }
82
83 protected abstract RemoveScmResult executeCvsCommand( Commandline cl, List<ScmFile> removedFiles )
84 throws ScmException;
85 }