diff src/org/tmatesoft/hg/repo/HgDataFile.java @ 347:8da7ade36c57

Add specific IAE subclass to handle wrong (e.g. outdated after rollback) revisions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 22 Nov 2011 05:25:57 +0100
parents a674b8590362
children 5f9073eabf06
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgDataFile.java	Tue Nov 22 04:02:37 2011 +0100
+++ b/src/org/tmatesoft/hg/repo/HgDataFile.java	Tue Nov 22 05:25:57 2011 +0100
@@ -33,6 +33,7 @@
 
 import org.tmatesoft.hg.core.HgDataStreamException;
 import org.tmatesoft.hg.core.HgException;
+import org.tmatesoft.hg.core.HgInvalidRevisionException;
 import org.tmatesoft.hg.core.HgLogCommand;
 import org.tmatesoft.hg.core.Nodeid;
 import org.tmatesoft.hg.internal.DataAccess;
@@ -177,7 +178,7 @@
 //	}
 	
 	/*XXX not sure distinct method contentWithFilters() is the best way to do, perhaps, callers shall add filters themselves?*/
-	public void contentWithFilters(int revision, ByteChannel sink) throws HgDataStreamException, CancelledException {
+	public void contentWithFilters(int revision, ByteChannel sink) throws HgDataStreamException, CancelledException, HgInvalidRevisionException {
 		if (revision == WORKING_COPY) {
 			workingCopy(sink); // pass un-mangled sink
 		} else {
@@ -187,7 +188,7 @@
 
 	// for data files need to check heading of the file content for possible metadata
 	// @see http://mercurial.selenic.com/wiki/FileFormats#data.2BAC8-
-	public void content(int revision, ByteChannel sink) throws HgDataStreamException, CancelledException {
+	public void content(int revision, ByteChannel sink) throws HgDataStreamException, CancelledException, HgInvalidRevisionException {
 		if (revision == TIP) {
 			revision = getLastRevision();
 		}
@@ -198,7 +199,7 @@
 			return;
 		}
 		if (wrongLocalRevision(revision) || revision == BAD_REVISION) {
-			throw new IllegalArgumentException(String.valueOf(revision));
+			throw new HgInvalidRevisionException(revision);
 		}
 		if (sink == null) {
 			throw new IllegalArgumentException();
@@ -350,7 +351,7 @@
 		history(0, getLastRevision(), inspector);
 	}
 
-	public void history(int start, int end, HgChangelog.Inspector inspector) {
+	public void history(int start, int end, HgChangelog.Inspector inspector) throws HgInvalidRevisionException {
 		if (!exists()) {
 			throw new IllegalStateException("Can't get history of invalid repository file node"); 
 		}