1 | |
package org.apache.maven.scm.provider.hg.command.blame; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.scm.ScmFileStatus; |
23 | |
import org.apache.maven.scm.command.blame.BlameLine; |
24 | |
import org.apache.maven.scm.log.ScmLogger; |
25 | |
import org.apache.maven.scm.provider.hg.command.HgConsumer; |
26 | |
|
27 | |
import java.util.ArrayList; |
28 | |
import java.util.Date; |
29 | |
import java.util.List; |
30 | |
import java.util.Locale; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public class HgBlameConsumer |
39 | |
extends HgConsumer |
40 | |
{ |
41 | 0 | private List<BlameLine> lines = new ArrayList<BlameLine>(); |
42 | |
|
43 | |
private static final String HG_TIMESTAMP_PATTERN = "EEE MMM dd HH:mm:ss yyyy Z"; |
44 | |
|
45 | |
public HgBlameConsumer( ScmLogger logger ) |
46 | |
{ |
47 | 0 | super( logger ); |
48 | |
|
49 | 0 | } |
50 | |
|
51 | |
public void doConsume( ScmFileStatus status, String trimmedLine ) |
52 | |
{ |
53 | |
|
54 | |
String annotation; |
55 | 0 | if ( trimmedLine.indexOf( ": " ) > -1 ) |
56 | |
{ |
57 | 0 | annotation = trimmedLine.substring( 0, trimmedLine.indexOf( ": " ) ).trim(); |
58 | |
} |
59 | |
else |
60 | |
{ |
61 | 0 | annotation = trimmedLine.substring( 0, trimmedLine.lastIndexOf( ":" ) ).trim(); |
62 | |
} |
63 | |
|
64 | 0 | String author = annotation.substring( 0, annotation.indexOf( ' ' ) ); |
65 | 0 | annotation = annotation.substring( annotation.indexOf( ' ' ) + 1 ).trim(); |
66 | |
|
67 | 0 | String revision = annotation.substring( 0, annotation.indexOf( ' ' ) ); |
68 | 0 | annotation = annotation.substring( annotation.indexOf( ' ' ) + 1 ).trim(); |
69 | |
|
70 | 0 | String dateStr = annotation; |
71 | 0 | Date dateTime = parseDate( dateStr, null, HG_TIMESTAMP_PATTERN, Locale.ENGLISH ); |
72 | |
|
73 | 0 | lines.add( new BlameLine( dateTime, revision, author ) ); |
74 | 0 | } |
75 | |
|
76 | |
public List<BlameLine> getLines() |
77 | |
{ |
78 | 0 | return lines; |
79 | |
} |
80 | |
} |