1 | |
package com.aragost.javahg.merge; |
2 | |
|
3 | |
import java.io.IOException; |
4 | |
|
5 | |
import com.aragost.javahg.internals.AbstractCommand; |
6 | |
import com.aragost.javahg.internals.HgInputStream; |
7 | |
import com.aragost.javahg.internals.UnexpectedCommandOutputException; |
8 | |
|
9 | |
public class BackoutConflictResolvingContext extends ConflictResolvingContext { |
10 | |
|
11 | 1 | private static final byte[] MERGING_WITH_CHANGESET = "merging with changeset ".getBytes(); |
12 | 1 | private static final byte[] BACKS_OUT_CHANGESET = " backs out changeset ".getBytes(); |
13 | 1 | private static final byte[] CHANGESET = "changeset".getBytes(); |
14 | 1 | private static final byte[] REVERTING = "reverting".getBytes(); |
15 | 1 | private static final byte[] CREATED_NEW_HEAD = "created new head".getBytes(); |
16 | |
|
17 | |
private final boolean merge; |
18 | |
|
19 | |
public BackoutConflictResolvingContext(AbstractCommand command, boolean merge) { |
20 | 6 | super(command); |
21 | |
|
22 | 6 | this.merge = merge; |
23 | 6 | } |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
@Override |
44 | |
public void processStream(HgInputStream in, boolean whenUnknowReturn) |
45 | |
throws IOException { |
46 | 6 | String createdChangeset = null; |
47 | |
|
48 | 22 | while (!in.isEof()) { |
49 | 20 | if (in.match(REVERTING)) { |
50 | 8 | in.upTo('\n'); |
51 | 12 | } else if (in.match(CREATED_NEW_HEAD)) { |
52 | 2 | in.upTo('\n'); |
53 | 10 | } else if (in.match(CHANGESET)) { |
54 | 4 | createdChangeset = in.textUpTo(BACKS_OUT_CHANGESET); |
55 | 4 | in.upTo('\n'); |
56 | 6 | } else if (in.match(MERGING_WITH_CHANGESET)) { |
57 | 2 | in.upTo('\n'); |
58 | |
} else { |
59 | |
break; |
60 | |
} |
61 | |
} |
62 | |
|
63 | 6 | if (createdChangeset == null && merge) { |
64 | 0 | if (whenUnknowReturn) { |
65 | 0 | return; |
66 | |
} |
67 | 0 | throw new UnexpectedCommandOutputException(this.getCommand(), null); |
68 | |
} |
69 | |
|
70 | 6 | super.processStream(in, whenUnknowReturn); |
71 | 6 | } |
72 | |
|
73 | |
} |