diff src/org/tmatesoft/hg/core/HgCommitCommand.java @ 628:6526d8adbc0f

Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 22 May 2013 15:52:31 +0200
parents 5afc7eedb3dd
children b4242b7e7dfe
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgCommitCommand.java	Tue May 21 20:17:33 2013 +0200
+++ b/src/org/tmatesoft/hg/core/HgCommitCommand.java	Wed May 22 15:52:31 2013 +0200
@@ -30,6 +30,7 @@
 import org.tmatesoft.hg.repo.HgChangelog;
 import org.tmatesoft.hg.repo.HgDataFile;
 import org.tmatesoft.hg.repo.HgInternals;
+import org.tmatesoft.hg.repo.HgInvalidControlFileException;
 import org.tmatesoft.hg.repo.HgRepository;
 import org.tmatesoft.hg.repo.HgRuntimeException;
 import org.tmatesoft.hg.repo.HgStatusCollector.Record;
@@ -74,12 +75,17 @@
 	 * Tell if changes in the working directory constitute merge commit. May be invoked prior to (and independently from) {@link #execute()}
 	 * 
 	 * @return <code>true</code> if working directory changes are result of a merge
-	 * @throws HgException subclass thereof to indicate specific issue with the repository
+	 * @throws HgLibraryFailureException to indicate unexpected issue with the repository
+	 * @throws HgException subclass thereof to indicate other specific issue with repository state
 	 */
 	public boolean isMergeCommit() throws HgException {
-		int[] parents = new int[2];
-		detectParentFromDirstate(parents);
-		return parents[0] != NO_REVISION && parents[1] != NO_REVISION; 
+		try {
+			int[] parents = new int[2];
+			detectParentFromDirstate(parents);
+			return parents[0] != NO_REVISION && parents[1] != NO_REVISION;
+		} catch (HgRuntimeException ex) {
+			throw new HgLibraryFailureException(ex);
+		}
 	}
 
 	/**
@@ -152,7 +158,7 @@
 		return newRevision;
 	}
 
-	private String detectBranch() {
+	private String detectBranch() throws HgInvalidControlFileException {
 		return repo.getWorkingCopyBranchName();
 	}
 	
@@ -164,7 +170,7 @@
 		return new HgInternals(repo).getNextCommitUsername();
 	}
 
-	private void detectParentFromDirstate(int[] parents) {
+	private void detectParentFromDirstate(int[] parents) throws HgRuntimeException {
 		Pair<Nodeid, Nodeid> pn = repo.getWorkingCopyParents();
 		HgChangelog clog = repo.getChangelog();
 		parents[0] = pn.first().isNull() ? NO_REVISION : clog.getRevisionIndex(pn.first());