You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Generator.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.revwalk;
  11. import java.io.IOException;
  12. import org.eclipse.jgit.errors.IncorrectObjectTypeException;
  13. import org.eclipse.jgit.errors.MissingObjectException;
  14. /**
  15. * Produces commits for RevWalk to return to applications.
  16. * <p>
  17. * Implementations of this basic class provide the real work behind RevWalk.
  18. * Conceptually a Generator is an iterator or a queue, it returns commits until
  19. * there are no more relevant. Generators may be piped/stacked together to
  20. * create a more complex set of operations.
  21. *
  22. * @see PendingGenerator
  23. * @see StartGenerator
  24. */
  25. abstract class Generator {
  26. /** Commits are sorted by commit date and time, descending. */
  27. static final int SORT_COMMIT_TIME_DESC = 1 << 0;
  28. /** Output may have {@link RevWalk#REWRITE} marked on it. */
  29. static final int HAS_REWRITE = 1 << 1;
  30. /** Output needs {@link RewriteGenerator}. */
  31. static final int NEEDS_REWRITE = 1 << 2;
  32. /** Topological ordering is enforced (all children before parents). */
  33. static final int SORT_TOPO = 1 << 3;
  34. /** Output may have {@link RevWalk#UNINTERESTING} marked on it. */
  35. static final int HAS_UNINTERESTING = 1 << 4;
  36. protected final boolean firstParent;
  37. protected Generator(boolean firstParent) {
  38. this.firstParent = firstParent;
  39. }
  40. /**
  41. * Connect the supplied queue to this generator's own free list (if any).
  42. *
  43. * @param q
  44. * another FIFO queue that wants to share our queue's free list.
  45. */
  46. void shareFreeList(BlockRevQueue q) {
  47. // Do nothing by default.
  48. }
  49. /**
  50. * Obtain flags describing the output behavior of this generator.
  51. *
  52. * @return one or more of the constants declared in this class, describing
  53. * how this generator produces its results.
  54. */
  55. abstract int outputType();
  56. /**
  57. * Return the next commit to the application, or the next generator.
  58. *
  59. * @return next available commit; null if no more are to be returned.
  60. * @throws MissingObjectException
  61. * @throws IncorrectObjectTypeException
  62. * @throws IOException
  63. */
  64. abstract RevCommit next() throws MissingObjectException,
  65. IncorrectObjectTypeException, IOException;
  66. }