1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.revwalk;
12
13 import static org.junit.Assert.assertNull;
14 import static org.junit.Assert.assertTrue;
15
16 import org.junit.Test;
17
18 public class RevWalkCarryFlagsTest extends RevWalkTestCase {
19
20
21
22
23
24
25
26 @Test
27 public void testRevWalkCarryUninteresting_fastClock() throws Exception {
28 final RevCommit a = commit();
29 final RevCommit b = commit(a);
30 final RevCommit c = commit(a);
31 final RevCommit d = commit(c);
32 final RevCommit e = commit(b, d);
33
34 markStart(d);
35 markUninteresting(e);
36 assertNull("Found an unexpected commit", rw.next());
37 }
38
39
40
41
42
43
44
45
46
47
48
49 @Test
50 public void testRevWalkCarryUninteresting_SlowClock() throws Exception {
51 final RevCommit a = commit();
52 final RevCommit b = commit(a);
53 final RevCommit c = commit(a);
54 final RevCommit d = commit(c);
55 final RevCommit e = commit(0, b, d);
56
57 markStart(d);
58 markUninteresting(e);
59 assertNull("Found an unexpected commit", rw.next());
60 }
61
62
63
64
65
66
67
68
69 @Test
70 public void testRevWalkCarryUninteresting_WrongClock() throws Exception {
71 final RevCommit a = commit();
72 final RevCommit b = commit(a);
73 final RevCommit c = commit(a);
74 final RevCommit d = commit(c);
75 final RevCommit e = commit(-1, b, d);
76
77 markStart(d);
78 markUninteresting(e);
79 assertNull("Found an unexpected commit", rw.next());
80 }
81
82
83
84
85
86
87
88 @Test
89 public void testRevWalkCarryCustom_SlowClock() throws Exception {
90 final RevCommit a = commit();
91 final RevCommit b = commit(a);
92 final RevCommit c = commit(a);
93 final RevCommit d = commit(c);
94 final RevCommit e = commit(0, b, d);
95
96 markStart(d);
97 markStart(e);
98 RevFlag customFlag = rw.newFlag("CUSTOM");
99 e.flags |= customFlag.mask;
100 rw.carry(customFlag);
101
102
103
104 int count = 0;
105 for (RevCommit cm : rw) {
106 assertTrue(
107 "Found a commit which doesn't have the custom flag: " + cm,
108 cm.has(customFlag));
109 count++;
110 }
111 assertTrue("Didn't walked over all commits", count == 5);
112 }
113 }