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.

RevFlag.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.text.MessageFormat;
  12. import org.eclipse.jgit.internal.JGitText;
  13. /**
  14. * Application level mark bit for {@link org.eclipse.jgit.revwalk.RevObject}s.
  15. * <p>
  16. * To create a flag use
  17. * {@link org.eclipse.jgit.revwalk.RevWalk#newFlag(String)}.
  18. */
  19. public class RevFlag {
  20. /**
  21. * Uninteresting by {@link RevWalk#markUninteresting(RevCommit)}.
  22. * <p>
  23. * We flag commits as uninteresting if the caller does not want commits
  24. * reachable from a commit to {@link RevWalk#markUninteresting(RevCommit)}.
  25. * This flag is always carried into the commit's parents and is a key part
  26. * of the "rev-list B --not A" feature; A is marked UNINTERESTING.
  27. * <p>
  28. * This is a static flag. Its RevWalk is not available.
  29. */
  30. public static final RevFlag UNINTERESTING = new StaticRevFlag(
  31. "UNINTERESTING", RevWalk.UNINTERESTING); //$NON-NLS-1$
  32. /**
  33. * Set on RevCommit instances added to {@link RevWalk#pending} queue.
  34. * <p>
  35. * We use this flag to avoid adding the same commit instance twice to our
  36. * queue, especially if we reached it by more than one path.
  37. * <p>
  38. * This is a static flag. Its RevWalk is not available.
  39. *
  40. * @since 3.0
  41. */
  42. public static final RevFlag SEEN = new StaticRevFlag("SEEN", RevWalk.SEEN); //$NON-NLS-1$
  43. final RevWalk walker;
  44. final String name;
  45. final int mask;
  46. RevFlag(RevWalk w, String n, int m) {
  47. walker = w;
  48. name = n;
  49. mask = m;
  50. }
  51. /**
  52. * Get the revision walk instance this flag was created from.
  53. *
  54. * @return the walker this flag was allocated out of, and belongs to.
  55. */
  56. public RevWalk getRevWalk() {
  57. return walker;
  58. }
  59. /** {@inheritDoc} */
  60. @Override
  61. public String toString() {
  62. return name;
  63. }
  64. static class StaticRevFlag extends RevFlag {
  65. StaticRevFlag(String n, int m) {
  66. super(null, n, m);
  67. }
  68. @Override
  69. public RevWalk getRevWalk() {
  70. throw new UnsupportedOperationException(MessageFormat.format(
  71. JGitText.get().isAStaticFlagAndHasNorevWalkInstance, toString()));
  72. }
  73. }
  74. }