1 | |
package org.apache.maven.scm.provider.jazz.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.command.blame.BlameLine; |
23 | |
import org.apache.maven.scm.log.ScmLogger; |
24 | |
import org.apache.maven.scm.provider.ScmProviderRepository; |
25 | |
import org.apache.maven.scm.provider.jazz.command.consumer.AbstractRepositoryConsumer; |
26 | |
import org.apache.regexp.RE; |
27 | |
import org.apache.regexp.RESyntaxException; |
28 | |
|
29 | |
import java.text.SimpleDateFormat; |
30 | |
import java.util.ArrayList; |
31 | |
import java.util.Date; |
32 | |
import java.util.List; |
33 | |
import java.util.TimeZone; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
public class JazzBlameConsumer |
43 | |
extends AbstractRepositoryConsumer |
44 | |
{ |
45 | |
private static final String JAZZ_TIMESTAMP_PATTERN = "yyyy-MM-dd"; |
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
private static final String LINE_PATTERN = "(\\d+) (.*) \\((\\d+)\\) (\\d+-\\d+-\\d+) (.*)"; |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
private RE lineRegexp; |
56 | |
|
57 | 2 | private List<BlameLine> fLines = new ArrayList<BlameLine>(); |
58 | |
|
59 | |
private SimpleDateFormat dateFormat; |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
public JazzBlameConsumer( ScmProviderRepository repository, ScmLogger logger ) |
68 | |
{ |
69 | 2 | super( repository, logger ); |
70 | |
|
71 | 2 | dateFormat = new SimpleDateFormat( JAZZ_TIMESTAMP_PATTERN ); |
72 | 2 | dateFormat.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); |
73 | |
|
74 | |
try |
75 | |
{ |
76 | 2 | lineRegexp = new RE( LINE_PATTERN ); |
77 | |
} |
78 | 0 | catch ( RESyntaxException ex ) |
79 | |
{ |
80 | 0 | throw new RuntimeException( |
81 | |
"INTERNAL ERROR: Could not create regexp to parse jazz scm blame output. This shouldn't happen. Something is probably wrong with the oro installation.", |
82 | |
ex ); |
83 | 2 | } |
84 | 2 | } |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
public void consumeLine( String line ) |
93 | |
{ |
94 | 2 | super.consumeLine( line ); |
95 | |
|
96 | 2 | if ( lineRegexp.match( line ) ) |
97 | |
{ |
98 | 2 | String lineNumberStr = lineRegexp.getParen( 1 ); |
99 | 2 | String owner = lineRegexp.getParen( 2 ); |
100 | 2 | String changeSetNumberStr = lineRegexp.getParen( 3 ); |
101 | 2 | String dateStr = lineRegexp.getParen( 4 ); |
102 | 2 | Date date = parseDate( dateStr, JAZZ_TIMESTAMP_PATTERN, null ); |
103 | 2 | fLines.add( new BlameLine( date, changeSetNumberStr, owner ) ); |
104 | |
} |
105 | 2 | } |
106 | |
|
107 | |
public List<BlameLine> getLines() |
108 | |
{ |
109 | 1 | return fLines; |
110 | |
} |
111 | |
} |