changeset 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 26ad7827a62d
children fffe4f882248
files src/org/tmatesoft/hg/repo/HgDirstate.java
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
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 {