diff src/org/tmatesoft/hg/internal/RevlogStream.java @ 538:dd4f6311af52

Commit: first working version
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 05 Feb 2013 22:30:21 +0100
parents 243202f1bda5
children 9edfd5a223b8
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/RevlogStream.java	Tue Feb 05 20:06:22 2013 +0100
+++ b/src/org/tmatesoft/hg/internal/RevlogStream.java	Tue Feb 05 22:30:21 2013 +0100
@@ -223,6 +223,27 @@
 		}
 		return BAD_REVISION;
 	}
+	
+	public long newEntryOffset() {
+		if (revisionCount() == 0) {
+			return 0;
+		}
+		DataAccess daIndex = getIndexStream();
+		int lastRev = revisionCount() - 1;
+		try {
+			int recordOffset = getIndexOffsetInt(lastRev);
+			daIndex.seek(recordOffset);
+			long value = daIndex.readLong();
+			value = value >>> 16;
+			int compressedLen = daIndex.readInt();
+			return lastRev == 0 ? compressedLen : value + compressedLen;
+		} catch (IOException ex) {
+			throw new HgInvalidControlFileException("Linked revision lookup failed", ex, indexFile).setRevisionIndex(lastRev);
+		} finally {
+			daIndex.done();
+		}
+	}
+
 
 
 	// should be possible to use TIP, ALL, or -1, -2, -n notation of Hg