# HG changeset patch # User Artem Tikhomirov # Date 1370604080 -7200 # Node ID 2f1cd1c26de564fe2e0a159ada1017f85e17b6ef # Parent 8cbc2a883d95d20ae63da3a5672a80b16bbe4f44 AIOOBE in HgManifest.RevisionMapper: provide more details about exception context. Create lock file atomically. Picked from changeset 8a5cdcb27b8f diff -r 8cbc2a883d95 -r 2f1cd1c26de5 src/org/tmatesoft/hg/repo/HgManifest.java --- 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 - diff -r 8cbc2a883d95 -r 2f1cd1c26de5 src/org/tmatesoft/hg/repo/HgRepositoryLock.java --- 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;