diff src/org/tmatesoft/hg/repo/HgDirstate.java @ 227:0fd10e5016dd

IOException on empty repository with 40-byte dirstate
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 25 May 2011 13:13:36 +0200
parents 8248aae33f7d
children 1792b37650f2
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgDirstate.java	Wed May 25 12:16:24 2011 +0200
+++ b/src/org/tmatesoft/hg/repo/HgDirstate.java	Wed May 25 13:13:36 2011 +0200
@@ -75,7 +75,8 @@
 			byte[] parents = new byte[40];
 			da.readBytes(parents, 0, 40);
 			parents = null;
-			do {
+			// hg init; hg up produces an empty repository where dirstate has parents (40 bytes) only
+			while (!da.isEmpty()) {
 				final byte state = da.readByte();
 				final int fmode = da.readInt();
 				final int size = da.readInt();
@@ -106,7 +107,7 @@
 				} else {
 					// FIXME log error?
 				}
-			} while (!da.isEmpty());
+			}
 		} catch (IOException ex) {
 			ex.printStackTrace(); // FIXME log error, clean dirstate?
 		} finally {