# HG changeset patch
# User Artem Tikhomirov <tikhomirov.artem@gmail.com>
# Date 1313525236 -7200
# Node ID f39fb6b3cc767c918a2b9042dc9983b3fcd037da
# Parent  b61ed0f2c4da47f9b14dcf4a104a4a73d8ba18ae
Handle revision constants correctly

diff -r b61ed0f2c4da -r f39fb6b3cc76 src/org/tmatesoft/hg/repo/HgManifest.java
--- a/src/org/tmatesoft/hg/repo/HgManifest.java	Tue Aug 16 15:45:47 2011 +0200
+++ b/src/org/tmatesoft/hg/repo/HgManifest.java	Tue Aug 16 22:07:16 2011 +0200
@@ -90,6 +90,10 @@
 		if (HgInternals.wrongLocalRevision(revisionNumber)) {
 			throw new IllegalArgumentException(String.valueOf(revisionNumber));
 		}
+		if (revisionNumber == HgRepository.WORKING_COPY || revisionNumber == HgRepository.BAD_REVISION) {
+			throw new IllegalArgumentException("Can't use constants like WORKING_COPY or BAD_REVISION");
+		}
+		// revisionNumber == TIP is processed by RevisionMapper 
 		if (revisionMap == null) {
 			revisionMap = new RevisionMapper(getRepo());
 			content.iterate(0, TIP, false, revisionMap);
@@ -211,7 +215,11 @@
 			changelogRevisions = repo.getChangelog().getRevisionCount();
 		}
 
+		// respects TIP
 		public int at(int revisionNumber) {
+			if (revisionNumber == TIP) {
+				revisionNumber = changelogRevisions - 1;
+			}
 			if (changelog2manifest != null) {
 				return changelog2manifest[revisionNumber];
 			}