1 package org.apache.maven.scm.provider.hg.command.add;
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
24 import org.apache.maven.scm.ScmException;
25 import org.apache.maven.scm.ScmFile;
26 import org.apache.maven.scm.ScmFileSet;
27 import org.apache.maven.scm.ScmFileStatus;
28 import org.apache.maven.scm.ScmResult;
29 import org.apache.maven.scm.command.Command;
30 import org.apache.maven.scm.command.add.AbstractAddCommand;
31 import org.apache.maven.scm.command.add.AddScmResult;
32 import org.apache.maven.scm.provider.ScmProviderRepository;
33 import org.apache.maven.scm.provider.hg.HgUtils;
34 import org.apache.maven.scm.provider.hg.command.HgCommandConstants;
35
36
37
38
39
40
41
42 public class HgAddCommand
43 extends AbstractAddCommand
44 implements Command
45 {
46
47 protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message,
48 boolean binary )
49 throws ScmException
50 {
51
52 String[] addCmd = new String[] { HgCommandConstants.ADD_CMD, HgCommandConstants.VERBOSE_OPTION };
53 addCmd = HgUtils.expandCommandLine( addCmd, fileSet );
54
55 File workingDir = fileSet.getBasedir();
56 HgAddConsumer consumer = new HgAddConsumer( getLogger(), workingDir );
57 ScmResult result = HgUtils.execute( consumer, getLogger(), workingDir, addCmd );
58
59 AddScmResult addScmResult = new AddScmResult( consumer.getAddedFiles(), result );
60
61
62
63 for ( File workingFile : fileSet.getFileList() )
64 {
65 File file = new File( workingDir + "/" + workingFile.getPath() );
66 if ( file.isDirectory() && file.listFiles().length == 0 )
67 {
68 addScmResult.getAddedFiles().add( new ScmFile( workingFile.getPath(), ScmFileStatus.ADDED ) );
69 }
70 }
71
72 return addScmResult;
73 }
74 }