changeset 547:66fc86e8c0dd

#getFileRevision() shall accept TIP as an argument
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 18 Feb 2013 19:58:10 +0100
parents cd78e8b9d7bc
children ab21ac7dd833
files src/org/tmatesoft/hg/repo/HgManifest.java
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgManifest.java	Mon Feb 18 19:19:48 2013 +0100
+++ b/src/org/tmatesoft/hg/repo/HgManifest.java	Mon Feb 18 19:58:10 2013 +0100
@@ -256,9 +256,9 @@
 		// there's no need for HgDataFile to own this method, or get a delegate
 		// as most of HgDataFile API is using file revision indexes, and there's easy step from file revision index to
 		// both file revision and changeset revision index. But there's no easy way to go from changesetRevisionIndex to
-		// file revision (the task this method solves), exept for HgFileInformer
+		// file revision (the task this method solves), except for HgFileInformer
 		// I feel methods dealing with changeset indexes shall be more exposed in HgChangelog and HgManifest API.
-		// TODO need tests
+		// TODO need tests (e.g. pass TIP here to see resMap.get(-1) doesn't fail)
 		int manifestRevIndex = fromChangelog(changelogRevisionIndex);
 		if (manifestRevIndex == BAD_REVISION) {
 			return null;
@@ -266,7 +266,9 @@
 		IntMap<Nodeid> resMap = new IntMap<Nodeid>(3);
 		FileLookupInspector parser = new FileLookupInspector(encodingHelper, file, resMap, null);
 		parser.walk(manifestRevIndex, content);
-		return resMap.get(changelogRevisionIndex);
+		assert resMap.size() == 1;
+		// can't use changelogRevisionIndex as key - it might have been TIP
+		return resMap.get(resMap.firstKey());
 	}
 	
 	/**
@@ -308,7 +310,9 @@
 		IntMap<Flags> resMap = new IntMap<Flags>(2);
 		FileLookupInspector parser = new FileLookupInspector(encodingHelper, file, null, resMap);
 		parser.walk(manifestRevIdx, content);
-		return resMap.get(changesetRevIndex);
+		assert resMap.size() == 1;
+		// can't use changesetRevIndex as key - it might have been TIP
+		return resMap.get(resMap.firstKey());
 	}