git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [JGIT PATCH 00/12] Improve test coverage in revwalk
@ 2009-03-18  1:40 Shawn O. Pearce
  2009-03-18  1:40 ` [JGIT PATCH 01/12] Fix copyright year in revwalk test file headers Shawn O. Pearce
  2009-03-18  6:34 ` [JGIT PATCH 00/12] Improve test coverage in revwalk Robin Rosenberg
  0 siblings, 2 replies; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

Most of these patches are to improve the test coverage within the
revwalk package.


The last commit points out what I feared, which is that a RevWalk
with a PathFilter applied doesn't produce the same results that
git-core would produce in the same situation.  We're either missing
some functions necessary to implement it, or we flat out produce
a wrong graph in some cases.

The tests are commented out because JUnit doesn't have a notion of
"known broken".  But I did leave in TODO comments.  I'd like to
apply the test, and then work later to improve it, but I'm open
to suggestions.


Shawn O. Pearce (12):
  Fix copyright year in revwalk test file headers
  Mark non-overridable methods of RevObject final
  Change RevWalkTestCase to use RevCommit, not ObjectId
  Test that RevFilter.MERGE_BASE cannot use a TreeFilter
  Add unit tests for DateRevQueue
  Add unit tests for FIFORevQueue
  Add unit tests for LIFORevQueue
  Add unit tests for AbstractRevQueue.EMPTY_QUEUE
  Add tests for basic RevObject methods related to type, flags
  Add tests for ObjectWalk
  Add some basic logic tests for TreeFilter on RevWalk
  Implement git-core t/t6012-rev-list-simplify test case

 .../jgit/revwalk/AlwaysEmptyRevQueueTest.java      |   63 +++++++
 .../org/spearce/jgit/revwalk/DateRevQueueTest.java |  118 ++++++++++++
 .../org/spearce/jgit/revwalk/FIFORevQueueTest.java |   81 +++++++++
 .../org/spearce/jgit/revwalk/LIFORevQueueTest.java |   69 +++++++
 .../org/spearce/jgit/revwalk/ObjectWalkTest.java   |  190 ++++++++++++++++++++
 .../org/spearce/jgit/revwalk/RevFlagSetTest.java   |    2 +-
 .../org/spearce/jgit/revwalk/RevObjectTest.java    |  171 ++++++++++++++++++
 .../org/spearce/jgit/revwalk/RevQueueTestCase.java |   85 +++++++++
 .../org/spearce/jgit/revwalk/RevWalkCullTest.java  |   30 ++--
 .../spearce/jgit/revwalk/RevWalkFilterTest.java    |   93 +++++-----
 .../spearce/jgit/revwalk/RevWalkMergeBaseTest.java |   64 ++++---
 .../jgit/revwalk/RevWalkPathFilter1Test.java       |  176 ++++++++++++++++++
 .../jgit/revwalk/RevWalkPathFilter6012Test.java    |  162 +++++++++++++++++
 .../org/spearce/jgit/revwalk/RevWalkSortTest.java  |   66 ++++----
 .../org/spearce/jgit/revwalk/RevWalkTestCase.java  |  110 ++++++++++--
 .../org/spearce/jgit/revwalk/AbstractRevQueue.java |    2 +-
 .../org/spearce/jgit/revwalk/BlockRevQueue.java    |    2 +-
 .../src/org/spearce/jgit/revwalk/RevObject.java    |   20 +-
 18 files changed, 1353 insertions(+), 151 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/AlwaysEmptyRevQueueTest.java
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/DateRevQueueTest.java
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/FIFORevQueueTest.java
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/LIFORevQueueTest.java
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/ObjectWalkTest.java
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevObjectTest.java
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevQueueTestCase.java
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkPathFilter1Test.java
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkPathFilter6012Test.java

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [JGIT PATCH 01/12] Fix copyright year in revwalk test file headers
  2009-03-18  1:40 [JGIT PATCH 00/12] Improve test coverage in revwalk Shawn O. Pearce
@ 2009-03-18  1:40 ` Shawn O. Pearce
  2009-03-18  1:40   ` [JGIT PATCH 02/12] Mark non-overridable methods of RevObject final Shawn O. Pearce
  2009-03-18  6:34 ` [JGIT PATCH 00/12] Improve test coverage in revwalk Robin Rosenberg
  1 sibling, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

These were all created in 2009, not 2008.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/revwalk/RevFlagSetTest.java   |    2 +-
 .../org/spearce/jgit/revwalk/RevWalkCullTest.java  |    2 +-
 .../spearce/jgit/revwalk/RevWalkFilterTest.java    |    2 +-
 .../spearce/jgit/revwalk/RevWalkMergeBaseTest.java |    2 +-
 .../org/spearce/jgit/revwalk/RevWalkSortTest.java  |    2 +-
 .../org/spearce/jgit/revwalk/RevWalkTestCase.java  |    2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevFlagSetTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevFlagSetTest.java
index 76f3cbb..ff02d64 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevFlagSetTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevFlagSetTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2009, Google Inc.
  *
  * All rights reserved.
  *
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkCullTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkCullTest.java
index 93bd645..e734273 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkCullTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkCullTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2009, Google Inc.
  *
  * All rights reserved.
  *
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkFilterTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkFilterTest.java
index cf2975d..d079bdc 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkFilterTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkFilterTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2009, Google Inc.
  *
  * All rights reserved.
  *
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java
index b05e774..cec4e3f 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2009, Google Inc.
  *
  * All rights reserved.
  *
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkSortTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkSortTest.java
index 6f2eedc..3ed1565 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkSortTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkSortTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2009, Google Inc.
  *
  * All rights reserved.
  *
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
index bd696dd..a477be9 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2009, Google Inc.
  *
  * All rights reserved.
  *
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 02/12] Mark non-overridable methods of RevObject final
  2009-03-18  1:40 ` [JGIT PATCH 01/12] Fix copyright year in revwalk test file headers Shawn O. Pearce
@ 2009-03-18  1:40   ` Shawn O. Pearce
  2009-03-18  1:40     ` [JGIT PATCH 03/12] Change RevWalkTestCase to use RevCommit, not ObjectId Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

There isn't a huge benefit to allowing these methods to be overridden,
and subclasses might actually screw them up given that flags is only
visible within our package.  Mark them all final instead.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/revwalk/RevObject.java    |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObject.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObject.java
index 8c7cc23..e8fb29f 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObject.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObject.java
@@ -70,17 +70,17 @@ abstract void parse(RevWalk walk) throws MissingObjectException,
 	 * 
 	 * @return unique hash of this object.
 	 */
-	public ObjectId getId() {
+	public final ObjectId getId() {
 		return this;
 	}
 
 	@Override
-	public boolean equals(final ObjectId o) {
+	public final boolean equals(final ObjectId o) {
 		return this == o;
 	}
 
 	@Override
-	public boolean equals(final Object o) {
+	public final boolean equals(final Object o) {
 		return this == o;
 	}
 
@@ -91,7 +91,7 @@ public boolean equals(final Object o) {
 	 *            the flag to test.
 	 * @return true if the flag has been added to this object; false if not.
 	 */
-	public boolean has(final RevFlag flag) {
+	public final boolean has(final RevFlag flag) {
 		return (flags & flag.mask) != 0;
 	}
 
@@ -103,7 +103,7 @@ public boolean has(final RevFlag flag) {
 	 * @return true if any flag in the set has been added to this object; false
 	 *         if not.
 	 */
-	public boolean hasAny(final RevFlagSet set) {
+	public final boolean hasAny(final RevFlagSet set) {
 		return (flags & set.mask) != 0;
 	}
 
@@ -115,7 +115,7 @@ public boolean hasAny(final RevFlagSet set) {
 	 * @return true if all flags of the set have been added to this object;
 	 *         false if some or none have been added.
 	 */
-	public boolean hasAll(final RevFlagSet set) {
+	public final boolean hasAll(final RevFlagSet set) {
 		return (flags & set.mask) == set.mask;
 	}
 
@@ -127,7 +127,7 @@ public boolean hasAll(final RevFlagSet set) {
 	 * @param flag
 	 *            the flag to mark on this object, for later testing.
 	 */
-	public void add(final RevFlag flag) {
+	public final void add(final RevFlag flag) {
 		flags |= flag.mask;
 	}
 
@@ -137,7 +137,7 @@ public void add(final RevFlag flag) {
 	 * @param set
 	 *            the set of flags to mark on this object, for later testing.
 	 */
-	public void add(final RevFlagSet set) {
+	public final void add(final RevFlagSet set) {
 		flags |= set.mask;
 	}
 
@@ -149,7 +149,7 @@ public void add(final RevFlagSet set) {
 	 * @param flag
 	 *            the flag to remove from this object.
 	 */
-	public void remove(final RevFlag flag) {
+	public final void remove(final RevFlag flag) {
 		flags &= ~flag.mask;
 	}
 
@@ -159,7 +159,7 @@ public void remove(final RevFlag flag) {
 	 * @param set
 	 *            the flag to remove from this object.
 	 */
-	public void remove(final RevFlagSet set) {
+	public final void remove(final RevFlagSet set) {
 		flags &= ~set.mask;
 	}
 
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 03/12] Change RevWalkTestCase to use RevCommit, not ObjectId
  2009-03-18  1:40   ` [JGIT PATCH 02/12] Mark non-overridable methods of RevObject final Shawn O. Pearce
@ 2009-03-18  1:40     ` Shawn O. Pearce
  2009-03-18  1:40       ` [JGIT PATCH 04/12] Test that RevFilter.MERGE_BASE cannot use a TreeFilter Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

We build a RevWalk once per test, and only execute a single traversal
in that test run.  Its more clear to use the RevCommit type from that
object pool to represent a commit entity than the generic ObjectId.

When creating a new commit we allocate its RevCommit from the pool,
but we delay parsing until as late as necessary.  This is needed for
at least one test where it validates whether or not the parents of a
commit were allocated after traversal finishes.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/revwalk/RevWalkCullTest.java  |   28 +++---
 .../spearce/jgit/revwalk/RevWalkFilterTest.java    |   91 ++++++++++----------
 .../spearce/jgit/revwalk/RevWalkMergeBaseTest.java |   45 +++++-----
 .../org/spearce/jgit/revwalk/RevWalkSortTest.java  |   64 +++++++-------
 .../org/spearce/jgit/revwalk/RevWalkTestCase.java  |   30 +++---
 5 files changed, 126 insertions(+), 132 deletions(-)

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkCullTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkCullTest.java
index e734273..2f61598 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkCullTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkCullTest.java
@@ -37,8 +37,6 @@
 
 package org.spearce.jgit.revwalk;
 
-import org.spearce.jgit.lib.ObjectId;
-
 public class RevWalkCullTest extends RevWalkTestCase {
 	public void testProperlyCullAllAncestors1() throws Exception {
 		// Credit goes to Junio C Hamano <gitster@pobox.com> for this
@@ -46,10 +44,10 @@ public void testProperlyCullAllAncestors1() throws Exception {
 		//
 		// We induce a clock skew so two is dated before one.
 		//
-		final ObjectId a = commit();
-		final ObjectId b = commit(-2400, a);
-		final ObjectId c = commit(b);
-		final ObjectId d = commit(c);
+		final RevCommit a = commit();
+		final RevCommit b = commit(-2400, a);
+		final RevCommit c = commit(b);
+		final RevCommit d = commit(c);
 
 		markStart(a);
 		markUninteresting(d);
@@ -60,11 +58,11 @@ public void testProperlyCullAllAncestors2() throws Exception {
 		// Despite clock skew on c1 being very old it should not
 		// produce, neither should a or b, or any part of that chain.
 		//
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c1 = commit(-5, b);
-		final ObjectId c2 = commit(10, b);
-		final ObjectId d = commit(c1, c2);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c1 = commit(-5, b);
+		final RevCommit c2 = commit(10, b);
+		final RevCommit d = commit(c1, c2);
 
 		markStart(d);
 		markUninteresting(c1);
@@ -74,14 +72,14 @@ public void testProperlyCullAllAncestors2() throws Exception {
 	}
 
 	public void testProperlyCullAllAncestors_LongHistory() throws Exception {
-		final ObjectId a = commit();
-		ObjectId b = commit(a);
+		final RevCommit a = commit();
+		RevCommit b = commit(a);
 		for (int i = 0; i < 24; i++) {
 			b = commit(b);
 			if ((i & 2) == 0)
 				markUninteresting(b);
 		}
-		final ObjectId c = commit(b);
+		final RevCommit c = commit(b);
 
 		markStart(c);
 		markUninteresting(b);
@@ -91,6 +89,6 @@ public void testProperlyCullAllAncestors_LongHistory() throws Exception {
 		// We should have aborted before we got back so far that "a"
 		// would be parsed. Thus, its parents shouldn't be allocated.
 		//
-		assertNull(rw.lookupCommit(a).parents);
+		assertNull(a.parents);
 	}
 }
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkFilterTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkFilterTest.java
index d079bdc..6a26d2e 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkFilterTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkFilterTest.java
@@ -42,7 +42,6 @@
 import org.spearce.jgit.errors.IncorrectObjectTypeException;
 import org.spearce.jgit.errors.MissingObjectException;
 import org.spearce.jgit.errors.StopWalkException;
-import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.revwalk.filter.AndRevFilter;
 import org.spearce.jgit.revwalk.filter.NotRevFilter;
 import org.spearce.jgit.revwalk.filter.OrRevFilter;
@@ -52,9 +51,9 @@
 	private static final MyAll MY_ALL = new MyAll();
 
 	public void testFilter_ALL() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(RevFilter.ALL);
 		markStart(c);
@@ -65,9 +64,9 @@ public void testFilter_ALL() throws Exception {
 	}
 
 	public void testFilter_Negate_ALL() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(RevFilter.ALL.negate());
 		markStart(c);
@@ -75,9 +74,9 @@ public void testFilter_Negate_ALL() throws Exception {
 	}
 
 	public void testFilter_NOT_ALL() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(NotRevFilter.create(RevFilter.ALL));
 		markStart(c);
@@ -85,9 +84,9 @@ public void testFilter_NOT_ALL() throws Exception {
 	}
 
 	public void testFilter_NONE() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(RevFilter.NONE);
 		markStart(c);
@@ -95,9 +94,9 @@ public void testFilter_NONE() throws Exception {
 	}
 
 	public void testFilter_NOT_NONE() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(NotRevFilter.create(RevFilter.NONE));
 		markStart(c);
@@ -108,9 +107,9 @@ public void testFilter_NOT_NONE() throws Exception {
 	}
 
 	public void testFilter_ALL_And_NONE() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(AndRevFilter.create(RevFilter.ALL, RevFilter.NONE));
 		markStart(c);
@@ -118,9 +117,9 @@ public void testFilter_ALL_And_NONE() throws Exception {
 	}
 
 	public void testFilter_NONE_And_ALL() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(AndRevFilter.create(RevFilter.NONE, RevFilter.ALL));
 		markStart(c);
@@ -128,9 +127,9 @@ public void testFilter_NONE_And_ALL() throws Exception {
 	}
 
 	public void testFilter_ALL_Or_NONE() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(OrRevFilter.create(RevFilter.ALL, RevFilter.NONE));
 		markStart(c);
@@ -141,9 +140,9 @@ public void testFilter_ALL_Or_NONE() throws Exception {
 	}
 
 	public void testFilter_NONE_Or_ALL() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(OrRevFilter.create(RevFilter.NONE, RevFilter.ALL));
 		markStart(c);
@@ -154,9 +153,9 @@ public void testFilter_NONE_Or_ALL() throws Exception {
 	}
 
 	public void testFilter_MY_ALL_And_NONE() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(AndRevFilter.create(MY_ALL, RevFilter.NONE));
 		markStart(c);
@@ -164,9 +163,9 @@ public void testFilter_MY_ALL_And_NONE() throws Exception {
 	}
 
 	public void testFilter_NONE_And_MY_ALL() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(AndRevFilter.create(RevFilter.NONE, MY_ALL));
 		markStart(c);
@@ -174,9 +173,9 @@ public void testFilter_NONE_And_MY_ALL() throws Exception {
 	}
 
 	public void testFilter_MY_ALL_Or_NONE() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(OrRevFilter.create(MY_ALL, RevFilter.NONE));
 		markStart(c);
@@ -187,9 +186,9 @@ public void testFilter_MY_ALL_Or_NONE() throws Exception {
 	}
 
 	public void testFilter_NONE_Or_MY_ALL() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
 
 		rw.setRevFilter(OrRevFilter.create(RevFilter.NONE, MY_ALL));
 		markStart(c);
@@ -200,12 +199,12 @@ public void testFilter_NONE_Or_MY_ALL() throws Exception {
 	}
 
 	public void testFilter_NO_MERGES() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c1 = commit(b);
-		final ObjectId c2 = commit(b);
-		final ObjectId d = commit(c1, c2);
-		final ObjectId e = commit(d);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c1 = commit(b);
+		final RevCommit c2 = commit(b);
+		final RevCommit d = commit(c1, c2);
+		final RevCommit e = commit(d);
 
 		rw.setRevFilter(RevFilter.NO_MERGES);
 		markStart(e);
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java
index cec4e3f..fc1a37c 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java
@@ -37,13 +37,12 @@
 
 package org.spearce.jgit.revwalk;
 
-import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.revwalk.filter.RevFilter;
 
 public class RevWalkMergeBaseTest extends RevWalkTestCase {
 	public void testNone() throws Exception {
-		final ObjectId c1 = commit(commit(commit()));
-		final ObjectId c2 = commit(commit(commit()));
+		final RevCommit c1 = commit(commit(commit()));
+		final RevCommit c2 = commit(commit(commit()));
 
 		rw.setRevFilter(RevFilter.MERGE_BASE);
 		markStart(c1);
@@ -52,10 +51,10 @@ public void testNone() throws Exception {
 	}
 
 	public void testSimple() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c1 = commit(commit(commit(commit(commit(b)))));
-		final ObjectId c2 = commit(commit(commit(commit(commit(b)))));
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c1 = commit(commit(commit(commit(commit(b)))));
+		final RevCommit c2 = commit(commit(commit(commit(commit(b)))));
 
 		rw.setRevFilter(RevFilter.MERGE_BASE);
 		markStart(c1);
@@ -65,11 +64,11 @@ public void testSimple() throws Exception {
 	}
 
 	public void testMultipleHeads_SameBase1() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c1 = commit(commit(commit(commit(commit(b)))));
-		final ObjectId c2 = commit(commit(commit(commit(commit(b)))));
-		final ObjectId c3 = commit(commit(commit(b)));
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c1 = commit(commit(commit(commit(commit(b)))));
+		final RevCommit c2 = commit(commit(commit(commit(commit(b)))));
+		final RevCommit c3 = commit(commit(commit(b)));
 
 		rw.setRevFilter(RevFilter.MERGE_BASE);
 		markStart(c1);
@@ -80,12 +79,12 @@ public void testMultipleHeads_SameBase1() throws Exception {
 	}
 
 	public void testMultipleHeads_SameBase2() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
-		final ObjectId d1 = commit(commit(commit(commit(commit(b)))));
-		final ObjectId d2 = commit(commit(commit(commit(commit(c)))));
-		final ObjectId d3 = commit(commit(commit(c)));
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
+		final RevCommit d1 = commit(commit(commit(commit(commit(b)))));
+		final RevCommit d2 = commit(commit(commit(commit(commit(c)))));
+		final RevCommit d3 = commit(commit(commit(c)));
 
 		rw.setRevFilter(RevFilter.MERGE_BASE);
 		markStart(d1);
@@ -101,11 +100,11 @@ public void testCrissCross() throws Exception {
 		// clean merge base for d,e as they each merged the parents b,c
 		// in different orders.
 		//
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(a);
-		final ObjectId d = commit(b, c);
-		final ObjectId e = commit(c, b);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(a);
+		final RevCommit d = commit(b, c);
+		final RevCommit e = commit(c, b);
 
 		rw.setRevFilter(RevFilter.MERGE_BASE);
 		markStart(d);
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkSortTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkSortTest.java
index 3ed1565..7435197 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkSortTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkSortTest.java
@@ -37,14 +37,12 @@
 
 package org.spearce.jgit.revwalk;
 
-import org.spearce.jgit.lib.ObjectId;
-
 public class RevWalkSortTest extends RevWalkTestCase {
 	public void testSort_Default() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(1, a);
-		final ObjectId c = commit(1, b);
-		final ObjectId d = commit(1, c);
+		final RevCommit a = commit();
+		final RevCommit b = commit(1, a);
+		final RevCommit c = commit(1, b);
+		final RevCommit d = commit(1, c);
 
 		markStart(d);
 		assertCommit(d, rw.next());
@@ -55,10 +53,10 @@ public void testSort_Default() throws Exception {
 	}
 
 	public void testSort_COMMIT_TIME_DESC() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
-		final ObjectId d = commit(c);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
+		final RevCommit d = commit(c);
 
 		rw.sort(RevSort.COMMIT_TIME_DESC);
 		markStart(d);
@@ -70,10 +68,10 @@ public void testSort_COMMIT_TIME_DESC() throws Exception {
 	}
 
 	public void testSort_REVERSE() throws Exception {
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(b);
-		final ObjectId d = commit(c);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(b);
+		final RevCommit d = commit(c);
 
 		rw.sort(RevSort.REVERSE);
 		markStart(d);
@@ -88,10 +86,10 @@ public void testSort_COMMIT_TIME_DESC_OutOfOrder1() throws Exception {
 		// Despite being out of order time-wise, a strand-of-pearls must
 		// still maintain topological order.
 		//
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c = commit(-5, b);
-		final ObjectId d = commit(10, c);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c = commit(-5, b);
+		final RevCommit d = commit(10, c);
 		assertTrue(parse(a).getCommitTime() < parse(d).getCommitTime());
 		assertTrue(parse(c).getCommitTime() < parse(b).getCommitTime());
 
@@ -107,11 +105,11 @@ public void testSort_COMMIT_TIME_DESC_OutOfOrder1() throws Exception {
 	public void testSort_COMMIT_TIME_DESC_OutOfOrder2() throws Exception {
 		// c1 is back dated before its parent.
 		//
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c1 = commit(-5, b);
-		final ObjectId c2 = commit(10, b);
-		final ObjectId d = commit(c1, c2);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c1 = commit(-5, b);
+		final RevCommit c2 = commit(10, b);
+		final RevCommit d = commit(c1, c2);
 
 		rw.sort(RevSort.COMMIT_TIME_DESC);
 		markStart(d);
@@ -126,11 +124,11 @@ public void testSort_COMMIT_TIME_DESC_OutOfOrder2() throws Exception {
 	public void testSort_TOPO() throws Exception {
 		// c1 is back dated before its parent.
 		//
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c1 = commit(-5, b);
-		final ObjectId c2 = commit(10, b);
-		final ObjectId d = commit(c1, c2);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c1 = commit(-5, b);
+		final RevCommit c2 = commit(10, b);
+		final RevCommit d = commit(c1, c2);
 
 		rw.sort(RevSort.TOPO);
 		markStart(d);
@@ -145,11 +143,11 @@ public void testSort_TOPO() throws Exception {
 	public void testSort_TOPO_REVERSE() throws Exception {
 		// c1 is back dated before its parent.
 		//
-		final ObjectId a = commit();
-		final ObjectId b = commit(a);
-		final ObjectId c1 = commit(-5, b);
-		final ObjectId c2 = commit(10, b);
-		final ObjectId d = commit(c1, c2);
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		final RevCommit c1 = commit(-5, b);
+		final RevCommit c2 = commit(10, b);
+		final RevCommit d = commit(c1, c2);
 
 		rw.sort(RevSort.TOPO);
 		rw.sort(RevSort.REVERSE, true);
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
index a477be9..f83be8d 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
@@ -40,7 +40,6 @@
 import java.util.Date;
 
 import org.spearce.jgit.lib.Commit;
-import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.lib.ObjectWriter;
 import org.spearce.jgit.lib.PersonIdent;
 import org.spearce.jgit.lib.RepositoryTestCase;
@@ -50,7 +49,7 @@
 public abstract class RevWalkTestCase extends RepositoryTestCase {
 	protected ObjectWriter ow;
 
-	protected ObjectId emptyTree;
+	protected RevTree emptyTree;
 
 	protected long nowTick;
 
@@ -59,20 +58,20 @@
 	public void setUp() throws Exception {
 		super.setUp();
 		ow = new ObjectWriter(db);
-		emptyTree = ow.writeTree(new Tree(db));
-		nowTick = 1236977987000L;
 		rw = new RevWalk(db);
+		emptyTree = rw.parseTree(ow.writeTree(new Tree(db)));
+		nowTick = 1236977987000L;
 	}
 
 	protected void tick(final int secDelta) {
 		nowTick += secDelta * 1000L;
 	}
 
-	protected ObjectId commit(final ObjectId... parents) throws Exception {
+	protected RevCommit commit(final RevCommit... parents) throws Exception {
 		return commit(1, parents);
 	}
 
-	protected ObjectId commit(final int secDelta, final ObjectId... parents)
+	protected RevCommit commit(final int secDelta, final RevCommit... parents)
 			throws Exception {
 		tick(secDelta);
 		final Commit c = new Commit(db);
@@ -81,22 +80,23 @@ protected ObjectId commit(final int secDelta, final ObjectId... parents)
 		c.setAuthor(new PersonIdent(jauthor, new Date(nowTick)));
 		c.setCommitter(new PersonIdent(jcommitter, new Date(nowTick)));
 		c.setMessage("");
-		return ow.writeCommit(c);
+		return rw.lookupCommit(ow.writeCommit(c));
 	}
 
-	protected RevCommit parse(final ObjectId commitId) throws Exception {
-		return rw.parseCommit(commitId);
+	protected <T extends RevObject> T parse(final T t) throws Exception {
+		rw.parse(t);
+		return t;
 	}
 
-	protected void markStart(final ObjectId commitId) throws Exception {
-		rw.markStart(parse(commitId));
+	protected void markStart(final RevCommit commit) throws Exception {
+		rw.markStart(commit);
 	}
 
-	protected void markUninteresting(final ObjectId commitId) throws Exception {
-		rw.markUninteresting(parse(commitId));
+	protected void markUninteresting(final RevCommit commit) throws Exception {
+		rw.markUninteresting(commit);
 	}
 
-	protected void assertCommit(final ObjectId commitId, final RevCommit commit) {
-		assertEquals(commitId.name(), commit != null ? commit.name() : null);
+	protected void assertCommit(final RevCommit exp, final RevCommit act) {
+		assertSame(exp, act);
 	}
 }
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 04/12] Test that RevFilter.MERGE_BASE cannot use a TreeFilter
  2009-03-18  1:40     ` [JGIT PATCH 03/12] Change RevWalkTestCase to use RevCommit, not ObjectId Shawn O. Pearce
@ 2009-03-18  1:40       ` Shawn O. Pearce
  2009-03-18  1:40         ` [JGIT PATCH 05/12] Add unit tests for DateRevQueue Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

Only TreeFilter.ALL is permitted right now when computing a merge
base, as the generator pipeline doesn't support parent rewrites
during a merge base computation.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../spearce/jgit/revwalk/RevWalkMergeBaseTest.java |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java
index fc1a37c..c8fdf5e 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkMergeBaseTest.java
@@ -38,6 +38,7 @@
 package org.spearce.jgit.revwalk;
 
 import org.spearce.jgit.revwalk.filter.RevFilter;
+import org.spearce.jgit.treewalk.filter.TreeFilter;
 
 public class RevWalkMergeBaseTest extends RevWalkTestCase {
 	public void testNone() throws Exception {
@@ -50,6 +51,22 @@ public void testNone() throws Exception {
 		assertNull(rw.next());
 	}
 
+	public void testDisallowTreeFilter() throws Exception {
+		final RevCommit c1 = commit();
+		final RevCommit c2 = commit();
+
+		rw.setRevFilter(RevFilter.MERGE_BASE);
+		rw.setTreeFilter(TreeFilter.ANY_DIFF);
+		markStart(c1);
+		markStart(c2);
+		try {
+			assertNull(rw.next());
+			fail("did not throw IllegalStateException");
+		} catch (IllegalStateException ise) {
+			// expected result
+		}
+	}
+
 	public void testSimple() throws Exception {
 		final RevCommit a = commit();
 		final RevCommit b = commit(a);
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 05/12] Add unit tests for DateRevQueue
  2009-03-18  1:40       ` [JGIT PATCH 04/12] Test that RevFilter.MERGE_BASE cannot use a TreeFilter Shawn O. Pearce
@ 2009-03-18  1:40         ` Shawn O. Pearce
  2009-03-18  1:40           ` [JGIT PATCH 06/12] Add unit tests for FIFORevQueue Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/revwalk/DateRevQueueTest.java |  118 ++++++++++++++++++++
 .../org/spearce/jgit/revwalk/RevQueueTestCase.java |   85 ++++++++++++++
 2 files changed, 203 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/DateRevQueueTest.java
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevQueueTestCase.java

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/DateRevQueueTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/DateRevQueueTest.java
new file mode 100644
index 0000000..c29fd55
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/DateRevQueueTest.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.revwalk;
+
+public class DateRevQueueTest extends RevQueueTestCase<DateRevQueue> {
+	protected DateRevQueue create() {
+		return new DateRevQueue();
+	}
+
+	public void testEmpty() throws Exception {
+		super.testEmpty();
+		assertNull(q.peek());
+		assertEquals(Generator.SORT_COMMIT_TIME_DESC, q.outputType());
+	}
+
+	public void testCloneEmpty() throws Exception {
+		q = new DateRevQueue(AbstractRevQueue.EMPTY_QUEUE);
+		assertNull(q.next());
+	}
+
+	public void testInsertOutOfOrder() throws Exception {
+		final RevCommit a = parse(commit());
+		final RevCommit b = parse(commit(10, a));
+		final RevCommit c1 = parse(commit(5, b));
+		final RevCommit c2 = parse(commit(-50, b));
+
+		q.add(c2);
+		q.add(a);
+		q.add(b);
+		q.add(c1);
+
+		assertCommit(c1, q.next());
+		assertCommit(b, q.next());
+		assertCommit(a, q.next());
+		assertCommit(c2, q.next());
+		assertNull(q.next());
+	}
+
+	public void testInsertTie() throws Exception {
+		final RevCommit a = parse(commit());
+		final RevCommit b = parse(commit(0, a));
+		{
+			q = create();
+			q.add(a);
+			q.add(b);
+
+			assertCommit(a, q.next());
+			assertCommit(b, q.next());
+			assertNull(q.next());
+		}
+		{
+			q = create();
+			q.add(b);
+			q.add(a);
+
+			assertCommit(b, q.next());
+			assertCommit(a, q.next());
+			assertNull(q.next());
+		}
+	}
+
+	public void testCloneFIFO() throws Exception {
+		final RevCommit a = parse(commit());
+		final RevCommit b = parse(commit(200, a));
+		final RevCommit c = parse(commit(200, b));
+
+		final FIFORevQueue src = new FIFORevQueue();
+		src.add(a);
+		src.add(b);
+		src.add(c);
+
+		q = new DateRevQueue(src);
+		assertFalse(q.everbodyHasFlag(RevWalk.UNINTERESTING));
+		assertFalse(q.anybodyHasFlag(RevWalk.UNINTERESTING));
+		assertCommit(c, q.peek());
+		assertCommit(c, q.peek());
+
+		assertCommit(c, q.next());
+		assertCommit(b, q.next());
+		assertCommit(a, q.next());
+		assertNull(q.next());
+	}
+}
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevQueueTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevQueueTestCase.java
new file mode 100644
index 0000000..8b379d6
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevQueueTestCase.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.revwalk;
+
+public abstract class RevQueueTestCase<T extends AbstractRevQueue> extends
+		RevWalkTestCase {
+	protected T q;
+
+	public void setUp() throws Exception {
+		super.setUp();
+		q = create();
+	}
+
+	protected abstract T create();
+
+	public void testEmpty() throws Exception {
+		assertNull(q.next());
+		assertTrue(q.everbodyHasFlag(RevWalk.UNINTERESTING));
+		assertFalse(q.anybodyHasFlag(RevWalk.UNINTERESTING));
+	}
+
+	public void testClear() throws Exception {
+		final RevCommit a = parse(commit());
+		final RevCommit b = parse(commit(a));
+
+		q.add(a);
+		q.add(b);
+		q.clear();
+		assertNull(q.next());
+	}
+
+	public void testHasFlags() throws Exception {
+		final RevCommit a = parse(commit());
+		final RevCommit b = parse(commit(a));
+
+		q.add(a);
+		q.add(b);
+
+		assertFalse(q.everbodyHasFlag(RevWalk.UNINTERESTING));
+		assertFalse(q.anybodyHasFlag(RevWalk.UNINTERESTING));
+
+		a.flags |= RevWalk.UNINTERESTING;
+		assertFalse(q.everbodyHasFlag(RevWalk.UNINTERESTING));
+		assertTrue(q.anybodyHasFlag(RevWalk.UNINTERESTING));
+
+		b.flags |= RevWalk.UNINTERESTING;
+		assertTrue(q.everbodyHasFlag(RevWalk.UNINTERESTING));
+		assertTrue(q.anybodyHasFlag(RevWalk.UNINTERESTING));
+	}
+}
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 06/12] Add unit tests for FIFORevQueue
  2009-03-18  1:40         ` [JGIT PATCH 05/12] Add unit tests for DateRevQueue Shawn O. Pearce
@ 2009-03-18  1:40           ` Shawn O. Pearce
  2009-03-18  1:40             ` [JGIT PATCH 07/12] Add unit tests for LIFORevQueue Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/revwalk/FIFORevQueueTest.java |   81 ++++++++++++++++++++
 .../org/spearce/jgit/revwalk/BlockRevQueue.java    |    2 +-
 2 files changed, 82 insertions(+), 1 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/FIFORevQueueTest.java

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/FIFORevQueueTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/FIFORevQueueTest.java
new file mode 100644
index 0000000..99ee031
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/FIFORevQueueTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.revwalk;
+
+import java.util.ArrayList;
+
+public class FIFORevQueueTest extends RevQueueTestCase<FIFORevQueue> {
+	protected FIFORevQueue create() {
+		return new FIFORevQueue();
+	}
+
+	public void testEmpty() throws Exception {
+		super.testEmpty();
+		assertEquals(0, q.outputType());
+	}
+
+	public void testCloneEmpty() throws Exception {
+		q = new FIFORevQueue(AbstractRevQueue.EMPTY_QUEUE);
+		assertNull(q.next());
+	}
+
+	public void testAddLargeBlocks() throws Exception {
+		final ArrayList<RevCommit> lst = new ArrayList<RevCommit>();
+		for (int i = 0; i < 3 * BlockRevQueue.Block.BLOCK_SIZE; i++) {
+			final RevCommit c = commit();
+			lst.add(c);
+			q.add(c);
+		}
+		for (int i = 0; i < lst.size(); i++)
+			assertSame(lst.get(i), q.next());
+	}
+
+	public void testUnpopAtFront() throws Exception {
+		final RevCommit a = commit();
+		final RevCommit b = commit();
+		final RevCommit c = commit();
+
+		q.add(a);
+		q.unpop(b);
+		q.unpop(c);
+
+		assertSame(c, q.next());
+		assertSame(b, q.next());
+		assertSame(a, q.next());
+	}
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/BlockRevQueue.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/BlockRevQueue.java
index 9660de8..8c0e46d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/BlockRevQueue.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/BlockRevQueue.java
@@ -104,7 +104,7 @@ void clear() {
 	}
 
 	static final class Block {
-		private static final int BLOCK_SIZE = 256;
+		static final int BLOCK_SIZE = 256;
 
 		/** Next block in our chain of blocks; null if we are the last. */
 		Block next;
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 07/12] Add unit tests for LIFORevQueue
  2009-03-18  1:40           ` [JGIT PATCH 06/12] Add unit tests for FIFORevQueue Shawn O. Pearce
@ 2009-03-18  1:40             ` Shawn O. Pearce
  2009-03-18  1:40               ` [JGIT PATCH 08/12] Add unit tests for AbstractRevQueue.EMPTY_QUEUE Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/revwalk/LIFORevQueueTest.java |   69 ++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/LIFORevQueueTest.java

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/LIFORevQueueTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/LIFORevQueueTest.java
new file mode 100644
index 0000000..b1ce5fa
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/LIFORevQueueTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.revwalk;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+public class LIFORevQueueTest extends RevQueueTestCase<LIFORevQueue> {
+	protected LIFORevQueue create() {
+		return new LIFORevQueue();
+	}
+
+	public void testEmpty() throws Exception {
+		super.testEmpty();
+		assertEquals(0, q.outputType());
+	}
+
+	public void testCloneEmpty() throws Exception {
+		q = new LIFORevQueue(AbstractRevQueue.EMPTY_QUEUE);
+		assertNull(q.next());
+	}
+
+	public void testAddLargeBlocks() throws Exception {
+		final ArrayList<RevCommit> lst = new ArrayList<RevCommit>();
+		for (int i = 0; i < 3 * BlockRevQueue.Block.BLOCK_SIZE; i++) {
+			final RevCommit c = commit();
+			lst.add(c);
+			q.add(c);
+		}
+		Collections.reverse(lst);
+		for (int i = 0; i < lst.size(); i++)
+			assertSame(lst.get(i), q.next());
+	}
+}
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 08/12] Add unit tests for AbstractRevQueue.EMPTY_QUEUE
  2009-03-18  1:40             ` [JGIT PATCH 07/12] Add unit tests for LIFORevQueue Shawn O. Pearce
@ 2009-03-18  1:40               ` Shawn O. Pearce
  2009-03-18  1:40                 ` [JGIT PATCH 09/12] Add tests for basic RevObject methods related to type, flags Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

Also fix anybodyHasFlag() to return false, as the queue is empty,
and thus nobody has that flag.  This matches the behavior of the
other queue types.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../jgit/revwalk/AlwaysEmptyRevQueueTest.java      |   63 ++++++++++++++++++++
 .../org/spearce/jgit/revwalk/AbstractRevQueue.java |    2 +-
 2 files changed, 64 insertions(+), 1 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/AlwaysEmptyRevQueueTest.java

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/AlwaysEmptyRevQueueTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/AlwaysEmptyRevQueueTest.java
new file mode 100644
index 0000000..94edd0a
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/AlwaysEmptyRevQueueTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.revwalk;
+
+public class AlwaysEmptyRevQueueTest extends RevWalkTestCase {
+	private final AbstractRevQueue q = AbstractRevQueue.EMPTY_QUEUE;
+
+	public void testEmpty() throws Exception {
+		assertNull(q.next());
+		assertTrue(q.everbodyHasFlag(RevWalk.UNINTERESTING));
+		assertFalse(q.anybodyHasFlag(RevWalk.UNINTERESTING));
+		assertEquals(0, q.outputType());
+	}
+
+	public void testClear() throws Exception {
+		q.clear();
+		testEmpty();
+	}
+
+	public void testAddFails() throws Exception {
+		try {
+			q.add(commit());
+			fail("Did not throw UnsupportedOperationException");
+		} catch (UnsupportedOperationException e) {
+			// expected result
+		}
+	}
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/AbstractRevQueue.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/AbstractRevQueue.java
index 5bb969d..9a6bf81 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/AbstractRevQueue.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/AbstractRevQueue.java
@@ -133,7 +133,7 @@ public RevCommit next() {
 
 		@Override
 		boolean anybodyHasFlag(int f) {
-			return true;
+			return false;
 		}
 
 		@Override
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 09/12] Add tests for basic RevObject methods related to type, flags
  2009-03-18  1:40               ` [JGIT PATCH 08/12] Add unit tests for AbstractRevQueue.EMPTY_QUEUE Shawn O. Pearce
@ 2009-03-18  1:40                 ` Shawn O. Pearce
  2009-03-18  1:40                   ` [JGIT PATCH 10/12] Add tests for ObjectWalk Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/revwalk/RevObjectTest.java    |  171 ++++++++++++++++++++
 .../org/spearce/jgit/revwalk/RevWalkTestCase.java  |   18 ++
 2 files changed, 189 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevObjectTest.java

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevObjectTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevObjectTest.java
new file mode 100644
index 0000000..0eaafbf
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevObjectTest.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.revwalk;
+
+import org.spearce.jgit.lib.AnyObjectId;
+import org.spearce.jgit.lib.Constants;
+
+public class RevObjectTest extends RevWalkTestCase {
+	public void testId() throws Exception {
+		final RevCommit a = commit();
+		assertSame(a, a.getId());
+	}
+
+	public void testEqualsIsIdentity() throws Exception {
+		final RevCommit a1 = commit();
+		final RevCommit b1 = commit();
+
+		assertTrue(a1.equals(a1));
+		assertTrue(a1.equals((Object) a1));
+		assertFalse(a1.equals(b1));
+
+		assertFalse(a1.equals(a1.copy()));
+		assertFalse(a1.equals((Object) a1.copy()));
+		assertFalse(a1.equals(""));
+
+		final RevWalk rw2 = new RevWalk(db);
+		final RevCommit a2 = rw2.parseCommit(a1);
+		final RevCommit b2 = rw2.parseCommit(b1);
+		assertNotSame(a1, a2);
+		assertNotSame(b1, b2);
+
+		assertFalse(a1.equals(a2));
+		assertFalse(b1.equals(b2));
+
+		assertEquals(a1.hashCode(), a2.hashCode());
+		assertEquals(b1.hashCode(), b2.hashCode());
+
+		assertTrue(AnyObjectId.equals(a1, a2));
+		assertTrue(AnyObjectId.equals(b1, b2));
+	}
+
+	public void testRevObjectTypes() throws Exception {
+		assertEquals(Constants.OBJ_TREE, emptyTree.getType());
+		assertEquals(Constants.OBJ_COMMIT, commit().getType());
+		assertEquals(Constants.OBJ_BLOB, blob("").getType());
+		assertEquals(Constants.OBJ_TAG, tag("emptyTree", emptyTree).getType());
+	}
+
+	public void testHasRevFlag() throws Exception {
+		final RevCommit a = commit();
+		assertFalse(a.has(RevFlag.UNINTERESTING));
+		a.flags |= RevWalk.UNINTERESTING;
+		assertTrue(a.has(RevFlag.UNINTERESTING));
+	}
+
+	public void testHasAnyFlag() throws Exception {
+		final RevCommit a = commit();
+		final RevFlag flag1 = rw.newFlag("flag1");
+		final RevFlag flag2 = rw.newFlag("flag2");
+		final RevFlagSet s = new RevFlagSet();
+		s.add(flag1);
+		s.add(flag2);
+
+		assertFalse(a.hasAny(s));
+		a.flags |= flag1.mask;
+		assertTrue(a.hasAny(s));
+	}
+
+	public void testHasAllFlag() throws Exception {
+		final RevCommit a = commit();
+		final RevFlag flag1 = rw.newFlag("flag1");
+		final RevFlag flag2 = rw.newFlag("flag2");
+		final RevFlagSet s = new RevFlagSet();
+		s.add(flag1);
+		s.add(flag2);
+
+		assertFalse(a.hasAll(s));
+		a.flags |= flag1.mask;
+		assertFalse(a.hasAll(s));
+		a.flags |= flag2.mask;
+		assertTrue(a.hasAll(s));
+	}
+
+	public void testAddRevFlag() throws Exception {
+		final RevCommit a = commit();
+		final RevFlag flag1 = rw.newFlag("flag1");
+		final RevFlag flag2 = rw.newFlag("flag2");
+		assertEquals(0, a.flags);
+
+		a.add(flag1);
+		assertEquals(flag1.mask, a.flags);
+
+		a.add(flag2);
+		assertEquals(flag1.mask | flag2.mask, a.flags);
+	}
+
+	public void testAddRevFlagSet() throws Exception {
+		final RevCommit a = commit();
+		final RevFlag flag1 = rw.newFlag("flag1");
+		final RevFlag flag2 = rw.newFlag("flag2");
+		final RevFlagSet s = new RevFlagSet();
+		s.add(flag1);
+		s.add(flag2);
+
+		assertEquals(0, a.flags);
+
+		a.add(s);
+		assertEquals(flag1.mask | flag2.mask, a.flags);
+	}
+
+	public void testRemoveRevFlag() throws Exception {
+		final RevCommit a = commit();
+		final RevFlag flag1 = rw.newFlag("flag1");
+		final RevFlag flag2 = rw.newFlag("flag2");
+		a.add(flag1);
+		a.add(flag2);
+		assertEquals(flag1.mask | flag2.mask, a.flags);
+		a.remove(flag2);
+		assertEquals(flag1.mask, a.flags);
+	}
+
+	public void testRemoveRevFlagSet() throws Exception {
+		final RevCommit a = commit();
+		final RevFlag flag1 = rw.newFlag("flag1");
+		final RevFlag flag2 = rw.newFlag("flag2");
+		final RevFlag flag3 = rw.newFlag("flag3");
+		final RevFlagSet s = new RevFlagSet();
+		s.add(flag1);
+		s.add(flag2);
+		a.add(flag3);
+		a.add(s);
+		assertEquals(flag1.mask | flag2.mask | flag3.mask, a.flags);
+		a.remove(s);
+		assertEquals(flag3.mask, a.flags);
+	}
+}
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
index f83be8d..501aa13 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
@@ -40,9 +40,11 @@
 import java.util.Date;
 
 import org.spearce.jgit.lib.Commit;
+import org.spearce.jgit.lib.Constants;
 import org.spearce.jgit.lib.ObjectWriter;
 import org.spearce.jgit.lib.PersonIdent;
 import org.spearce.jgit.lib.RepositoryTestCase;
+import org.spearce.jgit.lib.Tag;
 import org.spearce.jgit.lib.Tree;
 
 /** Support for tests of the {@link RevWalk} class. */
@@ -67,6 +69,11 @@ protected void tick(final int secDelta) {
 		nowTick += secDelta * 1000L;
 	}
 
+	protected RevBlob blob(final String content) throws Exception {
+		return rw.lookupBlob(ow.writeBlob(content
+				.getBytes(Constants.CHARACTER_ENCODING)));
+	}
+
 	protected RevCommit commit(final RevCommit... parents) throws Exception {
 		return commit(1, parents);
 	}
@@ -83,6 +90,17 @@ protected RevCommit commit(final int secDelta, final RevCommit... parents)
 		return rw.lookupCommit(ow.writeCommit(c));
 	}
 
+	protected RevTag tag(final String name, final RevObject dst)
+			throws Exception {
+		final Tag t = new Tag(db);
+		t.setType(Constants.typeString(dst.getType()));
+		t.setObjId(dst.toObjectId());
+		t.setTag(name);
+		t.setTagger(new PersonIdent(jcommitter, new Date(nowTick)));
+		t.setMessage("");
+		return (RevTag) rw.lookupAny(ow.writeTag(t), Constants.OBJ_TAG);
+	}
+
 	protected <T extends RevObject> T parse(final T t) throws Exception {
 		rw.parse(t);
 		return t;
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 10/12] Add tests for ObjectWalk
  2009-03-18  1:40                 ` [JGIT PATCH 09/12] Add tests for basic RevObject methods related to type, flags Shawn O. Pearce
@ 2009-03-18  1:40                   ` Shawn O. Pearce
  2009-03-18  1:40                     ` [JGIT PATCH 11/12] Add some basic logic tests for TreeFilter on RevWalk Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

This covers most of the common operations in an ObjectWalk, such
as culling off a common base and any trees reachable from that
common base.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/revwalk/ObjectWalkTest.java   |  190 ++++++++++++++++++++
 .../org/spearce/jgit/revwalk/RevWalkTestCase.java  |   64 +++++++-
 2 files changed, 251 insertions(+), 3 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/ObjectWalkTest.java

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/ObjectWalkTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/ObjectWalkTest.java
new file mode 100644
index 0000000..86f4277
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/ObjectWalkTest.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.revwalk;
+
+public class ObjectWalkTest extends RevWalkTestCase {
+	protected ObjectWalk objw;
+
+	protected RevWalk createRevWalk() {
+		return objw = new ObjectWalk(db);
+	}
+
+	public void testNoCommits() throws Exception {
+		assertNull(objw.next());
+		assertNull(objw.nextObject());
+	}
+
+	public void testTwoCommitsEmptyTree() throws Exception {
+		final RevCommit a = commit();
+		final RevCommit b = commit(a);
+		markStart(b);
+
+		assertCommit(b, objw.next());
+		assertCommit(a, objw.next());
+		assertNull(objw.next());
+
+		assertSame(emptyTree, objw.nextObject());
+		assertNull(objw.nextObject());
+	}
+
+	public void testOneCommitOneTreeTwoBlob() throws Exception {
+		final RevBlob f0 = blob("0");
+		final RevBlob f1 = blob("1");
+		final RevTree t = tree(file("0", f0), file("1", f1), file("2", f1));
+		final RevCommit a = commit(t);
+		markStart(a);
+
+		assertCommit(a, objw.next());
+		assertNull(objw.next());
+
+		assertSame(t, objw.nextObject());
+		assertSame(f0, objw.nextObject());
+		assertSame(f1, objw.nextObject());
+		assertNull(objw.nextObject());
+	}
+
+	public void testTwoCommitTwoTreeTwoBlob() throws Exception {
+		final RevBlob f0 = blob("0");
+		final RevBlob f1 = blob("1");
+		final RevBlob f2 = blob("0v2");
+		final RevTree ta = tree(file("0", f0), file("1", f1), file("2", f1));
+		final RevTree tb = tree(file("0", f2), file("1", f1), file("2", f1));
+		final RevCommit a = commit(ta);
+		final RevCommit b = commit(tb, a);
+		markStart(b);
+
+		assertCommit(b, objw.next());
+		assertCommit(a, objw.next());
+		assertNull(objw.next());
+
+		assertSame(tb, objw.nextObject());
+		assertSame(f2, objw.nextObject());
+		assertSame(f1, objw.nextObject());
+
+		assertSame(ta, objw.nextObject());
+		assertSame(f0, objw.nextObject());
+
+		assertNull(objw.nextObject());
+	}
+
+	public void testTwoCommitDeepTree1() throws Exception {
+		final RevBlob f0 = blob("0");
+		final RevBlob f1 = blob("0v2");
+		final RevTree ta = tree(file("a/b/0", f0));
+		final RevTree tb = tree(file("a/b/1", f1));
+		final RevCommit a = commit(ta);
+		final RevCommit b = commit(tb, a);
+		markStart(b);
+
+		assertCommit(b, objw.next());
+		assertCommit(a, objw.next());
+		assertNull(objw.next());
+
+		assertSame(tb, objw.nextObject());
+		assertSame(get(tb, "a"), objw.nextObject());
+		assertSame(get(tb, "a/b"), objw.nextObject());
+		assertSame(f1, objw.nextObject());
+
+		assertSame(ta, objw.nextObject());
+		assertSame(get(ta, "a"), objw.nextObject());
+		assertSame(get(ta, "a/b"), objw.nextObject());
+		assertSame(f0, objw.nextObject());
+
+		assertNull(objw.nextObject());
+	}
+
+	public void testTwoCommitDeepTree2() throws Exception {
+		final RevBlob f1 = blob("1");
+		final RevTree ta = tree(file("a/b/0", f1), file("a/c/q", f1));
+		final RevTree tb = tree(file("a/b/1", f1), file("a/c/q", f1));
+		final RevCommit a = commit(ta);
+		final RevCommit b = commit(tb, a);
+		markStart(b);
+
+		assertCommit(b, objw.next());
+		assertCommit(a, objw.next());
+		assertNull(objw.next());
+
+		assertSame(tb, objw.nextObject());
+		assertSame(get(tb, "a"), objw.nextObject());
+		assertSame(get(tb, "a/b"), objw.nextObject());
+		assertSame(f1, objw.nextObject());
+		assertSame(get(tb, "a/c"), objw.nextObject());
+
+		assertSame(ta, objw.nextObject());
+		assertSame(get(ta, "a"), objw.nextObject());
+		assertSame(get(ta, "a/b"), objw.nextObject());
+
+		assertNull(objw.nextObject());
+	}
+
+	public void testCull() throws Exception {
+		final RevBlob f1 = blob("1");
+		final RevBlob f2 = blob("2");
+		final RevBlob f3 = blob("3");
+		final RevBlob f4 = blob("4");
+
+		final RevTree ta = tree(file("a/1", f1), file("c/3", f3));
+		final RevCommit a = commit(ta);
+
+		final RevTree tb = tree(file("a/1", f2), file("c/3", f3));
+		final RevCommit b1 = commit(tb, a);
+		final RevCommit b2 = commit(tb, b1);
+
+		final RevTree tc = tree(file("a/1", f4));
+		final RevCommit c1 = commit(tc, a);
+		final RevCommit c2 = commit(tc, c1);
+
+		markStart(b2);
+		markUninteresting(c2);
+
+		assertCommit(b2, objw.next());
+		assertCommit(b1, objw.next());
+		assertNull(objw.next());
+
+		assertTrue(a.has(RevFlag.UNINTERESTING));
+		assertTrue(ta.has(RevFlag.UNINTERESTING));
+		assertTrue(f1.has(RevFlag.UNINTERESTING));
+		assertTrue(f3.has(RevFlag.UNINTERESTING));
+
+		assertSame(tb, objw.nextObject());
+		assertSame(get(tb, "a"), objw.nextObject());
+		assertSame(f2, objw.nextObject());
+		assertNull(objw.nextObject());
+	}
+}
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
index 501aa13..0a1e7b8 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java
@@ -37,15 +37,23 @@
 
 package org.spearce.jgit.revwalk;
 
+import java.util.Collections;
 import java.util.Date;
 
+import org.spearce.jgit.dircache.DirCache;
+import org.spearce.jgit.dircache.DirCacheBuilder;
+import org.spearce.jgit.dircache.DirCacheEntry;
 import org.spearce.jgit.lib.Commit;
 import org.spearce.jgit.lib.Constants;
+import org.spearce.jgit.lib.FileMode;
+import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.lib.ObjectWriter;
 import org.spearce.jgit.lib.PersonIdent;
 import org.spearce.jgit.lib.RepositoryTestCase;
 import org.spearce.jgit.lib.Tag;
 import org.spearce.jgit.lib.Tree;
+import org.spearce.jgit.treewalk.TreeWalk;
+import org.spearce.jgit.treewalk.filter.PathFilterGroup;
 
 /** Support for tests of the {@link RevWalk} class. */
 public abstract class RevWalkTestCase extends RepositoryTestCase {
@@ -60,11 +68,15 @@
 	public void setUp() throws Exception {
 		super.setUp();
 		ow = new ObjectWriter(db);
-		rw = new RevWalk(db);
+		rw = createRevWalk();
 		emptyTree = rw.parseTree(ow.writeTree(new Tree(db)));
 		nowTick = 1236977987000L;
 	}
 
+	protected RevWalk createRevWalk() {
+		return new RevWalk(db);
+	}
+
 	protected void tick(final int secDelta) {
 		nowTick += secDelta * 1000L;
 	}
@@ -74,15 +86,61 @@ protected RevBlob blob(final String content) throws Exception {
 				.getBytes(Constants.CHARACTER_ENCODING)));
 	}
 
+	protected DirCacheEntry file(final String path, final RevBlob blob)
+			throws Exception {
+		final DirCacheEntry e = new DirCacheEntry(path);
+		e.setFileMode(FileMode.REGULAR_FILE);
+		e.setObjectId(blob);
+		return e;
+	}
+
+	protected RevTree tree(final DirCacheEntry... entries) throws Exception {
+		final DirCache dc = DirCache.newInCore();
+		final DirCacheBuilder b = dc.builder();
+		for (final DirCacheEntry e : entries)
+			b.add(e);
+		b.finish();
+		return rw.lookupTree(dc.writeTree(ow));
+	}
+
+	protected RevObject get(final RevTree tree, final String path)
+			throws Exception {
+		final TreeWalk tw = new TreeWalk(db);
+		tw.setFilter(PathFilterGroup.createFromStrings(Collections
+				.singleton(path)));
+		tw.reset(tree);
+		while (tw.next()) {
+			if (tw.isSubtree() && !path.equals(tw.getPathString())) {
+				tw.enterSubtree();
+				continue;
+			}
+			final ObjectId entid = tw.getObjectId(0);
+			final FileMode entmode = tw.getFileMode(0);
+			return rw.lookupAny(entid, entmode.getObjectType());
+		}
+		fail("Can't find " + path + " in tree " + tree.name());
+		return null; // never reached.
+	}
+
 	protected RevCommit commit(final RevCommit... parents) throws Exception {
-		return commit(1, parents);
+		return commit(1, emptyTree, parents);
+	}
+
+	protected RevCommit commit(final RevTree tree, final RevCommit... parents)
+			throws Exception {
+		return commit(1, tree, parents);
 	}
 
 	protected RevCommit commit(final int secDelta, final RevCommit... parents)
 			throws Exception {
+		return commit(secDelta, emptyTree, parents);
+	}
+
+	protected RevCommit commit(final int secDelta, final RevTree tree,
+			final RevCommit... parents) throws Exception {
 		tick(secDelta);
 		final Commit c = new Commit(db);
-		c.setTreeId(emptyTree);
+		c.setTreeId(tree);
 		c.setParentIds(parents);
 		c.setAuthor(new PersonIdent(jauthor, new Date(nowTick)));
 		c.setCommitter(new PersonIdent(jcommitter, new Date(nowTick)));
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 11/12] Add some basic logic tests for TreeFilter on RevWalk
  2009-03-18  1:40                   ` [JGIT PATCH 10/12] Add tests for ObjectWalk Shawn O. Pearce
@ 2009-03-18  1:40                     ` Shawn O. Pearce
  2009-03-18  1:40                       ` [JGIT PATCH 12/12] Implement git-core t/t6012-rev-list-simplify test case Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../jgit/revwalk/RevWalkPathFilter1Test.java       |  176 ++++++++++++++++++++
 1 files changed, 176 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkPathFilter1Test.java

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkPathFilter1Test.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkPathFilter1Test.java
new file mode 100644
index 0000000..c74ab80
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkPathFilter1Test.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.revwalk;
+
+import java.util.Collections;
+
+import org.spearce.jgit.treewalk.filter.AndTreeFilter;
+import org.spearce.jgit.treewalk.filter.PathFilterGroup;
+import org.spearce.jgit.treewalk.filter.TreeFilter;
+
+public class RevWalkPathFilter1Test extends RevWalkTestCase {
+	protected void filter(final String path) {
+		rw.setTreeFilter(AndTreeFilter.create(PathFilterGroup
+				.createFromStrings(Collections.singleton(path)),
+				TreeFilter.ANY_DIFF));
+	}
+
+	public void testEmpty_EmptyTree() throws Exception {
+		final RevCommit a = commit();
+		filter("a");
+		markStart(a);
+		assertNull(rw.next());
+	}
+
+	public void testEmpty_NoMatch() throws Exception {
+		final RevCommit a = commit(tree(file("0", blob("0"))));
+		filter("a");
+		markStart(a);
+		assertNull(rw.next());
+	}
+
+	public void testSimple1() throws Exception {
+		final RevCommit a = commit(tree(file("0", blob("0"))));
+		filter("0");
+		markStart(a);
+		assertCommit(a, rw.next());
+		assertNull(rw.next());
+	}
+
+	public void testEdits_MatchNone() throws Exception {
+		final RevCommit a = commit(tree(file("0", blob("a"))));
+		final RevCommit b = commit(tree(file("0", blob("b"))), a);
+		final RevCommit c = commit(tree(file("0", blob("c"))), b);
+		final RevCommit d = commit(tree(file("0", blob("d"))), c);
+		filter("a");
+		markStart(d);
+		assertNull(rw.next());
+	}
+
+	public void testEdits_MatchAll() throws Exception {
+		final RevCommit a = commit(tree(file("0", blob("a"))));
+		final RevCommit b = commit(tree(file("0", blob("b"))), a);
+		final RevCommit c = commit(tree(file("0", blob("c"))), b);
+		final RevCommit d = commit(tree(file("0", blob("d"))), c);
+		filter("0");
+		markStart(d);
+		assertCommit(d, rw.next());
+		assertCommit(c, rw.next());
+		assertCommit(b, rw.next());
+		assertCommit(a, rw.next());
+		assertNull(rw.next());
+	}
+
+	public void testStringOfPearls_FilePath1() throws Exception {
+		final RevCommit a = commit(tree(file("d/f", blob("a"))));
+		final RevCommit b = commit(tree(file("d/f", blob("a"))), a);
+		final RevCommit c = commit(tree(file("d/f", blob("b"))), b);
+		filter("d/f");
+		markStart(c);
+
+		assertCommit(c, rw.next());
+		assertEquals(1, c.getParentCount());
+		assertCommit(a, c.getParent(0)); // b was skipped
+
+		assertCommit(a, rw.next());
+		assertEquals(0, a.getParentCount());
+		assertNull(rw.next());
+	}
+
+	public void testStringOfPearls_FilePath2() throws Exception {
+		final RevCommit a = commit(tree(file("d/f", blob("a"))));
+		final RevCommit b = commit(tree(file("d/f", blob("a"))), a);
+		final RevCommit c = commit(tree(file("d/f", blob("b"))), b);
+		final RevCommit d = commit(tree(file("d/f", blob("b"))), c);
+		filter("d/f");
+		markStart(d);
+
+		// d was skipped
+		assertCommit(c, rw.next());
+		assertEquals(1, c.getParentCount());
+		assertCommit(a, c.getParent(0)); // b was skipped
+
+		assertCommit(a, rw.next());
+		assertEquals(0, a.getParentCount());
+		assertNull(rw.next());
+	}
+
+	public void testStringOfPearls_DirPath2() throws Exception {
+		final RevCommit a = commit(tree(file("d/f", blob("a"))));
+		final RevCommit b = commit(tree(file("d/f", blob("a"))), a);
+		final RevCommit c = commit(tree(file("d/f", blob("b"))), b);
+		final RevCommit d = commit(tree(file("d/f", blob("b"))), c);
+		filter("d");
+		markStart(d);
+
+		// d was skipped
+		assertCommit(c, rw.next());
+		assertEquals(1, c.getParentCount());
+		assertCommit(a, c.getParent(0)); // b was skipped
+
+		assertCommit(a, rw.next());
+		assertEquals(0, a.getParentCount());
+		assertNull(rw.next());
+	}
+
+	public void testStringOfPearls_FilePath3() throws Exception {
+		final RevCommit a = commit(tree(file("d/f", blob("a"))));
+		final RevCommit b = commit(tree(file("d/f", blob("a"))), a);
+		final RevCommit c = commit(tree(file("d/f", blob("b"))), b);
+		final RevCommit d = commit(tree(file("d/f", blob("b"))), c);
+		final RevCommit e = commit(tree(file("d/f", blob("b"))), d);
+		final RevCommit f = commit(tree(file("d/f", blob("b"))), e);
+		final RevCommit g = commit(tree(file("d/f", blob("b"))), f);
+		final RevCommit h = commit(tree(file("d/f", blob("b"))), g);
+		final RevCommit i = commit(tree(file("d/f", blob("c"))), h);
+		filter("d/f");
+		markStart(i);
+
+		assertCommit(i, rw.next());
+		assertEquals(1, i.getParentCount());
+		assertCommit(c, i.getParent(0)); // h..d was skipped
+
+		assertCommit(c, rw.next());
+		assertEquals(1, c.getParentCount());
+		assertCommit(a, c.getParent(0)); // b was skipped
+
+		assertCommit(a, rw.next());
+		assertEquals(0, a.getParentCount());
+		assertNull(rw.next());
+	}
+}
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [JGIT PATCH 12/12] Implement git-core t/t6012-rev-list-simplify test case
  2009-03-18  1:40                     ` [JGIT PATCH 11/12] Add some basic logic tests for TreeFilter on RevWalk Shawn O. Pearce
@ 2009-03-18  1:40                       ` Shawn O. Pearce
  0 siblings, 0 replies; 15+ messages in thread
From: Shawn O. Pearce @ 2009-03-18  1:40 UTC (permalink / raw
  To: Robin Rosenberg; +Cc: git

This test case provides a known graph and results that git-core has
been producing since Aug 3, 2008.  Half of the test is commented out
as JGit does not produce the correct results, or does not support a
flag necessary to indicate how the results should be determined.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---

 As I said in the series cover letter, this test is more busted
 then correct.  I'm quite sure the test is right, and the JGit
 library is wrong.

 .../jgit/revwalk/RevWalkPathFilter6012Test.java    |  162 ++++++++++++++++++++
 1 files changed, 162 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkPathFilter6012Test.java

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkPathFilter6012Test.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkPathFilter6012Test.java
new file mode 100644
index 0000000..b2fdb16
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkPathFilter6012Test.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.revwalk;
+
+import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.HashMap;
+
+import org.spearce.jgit.treewalk.filter.AndTreeFilter;
+import org.spearce.jgit.treewalk.filter.PathFilterGroup;
+import org.spearce.jgit.treewalk.filter.TreeFilter;
+
+// Note: Much of this test case is broken as it depends upon
+// the graph applying topological sorting *before* doing merge
+// simplification.  It also depends upon a difference between
+// full history and non-full history for a path, something we
+// don't quite yet have a distiction for in JGit.
+//
+public class RevWalkPathFilter6012Test extends RevWalkTestCase {
+	private static final String pA = "pA", pF = "pF", pE = "pE";
+
+	private RevCommit a, b, c, d, e, f, g, h, i;
+
+	private HashMap<RevCommit, String> byName;
+
+	public void setUp() throws Exception {
+		super.setUp();
+
+		// Test graph was stolen from git-core t6012-rev-list-simplify
+		// (by Junio C Hamano in 65347030590bcc251a9ff2ed96487a0f1b9e9fa8)
+		//
+		final RevBlob zF = blob("zF");
+		final RevBlob zH = blob("zH");
+		final RevBlob zI = blob("zI");
+		final RevBlob zS = blob("zS");
+		final RevBlob zY = blob("zY");
+
+		a = commit(tree(file(pF, zH)));
+		b = commit(tree(file(pF, zI)), a);
+		c = commit(tree(file(pF, zI)), a);
+		d = commit(tree(file(pA, zS), file(pF, zI)), c);
+		parse(d);
+		e = commit(d.getTree(), d, b);
+		f = commit(tree(file(pA, zS), file(pE, zY), file(pF, zI)), e);
+		parse(f);
+		g = commit(tree(file(pE, zY), file(pF, zI)), b);
+		h = commit(f.getTree(), g, f);
+		i = commit(tree(file(pA, zS), file(pE, zY), file(pF, zF)), h);
+
+		byName = new HashMap<RevCommit, String>();
+		for (Field z : RevWalkPathFilter6012Test.class.getDeclaredFields()) {
+			if (z.getType() == RevCommit.class)
+				byName.put((RevCommit) z.get(this), z.getName());
+		}
+	}
+
+	protected void check(final RevCommit... order) throws Exception {
+		markStart(i);
+		final StringBuilder act = new StringBuilder();
+		for (final RevCommit z : rw) {
+			final String name = byName.get(z);
+			assertNotNull(name);
+			act.append(name);
+			act.append(' ');
+		}
+		final StringBuilder exp = new StringBuilder();
+		for (final RevCommit z : order) {
+			final String name = byName.get(z);
+			assertNotNull(name);
+			exp.append(name);
+			exp.append(' ');
+		}
+		assertEquals(exp.toString(), act.toString());
+	}
+
+	protected void filter(final String path) {
+		rw.setTreeFilter(AndTreeFilter.create(PathFilterGroup
+				.createFromStrings(Collections.singleton(path)),
+				TreeFilter.ANY_DIFF));
+	}
+
+	public void test1() throws Exception {
+		// TODO --full-history
+		check(i, h, g, f, e, d, c, b, a);
+	}
+
+	public void test2() throws Exception {
+		// TODO --full-history
+		filter(pF);
+		// TODO fix broken test
+		// check(i, h, e, c, b, a);
+	}
+
+	public void test3() throws Exception {
+		// TODO --full-history
+		rw.sort(RevSort.TOPO);
+		filter(pF);
+		// TODO fix broken test
+		// check(i, h, e, c, b, a);
+	}
+
+	public void test4() throws Exception {
+		// TODO --full-history
+		rw.sort(RevSort.COMMIT_TIME_DESC);
+		filter(pF);
+		// TODO fix broken test
+		// check(i, h, e, c, b, a);
+	}
+
+	public void test5() throws Exception {
+		// TODO --simplify-merges
+		filter(pF);
+		// TODO fix broken test
+		// check(i, e, c, b, a);
+	}
+
+	public void test6() throws Exception {
+		filter(pF);
+		check(i, b, a);
+	}
+
+	public void test7() throws Exception {
+		rw.sort(RevSort.TOPO);
+		filter(pF);
+		check(i, b, a);
+	}
+}
-- 
1.6.2.1.286.g8173

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [JGIT PATCH 00/12] Improve test coverage in revwalk
  2009-03-18  1:40 [JGIT PATCH 00/12] Improve test coverage in revwalk Shawn O. Pearce
  2009-03-18  1:40 ` [JGIT PATCH 01/12] Fix copyright year in revwalk test file headers Shawn O. Pearce
@ 2009-03-18  6:34 ` Robin Rosenberg
  2009-03-18  9:21   ` Robin Rosenberg
  1 sibling, 1 reply; 15+ messages in thread
From: Robin Rosenberg @ 2009-03-18  6:34 UTC (permalink / raw
  To: Shawn O. Pearce; +Cc: git

onsdag 18 mars 2009 02:40:39 skrev "Shawn O. Pearce" <spearce@spearce.org>:
> Most of these patches are to improve the test coverage within the
> revwalk package.
> 
> 
> The last commit points out what I feared, which is that a RevWalk
> with a PathFilter applied doesn't produce the same results that
> git-core would produce in the same situation.  We're either missing
> some functions necessary to implement it, or we flat out produce
> a wrong graph in some cases.
> 
> The tests are commented out because JUnit doesn't have a notion of
> "known broken".  But I did leave in TODO comments.  I'd like to
> apply the test, and then work later to improve it, but I'm open
> to suggestions.

If we'd switch to JUnit4/TestNG we could abuse the expected exception
annotation.

-- robin

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [JGIT PATCH 00/12] Improve test coverage in revwalk
  2009-03-18  6:34 ` [JGIT PATCH 00/12] Improve test coverage in revwalk Robin Rosenberg
@ 2009-03-18  9:21   ` Robin Rosenberg
  0 siblings, 0 replies; 15+ messages in thread
From: Robin Rosenberg @ 2009-03-18  9:21 UTC (permalink / raw
  To: Shawn O. Pearce; +Cc: git

onsdag 18 mars 2009 07:34:59 skrev Robin Rosenberg <robin.rosenberg.lists@dewire.com>:
> onsdag 18 mars 2009 02:40:39 skrev "Shawn O. Pearce" <spearce@spearce.org>:
> > The tests are commented out because JUnit doesn't have a notion of
> > "known broken".  But I did leave in TODO comments.  I'd like to
> > apply the test, and then work later to improve it, but I'm open
> > to suggestions.
> 
> If we'd switch to JUnit4/TestNG we could abuse the expected exception
> annotation.

..or the  @Ignore annotation

-- robin

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2009-03-18  9:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-18  1:40 [JGIT PATCH 00/12] Improve test coverage in revwalk Shawn O. Pearce
2009-03-18  1:40 ` [JGIT PATCH 01/12] Fix copyright year in revwalk test file headers Shawn O. Pearce
2009-03-18  1:40   ` [JGIT PATCH 02/12] Mark non-overridable methods of RevObject final Shawn O. Pearce
2009-03-18  1:40     ` [JGIT PATCH 03/12] Change RevWalkTestCase to use RevCommit, not ObjectId Shawn O. Pearce
2009-03-18  1:40       ` [JGIT PATCH 04/12] Test that RevFilter.MERGE_BASE cannot use a TreeFilter Shawn O. Pearce
2009-03-18  1:40         ` [JGIT PATCH 05/12] Add unit tests for DateRevQueue Shawn O. Pearce
2009-03-18  1:40           ` [JGIT PATCH 06/12] Add unit tests for FIFORevQueue Shawn O. Pearce
2009-03-18  1:40             ` [JGIT PATCH 07/12] Add unit tests for LIFORevQueue Shawn O. Pearce
2009-03-18  1:40               ` [JGIT PATCH 08/12] Add unit tests for AbstractRevQueue.EMPTY_QUEUE Shawn O. Pearce
2009-03-18  1:40                 ` [JGIT PATCH 09/12] Add tests for basic RevObject methods related to type, flags Shawn O. Pearce
2009-03-18  1:40                   ` [JGIT PATCH 10/12] Add tests for ObjectWalk Shawn O. Pearce
2009-03-18  1:40                     ` [JGIT PATCH 11/12] Add some basic logic tests for TreeFilter on RevWalk Shawn O. Pearce
2009-03-18  1:40                       ` [JGIT PATCH 12/12] Implement git-core t/t6012-rev-list-simplify test case Shawn O. Pearce
2009-03-18  6:34 ` [JGIT PATCH 00/12] Improve test coverage in revwalk Robin Rosenberg
2009-03-18  9:21   ` Robin Rosenberg

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).