comparison src/org/tmatesoft/hg/repo/HgManifest.java @ 257:f39fb6b3cc76

Handle revision constants correctly
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 16 Aug 2011 22:07:16 +0200
parents a620f0663a37
children 3dcd3dd90c77
comparison
equal deleted inserted replaced
256:b61ed0f2c4da 257:f39fb6b3cc76
88 // manifest revision number that corresponds to the given changeset 88 // manifest revision number that corresponds to the given changeset
89 /*package-local*/ int fromChangelog(int revisionNumber) { 89 /*package-local*/ int fromChangelog(int revisionNumber) {
90 if (HgInternals.wrongLocalRevision(revisionNumber)) { 90 if (HgInternals.wrongLocalRevision(revisionNumber)) {
91 throw new IllegalArgumentException(String.valueOf(revisionNumber)); 91 throw new IllegalArgumentException(String.valueOf(revisionNumber));
92 } 92 }
93 if (revisionNumber == HgRepository.WORKING_COPY || revisionNumber == HgRepository.BAD_REVISION) {
94 throw new IllegalArgumentException("Can't use constants like WORKING_COPY or BAD_REVISION");
95 }
96 // revisionNumber == TIP is processed by RevisionMapper
93 if (revisionMap == null) { 97 if (revisionMap == null) {
94 revisionMap = new RevisionMapper(getRepo()); 98 revisionMap = new RevisionMapper(getRepo());
95 content.iterate(0, TIP, false, revisionMap); 99 content.iterate(0, TIP, false, revisionMap);
96 } 100 }
97 return revisionMap.at(revisionNumber); 101 return revisionMap.at(revisionNumber);
209 public RevisionMapper(HgRepository hgRepo) { 213 public RevisionMapper(HgRepository hgRepo) {
210 repo = hgRepo; 214 repo = hgRepo;
211 changelogRevisions = repo.getChangelog().getRevisionCount(); 215 changelogRevisions = repo.getChangelog().getRevisionCount();
212 } 216 }
213 217
218 // respects TIP
214 public int at(int revisionNumber) { 219 public int at(int revisionNumber) {
220 if (revisionNumber == TIP) {
221 revisionNumber = changelogRevisions - 1;
222 }
215 if (changelog2manifest != null) { 223 if (changelog2manifest != null) {
216 return changelog2manifest[revisionNumber]; 224 return changelog2manifest[revisionNumber];
217 } 225 }
218 return revisionNumber; 226 return revisionNumber;
219 } 227 }