-
Notifications
You must be signed in to change notification settings - Fork 17
/
ProjectConflicts.java
70 lines (62 loc) · 2.32 KB
/
ProjectConflicts.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package hudson.plugins.synergy.impl;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
/**
* Synergy command that checks for object and task conflicts
* in the specified project and its subprojects.
*/
public class ProjectConflicts extends Command {
private String project;
private List<Conflict> conflicts = new ArrayList<Conflict>();
public ProjectConflicts(String project) {
this.project = project;
}
@Override
public String[] buildCommand(String ccmExe) {
return new String[]{ccmExe, "conflicts", "-r", "-noformat", project};
}
@Override
public void parseResult(String result) {
BufferedReader reader = new BufferedReader(new StringReader(result));
try {
String line = reader.readLine();
while (line!=null) {
line = line.trim();
if((line.indexOf("Conflict detection completed") == -1) &&
(line.indexOf("Finding objects that are not included") == -1) &&
(line.indexOf("Collecting objects and tasks beyond baseline") == -1) &&
// the following lines are needed using Synergy 7.1; these lines occure sporadically!
(line.indexOf("%...") == -1) && // lines like "0%..."
(line.indexOf("Getting explicitly included objects.") == -1) &&
(line.indexOf("Getting members of baseline project.") == -1) &&
(line.indexOf("Checking for missing fix tasks.") == -1))
{
if (line.length()!=0 && !line.startsWith("Project:") && line.indexOf("No conflicts detected")==-1) {
StringTokenizer tokenizer = new StringTokenizer(line, "\t");
String objectname = tokenizer.nextToken();
String task = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : "No Task";
String message = "";
String type = "";
if(tokenizer.hasMoreTokens()){
message = tokenizer.nextToken();
int index = message.lastIndexOf("-");
type = message.substring(index+1).trim();
}
Conflict conflict = new Conflict(objectname, task, type, message);
conflicts.add(conflict);
}
}
line = reader.readLine();
}
} catch (IOException e) {
// Ignore with a StringReader.
}
}
public List<Conflict> getConflicts() {
return conflicts;
}
}