All of lore.kernel.org
 help / color / mirror / Atom feed
* [EGIT PATCH1/2] fix-CommitTimeRevFilter-by-adding-a-Between-filter
@ 2009-06-15 21:35 Mark Struberg
  0 siblings, 0 replies; only message in thread
From: Mark Struberg @ 2009-06-15 21:35 UTC (permalink / raw)
  To: git


>From 0a5e2d469972791cdc2e1db00602142980050af8 Mon Sep 17 00:00:00 2001
From: Mark Struberg <struberg@yahoo.de>
Date: Mon, 15 Jun 2009 01:25:25 +0200
Subject: [PATCH] fix CommitTimeRevFilter by adding a Between filter subclass

---
 .../jgit/revwalk/filter/CommitTimeRevFilter.java   |   29 ++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/CommitTimeRevFilter.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/CommitTimeRevFilter.java
index a3751b8..0aaa78d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/CommitTimeRevFilter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/CommitTimeRevFilter.java
@@ -70,6 +70,18 @@ public static final RevFilter after(final Date ts) {
 		return new After(ts.getTime());
 	}
 
+	/**
+	 * Create a new filter to select commits after or equal a given date/time <code>since</code> 
+	 * and before or equal a given date/time <code>until</code>.
+	 * 
+	 * @param since the point in time to cut on.
+	 * @param until the point in time to cut off.
+	 * @return a new filter to select commits between the given date/times.
+	 */
+	public static final RevFilter between(final Date since, final Date until) {
+		return new Between(since.getTime(), until.getTime());
+	}
+
 	final int when;
 
 	CommitTimeRevFilter(final long ts) {
@@ -117,4 +129,21 @@ public boolean include(final RevWalk walker, final RevCommit cmit)
 			return true;
 		}
 	}
+
+	private static class Between extends CommitTimeRevFilter {
+		private final int until;
+
+		Between(final long since, final long until) {
+			super(since);
+			this.until = (int) (until / 1000); 
+		}
+
+		@Override
+		public boolean include(final RevWalk walker, final RevCommit cmit)
+				throws StopWalkException, MissingObjectException,
+				IncorrectObjectTypeException, IOException {
+			return cmit.getCommitTime() <= until && cmit.getCommitTime() >= when;
+		}
+	}
+
 }
-- 
1.6.0.6



      

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-15 21:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-15 21:35 [EGIT PATCH1/2] fix-CommitTimeRevFilter-by-adding-a-Between-filter Mark Struberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.