Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

LIFORevQueue.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2009, Google Inc.
  3. * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
  4. *
  5. * This program and the accompanying materials are made available under the
  6. * terms of the Eclipse Distribution License v. 1.0 which is available at
  7. * https://www.eclipse.org/org/documents/edl-v10.php.
  8. *
  9. * SPDX-License-Identifier: BSD-3-Clause
  10. */
  11. package org.eclipse.jgit.revwalk;
  12. import java.io.IOException;
  13. import org.eclipse.jgit.errors.IncorrectObjectTypeException;
  14. import org.eclipse.jgit.errors.MissingObjectException;
  15. /**
  16. * A queue of commits in LIFO order.
  17. */
  18. public class LIFORevQueue extends BlockRevQueue {
  19. private Block head;
  20. /**
  21. * Create an empty LIFO queue.
  22. */
  23. public LIFORevQueue() {
  24. super(false);
  25. }
  26. LIFORevQueue(Generator s) throws MissingObjectException,
  27. IncorrectObjectTypeException, IOException {
  28. super(s);
  29. }
  30. /** {@inheritDoc} */
  31. @Override
  32. public void add(RevCommit c) {
  33. Block b = head;
  34. if (b == null || !b.canUnpop()) {
  35. b = free.newBlock();
  36. b.resetToEnd();
  37. b.next = head;
  38. head = b;
  39. }
  40. b.unpop(c);
  41. }
  42. /** {@inheritDoc} */
  43. @Override
  44. public RevCommit next() {
  45. final Block b = head;
  46. if (b == null)
  47. return null;
  48. final RevCommit c = b.pop();
  49. if (b.isEmpty()) {
  50. head = b.next;
  51. free.freeBlock(b);
  52. }
  53. return c;
  54. }
  55. /** {@inheritDoc} */
  56. @Override
  57. public void clear() {
  58. head = null;
  59. free.clear();
  60. }
  61. @Override
  62. boolean everbodyHasFlag(int f) {
  63. for (Block b = head; b != null; b = b.next) {
  64. for (int i = b.headIndex; i < b.tailIndex; i++)
  65. if ((b.commits[i].flags & f) == 0)
  66. return false;
  67. }
  68. return true;
  69. }
  70. @Override
  71. boolean anybodyHasFlag(int f) {
  72. for (Block b = head; b != null; b = b.next) {
  73. for (int i = b.headIndex; i < b.tailIndex; i++)
  74. if ((b.commits[i].flags & f) != 0)
  75. return true;
  76. }
  77. return false;
  78. }
  79. /** {@inheritDoc} */
  80. @Override
  81. public String toString() {
  82. final StringBuilder s = new StringBuilder();
  83. for (Block q = head; q != null; q = q.next) {
  84. for (int i = q.headIndex; i < q.tailIndex; i++)
  85. describe(s, q.commits[i]);
  86. }
  87. return s.toString();
  88. }
  89. }