1 | |
package org.apache.maven.scm.provider.tfs.command; |
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 | |
import java.util.ArrayList; |
24 | |
import java.util.Date; |
25 | |
import java.util.Iterator; |
26 | |
import java.util.List; |
27 | |
|
28 | |
import org.apache.maven.scm.ChangeSet; |
29 | |
import org.apache.maven.scm.ScmBranch; |
30 | |
import org.apache.maven.scm.ScmException; |
31 | |
import org.apache.maven.scm.ScmFileSet; |
32 | |
import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand; |
33 | |
import org.apache.maven.scm.command.changelog.ChangeLogScmResult; |
34 | |
import org.apache.maven.scm.command.changelog.ChangeLogSet; |
35 | |
import org.apache.maven.scm.provider.ScmProviderRepository; |
36 | |
import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; |
37 | |
import org.apache.maven.scm.provider.tfs.command.consumer.TfsChangeLogConsumer; |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | 1 | public class TfsChangeLogCommand |
44 | |
extends AbstractChangeLogCommand |
45 | |
{ |
46 | |
|
47 | |
protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository r, ScmFileSet f, Date startDate, |
48 | |
Date endDate, ScmBranch branch, String datePattern ) |
49 | |
throws ScmException |
50 | |
{ |
51 | 0 | List<ChangeSet> changeLogs = new ArrayList<ChangeSet>(); |
52 | 0 | Iterator<File> iter = f.getFileList().iterator(); |
53 | 0 | if ( !iter.hasNext() ) |
54 | |
{ |
55 | 0 | List<File> dir = new ArrayList<File>(); |
56 | |
|
57 | 0 | dir.add( f.getBasedir() ); |
58 | 0 | iter = dir.iterator(); |
59 | |
} |
60 | 0 | TfsCommand command = null; |
61 | |
|
62 | 0 | while ( iter.hasNext() ) |
63 | |
{ |
64 | 0 | TfsChangeLogConsumer out = new TfsChangeLogConsumer( getLogger() ); |
65 | 0 | ErrorStreamConsumer err = new ErrorStreamConsumer(); |
66 | |
|
67 | 0 | command = createCommand( r, f, ( (File) iter.next() ) ); |
68 | 0 | int status = command.execute( out, err ); |
69 | |
|
70 | 0 | if ( status != 0 || ( !out.hasBeenFed() && err.hasBeenFed() ) ) |
71 | 0 | return new ChangeLogScmResult( command.getCommandString(), "Error code for TFS changelog command - " |
72 | |
+ status, err.getOutput(), false ); |
73 | 0 | changeLogs.addAll( out.getLogs() ); |
74 | 0 | } |
75 | 0 | return new ChangeLogScmResult( command.getCommandString(), new ChangeLogSet( changeLogs, startDate, endDate ) ); |
76 | |
|
77 | |
} |
78 | |
|
79 | |
protected TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f, File file ) |
80 | |
{ |
81 | 1 | TfsCommand command = new TfsCommand( "history", r, f, getLogger() ); |
82 | 1 | command.addArgument( "-format:detailed" ); |
83 | 1 | command.addArgument( file.getName() ); |
84 | 1 | return command; |
85 | |
} |
86 | |
} |
87 | |
|