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 package org.eclipse.jgit.revwalk;
46
47 import java.io.IOException;
48
49 import org.eclipse.jgit.errors.IncorrectObjectTypeException;
50 import org.eclipse.jgit.errors.MissingObjectException;
51
52 class BoundaryGenerator extends Generator {
53 static final int UNINTERESTING = RevWalk.UNINTERESTING;
54
55 Generator g;
56
57 BoundaryGenerator(RevWalk w, Generator s) {
58 g = new InitialGenerator(w, s);
59 }
60
61 @Override
62 int outputType() {
63 return g.outputType() | HAS_UNINTERESTING;
64 }
65
66 @Override
67 void shareFreeList(BlockRevQueue q) {
68 g.shareFreeList(q);
69 }
70
71 @Override
72 RevCommit next() throws MissingObjectException,
73 IncorrectObjectTypeException, IOException {
74 return g.next();
75 }
76
77 private class InitialGenerator extends Generator {
78 private static final int PARSED = RevWalk.PARSED;
79
80 private static final int DUPLICATE = RevWalk.TEMP_MARK;
81
82 private final RevWalk walk;
83
84 private final FIFORevQueue held;
85
86 private final Generator source;
87
88 InitialGenerator(RevWalk w, Generator s) {
89 walk = w;
90 held = new FIFORevQueue();
91 source = s;
92 source.shareFreeList(held);
93 }
94
95 @Override
96 int outputType() {
97 return source.outputType();
98 }
99
100 @Override
101 void shareFreeList(BlockRevQueue q) {
102 q.shareFreeList(held);
103 }
104
105 @Override
106 RevCommit next() throws MissingObjectException,
107 IncorrectObjectTypeException, IOException {
108 RevCommit c = source.next();
109 if (c != null) {
110 for (RevCommit p : c.parents)
111 if ((p.flags & UNINTERESTING) != 0)
112 held.add(p);
113 return c;
114 }
115
116 final FIFORevQueue boundary = new FIFORevQueue();
117 boundary.shareFreeList(held);
118 for (;;) {
119 c = held.next();
120 if (c == null)
121 break;
122 if ((c.flags & DUPLICATE) != 0)
123 continue;
124 if ((c.flags & PARSED) == 0)
125 c.parseHeaders(walk);
126 c.flags |= DUPLICATE;
127 boundary.add(c);
128 }
129 boundary.removeFlag(DUPLICATE);
130 g = boundary;
131 return boundary.next();
132 }
133 }
134 }