From 3b27268f49e27bad2b249d422eaff1319078d322 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 25 Apr 2008 03:08:02 -0400 Subject: [PATCH] Allow RevWalk users to ask for FIFO style ordering Some applications just want (or require) a FIFO style ordering when we walk commits. This is easier for us than date order, and is what we use by default in the queue when the sort order is NONE, but we shouldn't promise that. Instead we use a new RevSort value to enforce FIFO requirements. Signed-off-by: Shawn O. Pearce --- org.spearce.jgit/src/org/spearce/jgit/revwalk/RevSort.java | 11 +++++++++++ .../src/org/spearce/jgit/revwalk/StartGenerator.java | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevSort.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevSort.java index f2aede20..c43eb2ba 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevSort.java +++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevSort.java @@ -28,6 +28,17 @@ public enum RevSort { NONE, /** + * Maintain the order commits were marked as starting points. + *

+ * This strategy is largely a FIFO strategy; commits are enumerated in the + * order they were added to the RevWalk by the application. Parents not yet + * visited are added behind all commits already enqueued for visiting. + *

+ * This strategy should not be combined with {@link #COMMIT_TIME_DESC}. + */ + START_ORDER, + + /** * Sort by commit time, descending (newest first, oldest last). *

* This strategy can be combined with {@link #TOPO}. diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/StartGenerator.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/StartGenerator.java index 94d53238..9f273e82 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/StartGenerator.java +++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/StartGenerator.java @@ -66,7 +66,10 @@ class StartGenerator extends Generator { } int pendingOutputType = 0; - if (sort.contains(RevSort.COMMIT_TIME_DESC)) + if (sort.contains(RevSort.START_ORDER) && !(q instanceof FIFORevQueue)) + q = new FIFORevQueue(q); + if (sort.contains(RevSort.COMMIT_TIME_DESC) + && !(q instanceof DateRevQueue)) q = new DateRevQueue(q); if (tf != TreeFilter.ALL) { rf = AndRevFilter.create(rf, new RewriteTreeFilter(w, tf)); -- 2.11.4.GIT