changeset 364:ac8e1ce67730

Expose errors dealign with Mercurial internals with Exceptions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 09 Dec 2011 02:09:22 +0100
parents d9dfa9fe9cec
children 3572fcb06473
files src/org/tmatesoft/hg/core/ChangesetTransformer.java src/org/tmatesoft/hg/core/HgFileRevision.java
diffstat 2 files changed, 12 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/ChangesetTransformer.java	Fri Dec 09 02:08:09 2011 +0100
+++ b/src/org/tmatesoft/hg/core/ChangesetTransformer.java	Fri Dec 09 02:09:22 2011 +0100
@@ -30,7 +30,7 @@
 
 /**
  * Bridges {@link HgChangelog.RawChangeset} with high-level {@link HgChangeset} API
- * FIXME move to .internal
+ * FIXME move to .internal once access to package-local HgChangeset cons is resolved
  * 
  * @author Artem Tikhomirov
  * @author TMate Software Ltd.
--- a/src/org/tmatesoft/hg/core/HgFileRevision.java	Fri Dec 09 02:08:09 2011 +0100
+++ b/src/org/tmatesoft/hg/core/HgFileRevision.java	Fri Dec 09 02:09:22 2011 +0100
@@ -17,7 +17,6 @@
 package org.tmatesoft.hg.core;
 
 import org.tmatesoft.hg.repo.HgDataFile;
-import org.tmatesoft.hg.repo.HgInternals;
 import org.tmatesoft.hg.repo.HgRepository;
 import org.tmatesoft.hg.util.ByteChannel;
 import org.tmatesoft.hg.util.CancelledException;
@@ -58,10 +57,12 @@
 	public Path getPath() {
 		return path;
 	}
+
 	public Nodeid getRevision() {
 		return revision;
 	}
-	public boolean wasCopied() {
+
+	public boolean wasCopied() throws HgException {
 		if (isCopy == null) {
 			checkCopy();
 		}
@@ -70,7 +71,7 @@
 	/**
 	 * @return <code>null</code> if {@link #wasCopied()} is <code>false</code>, name of the copy source otherwise.
 	 */
-	public Path getOriginIfCopy() {
+	public Path getOriginIfCopy() throws HgException {
 		if (wasCopied()) {
 			return origin;
 		}
@@ -104,22 +105,15 @@
 		fn.contentWithFilters(localRevision, sink);
 	}
 
-	private void checkCopy() {
+	private void checkCopy() throws HgInvalidControlFileException, HgDataStreamException {
 		HgDataFile fn = repo.getFileNode(path);
-		try {
-			if (fn.isCopy()) {
-				if (fn.getRevision(0).equals(revision)) {
-					// this HgFileRevision represents first revision of the copy
-					isCopy = Boolean.TRUE;
-					origin = fn.getCopySourceName();
-					return;
-				}
+		if (fn.isCopy()) {
+			if (fn.getRevision(0).equals(revision)) {
+				// this HgFileRevision represents first revision of the copy
+				isCopy = Boolean.TRUE;
+				origin = fn.getCopySourceName();
+				return;
 			}
-		} catch (HgDataStreamException ex) {
-			// FIXME rather throw an exception than log silently
-			HgInternals.getContext(repo).getLog().error(getClass(), ex, null);
-		} catch (HgInvalidControlFileException ex) {
-			HgInternals.getContext(repo).getLog().error(getClass(), ex, null);
 		}
 		isCopy = Boolean.FALSE;
 	}