Allow RevWalk applications to add new starting roots during traversal
[egit/qmx.git] / org.spearce.jgit / src / org / spearce / jgit / revwalk / Generator.java
bloba61b2ab5789eb6cf88de81da8187653b49cda513
1 /*
2 * Copyright (C) 2008 Shawn Pearce <spearce@spearce.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License, version 2, as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 package org.spearce.jgit.revwalk;
19 import java.io.IOException;
21 import org.spearce.jgit.errors.IncorrectObjectTypeException;
22 import org.spearce.jgit.errors.MissingObjectException;
24 /**
25 * Produces commits for RevWalk to return to applications.
26 * <p>
27 * Implementations of this basic class provide the real work behind RevWalk.
28 * Conceptually a Generator is an iterator or a queue, it returns commits until
29 * there are no more relevant. Generators may be piped/stacked together to
30 * create a more complex set of operations.
32 * @see PendingGenerator
33 * @see StartGenerator
35 abstract class Generator {
36 /** Commits are sorted by commit date and time, descending. */
37 static final int SORT_COMMIT_TIME_DESC = 1 << 0;
39 /** Output may have {@link RevWalk#REWRITE} marked on it. */
40 static final int HAS_REWRITE = 1 << 1;
42 /** Output needs {@link RewriteGenerator}. */
43 static final int NEEDS_REWRITE = 1 << 2;
45 /** Topological ordering is enforced (all children before parents). */
46 static final int SORT_TOPO = 1 << 3;
48 /** Output may have {@link RevWalk#UNINTERESTING} marked on it. */
49 static final int HAS_UNINTERESTING = 1 << 4;
51 /**
52 * Connect the supplied queue to this generator's own free list (if any).
54 * @param q
55 * another FIFO queue that wants to share our queue's free list.
57 void shareFreeList(final BlockRevQueue q) {
58 // Do nothing by default.
61 /**
62 * Obtain flags describing the output behavior of this generator.
64 * @return one or more of the constants declared in this class, describing
65 * how this generator produces its results.
67 abstract int outputType();
69 /**
70 * Return the next commit to the application, or the next generator.
72 * @return next available commit; null if no more are to be returned.
73 * @throws MissingObjectException
74 * @throws IncorrectObjectTypeException
75 * @throws IOException
77 abstract RevCommit next() throws MissingObjectException,
78 IncorrectObjectTypeException, IOException;