diff src/org/tmatesoft/hg/repo/Revlog.java @ 445:d0e5dc3cae6e smartgit3

Support for phases functionality from Mercurial 2.1
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 05 Jun 2012 20:50:06 +0200
parents 728708de3597
children 2e402c12ebc6
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/Revlog.java	Wed Mar 21 14:54:02 2012 +0100
+++ b/src/org/tmatesoft/hg/repo/Revlog.java	Tue Jun 05 20:50:06 2012 +0200
@@ -257,7 +257,7 @@
 	}
 	
 	@Experimental
-	public void walk(int start, int end, final Revlog.Inspector inspector) throws HgInvalidRevisionException, HgInvalidControlFileException {
+	public final void walk(int start, int end, final Revlog.Inspector inspector) throws HgInvalidRevisionException, HgInvalidControlFileException {
 		int lastRev = getLastRevision();
 		if (start == TIP) {
 			start = lastRev;
@@ -268,6 +268,11 @@
 		final RevisionInspector revisionInsp = Adaptable.Factory.getAdapter(inspector, RevisionInspector.class, null);
 		final ParentInspector parentInsp = Adaptable.Factory.getAdapter(inspector, ParentInspector.class, null);
 		final Nodeid[] allRevisions = parentInsp == null ? null : new Nodeid[end - start + 1]; 
+		if (parentInsp != null && start != 0) {
+			// e.g. start == 6, end == 7 and parentOf(start) == 5. allRevisions.length == 2, allRevisions[parentOf(start)] => AIOOBE 
+			throw new IllegalStateException("There's a defect in the code that doesn't allow walks other than from the very beginning");
+			// TestAuxUtilities#testRevlogInspectors
+		}
 
 		content.iterate(start, end, false, new RevlogStream.Inspector() {