1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.scm.provider.hg.command.add;
20
21 import java.io.File;
22
23 import org.apache.maven.scm.ScmException;
24 import org.apache.maven.scm.ScmFile;
25 import org.apache.maven.scm.ScmFileSet;
26 import org.apache.maven.scm.ScmFileStatus;
27 import org.apache.maven.scm.ScmResult;
28 import org.apache.maven.scm.command.Command;
29 import org.apache.maven.scm.command.add.AbstractAddCommand;
30 import org.apache.maven.scm.command.add.AddScmResult;
31 import org.apache.maven.scm.provider.ScmProviderRepository;
32 import org.apache.maven.scm.provider.hg.HgUtils;
33 import org.apache.maven.scm.provider.hg.command.HgCommandConstants;
34
35
36
37
38
39
40 public class HgAddCommand extends AbstractAddCommand implements Command {
41
42
43
44 protected ScmResult executeAddCommand(
45 ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
46
47 String[] addCmd = new String[] {HgCommandConstants.ADD_CMD, HgCommandConstants.VERBOSE_OPTION};
48 addCmd = HgUtils.expandCommandLine(addCmd, fileSet);
49
50 File workingDir = fileSet.getBasedir();
51 HgAddConsumer consumer = new HgAddConsumer(workingDir);
52 ScmResult result = HgUtils.execute(consumer, workingDir, addCmd);
53
54 AddScmResult addScmResult = new AddScmResult(consumer.getAddedFiles(), result);
55
56
57
58 for (File workingFile : fileSet.getFileList()) {
59 File file = new File(workingDir + "/" + workingFile.getPath());
60 if (file.isDirectory() && file.listFiles().length == 0) {
61 addScmResult.getAddedFiles().add(new ScmFile(workingFile.getPath(), ScmFileStatus.ADDED));
62 }
63 }
64
65 return addScmResult;
66 }
67 }