diff src/org/tmatesoft/hg/repo/HgDirstate.java @ 421:fdd7d756dea0 v0.8.5

Allow IOException from DataAccess methods for subclasses with non-trivial implementations, to avoid exception dumps when inapropriate
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 22 Mar 2012 23:09:11 +0100
parents 528b6780a8bd
children 9c9c442b5f2e
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgDirstate.java	Thu Mar 22 22:56:01 2012 +0100
+++ b/src/org/tmatesoft/hg/repo/HgDirstate.java	Thu Mar 22 23:09:11 2012 +0100
@@ -87,15 +87,16 @@
 			return;
 		}
 		DataAccess da = repo.getDataAccess().create(dirstateFile);
-		if (da.isEmpty()) {
-			return;
-		}
-		// not sure linked is really needed here, just for ease of debug
-		normal = new LinkedHashMap<Path, Record>();
-		added = new LinkedHashMap<Path, Record>();
-		removed = new LinkedHashMap<Path, Record>();
-		merged = new LinkedHashMap<Path, Record>();
 		try {
+			if (da.isEmpty()) {
+				return;
+			}
+			// not sure linked is really needed here, just for ease of debug
+			normal = new LinkedHashMap<Path, Record>();
+			added = new LinkedHashMap<Path, Record>();
+			removed = new LinkedHashMap<Path, Record>();
+			merged = new LinkedHashMap<Path, Record>();
+			
 			parents = internalReadParents(da);
 			// hg init; hg up produces an empty repository where dirstate has parents (40 bytes) only
 			while (!da.isEmpty()) {
@@ -179,10 +180,10 @@
 			return new Pair<Nodeid,Nodeid>(NULL, NULL);
 		}
 		DataAccess da = repo.getDataAccess().create(dirstateFile);
-		if (da.isEmpty()) {
-			return new Pair<Nodeid,Nodeid>(NULL, NULL);
-		}
 		try {
+			if (da.isEmpty()) {
+				return new Pair<Nodeid,Nodeid>(NULL, NULL);
+			}
 			return internalReadParents(da);
 		} catch (IOException ex) {
 			throw new HgInvalidControlFileException("Error reading working copy parents from dirstate", ex, dirstateFile);