changeset 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 (2013-06-07)
parents 8cbc2a883d95
children 49f0749307a0
files src/org/tmatesoft/hg/repo/HgManifest.java src/org/tmatesoft/hg/repo/HgRepositoryLock.java
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
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 -
--- a/src/org/tmatesoft/hg/repo/HgRepositoryLock.java	Mon Apr 29 17:04:51 2013 +0200
+++ b/src/org/tmatesoft/hg/repo/HgRepositoryLock.java	Fri Jun 07 13:21:20 2013 +0200
@@ -120,7 +120,7 @@
 		do {
 			synchronized(this) {
 				try {
-					if (!lockFile.exists()) {
+					if (lockFile.createNewFile()) {
 						write(lockFile, bytes);
 						use++;
 						return;