1 package org.apache.maven.scm.provider.hg.command.inventory;
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.ScmFileSet;
26 import org.apache.maven.scm.ScmResult;
27 import org.apache.maven.scm.ScmVersion;
28 import org.apache.maven.scm.command.Command;
29 import org.apache.maven.scm.command.list.AbstractListCommand;
30 import org.apache.maven.scm.command.list.ListScmResult;
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 HgListCommand
42 extends AbstractListCommand
43 implements Command
44 {
45
46 protected ListScmResult executeListCommand( ScmProviderRepository repository, ScmFileSet fileSet,
47 boolean recursive, ScmVersion scmVersion )
48 throws ScmException
49 {
50
51
52 File workingDir = fileSet.getBasedir();
53
54
55 String[] listCmd = new String[] { HgCommandConstants.INVENTORY_CMD };
56
57
58 StringBuilder cmd = new StringBuilder();
59 for ( int i = 0; i < listCmd.length; i++ )
60 {
61 String s = listCmd[i];
62 cmd.append( s );
63 if ( i < listCmd.length - 1 )
64 {
65 cmd.append( " " );
66 }
67 }
68
69 HgListConsumer consumer = new HgListConsumer( getLogger() );
70
71 ScmResult result = HgUtils.execute( consumer, getLogger(), workingDir, listCmd );
72
73 if ( result.isSuccess() )
74 {
75 return new ListScmResult( consumer.getFiles(), result );
76 }
77 else
78 {
79 throw new ScmException( "Error while executing command " + cmd.toString() );
80 }
81 }
82 }