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
41 public class HgAddCommand extends AbstractAddCommand implements Command {
42
43 protected ScmResult executeAddCommand(
44 ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
45
46 String[] addCmd = new String[] {HgCommandConstants.ADD_CMD, HgCommandConstants.VERBOSE_OPTION};
47 addCmd = HgUtils.expandCommandLine(addCmd, fileSet);
48
49 File workingDir = fileSet.getBasedir();
50 HgAddConsumer consumer = new HgAddConsumer(workingDir);
51 ScmResult result = HgUtils.execute(consumer, workingDir, addCmd);
52
53 AddScmResult addScmResult = new AddScmResult(consumer.getAddedFiles(), result);
54
55
56
57 for (File workingFile : fileSet.getFileList()) {
58 File file = new File(workingDir + "/" + workingFile.getPath());
59 if (file.isDirectory() && file.listFiles().length == 0) {
60 addScmResult.getAddedFiles().add(new ScmFile(workingFile.getPath(), ScmFileStatus.ADDED));
61 }
62 }
63
64 return addScmResult;
65 }
66 }