blob: bdf63ff10bad75e6c88ed76f92132b2004b86491 (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/*
* Copyright (C) 2009, Google Inc.
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.revwalk;
import java.io.IOException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
class BoundaryGenerator extends Generator {
static final int UNINTERESTING = RevWalk.UNINTERESTING;
Generator g;
BoundaryGenerator(RevWalk w, Generator s) {
super(s.firstParent);
g = new InitialGenerator(w, s);
}
@Override
int outputType() {
return g.outputType() | HAS_UNINTERESTING;
}
@Override
void shareFreeList(BlockRevQueue q) {
g.shareFreeList(q);
}
@Override
RevCommit next() throws MissingObjectException,
IncorrectObjectTypeException, IOException {
return g.next();
}
private class InitialGenerator extends Generator {
private static final int PARSED = RevWalk.PARSED;
private static final int DUPLICATE = RevWalk.TEMP_MARK;
private final RevWalk walk;
private final FIFORevQueue held;
private final Generator source;
InitialGenerator(RevWalk w, Generator s) {
super(s.firstParent);
walk = w;
held = new FIFORevQueue(firstParent);
source = s;
source.shareFreeList(held);
}
@Override
int outputType() {
return source.outputType();
}
@Override
void shareFreeList(BlockRevQueue q) {
q.shareFreeList(held);
}
@Override
RevCommit next() throws MissingObjectException,
IncorrectObjectTypeException, IOException {
RevCommit c = source.next();
if (c != null) {
int n = c.getParentCount();
for (int i = 0; i < n; i++) {
if (firstParent && i > 0) {
break;
}
RevCommit p = c.getParent(i);
if ((p.flags & UNINTERESTING) != 0) {
held.add(p);
}
}
return c;
}
final FIFORevQueue boundary = new FIFORevQueue(firstParent);
boundary.shareFreeList(held);
for (;;) {
c = held.next();
if (c == null)
break;
if ((c.flags & DUPLICATE) != 0)
continue;
if ((c.flags & PARSED) == 0)
c.parseHeaders(walk);
c.flags |= DUPLICATE;
boundary.add(c);
}
boundary.removeFlag(DUPLICATE);
g = boundary;
return boundary.next();
}
}
}
|