diff src/org/tmatesoft/hg/repo/HgManifest.java @ 638:2f1cd1c26de5 smartgit-4.5

AIOOBE in HgManifest.RevisionMapper: provide more details about exception context. Create lock file atomically. Picked from changeset 8a5cdcb27b8f
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 07 Jun 2013 13:21:20 +0200
parents 47dfa0ec7e35
children 5d8798772cca
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgManifest.java	Mon Apr 29 17:04:51 2013 +0200
+++ b/src/org/tmatesoft/hg/repo/HgManifest.java	Fri Jun 07 13:21:20 2013 +0200
@@ -602,7 +602,12 @@
 		}
 
 		// XXX likely can be replaced with Revlog.RevisionInspector
-		public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess data) {
+		public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess data) throws HgInvalidRevisionException {
+			if (linkRevision >= changelogRevisionCount) {
+				String storeLock = repo.getStoreLock().readLockInfo();
+				String message = String.format("Manifest revision %d references changeset %d, which is beyond known scope [0..%d). Lock: %s", revisionNumber, linkRevision, changelogRevisionCount, storeLock);
+				throw new HgInvalidRevisionException(message, null, linkRevision);
+			}
 			if (changelog2manifest != null) {
 				// next assertion is not an error, rather assumption check, which is too development-related to be explicit exception - 
 				// I just wonder if there are manifests that have two entries pointing to single changeset. It seems unrealistic, though -