Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgManifest.java @ 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 | 5a455624be4f |
| children | c1478cc31f45 |
comparison
equal
deleted
inserted
replaced
| 546:cd78e8b9d7bc | 547:66fc86e8c0dd |
|---|---|
| 254 */ | 254 */ |
| 255 public Nodeid getFileRevision(int changelogRevisionIndex, final Path file) throws HgInvalidRevisionException, HgInvalidControlFileException { | 255 public Nodeid getFileRevision(int changelogRevisionIndex, final Path file) throws HgInvalidRevisionException, HgInvalidControlFileException { |
| 256 // there's no need for HgDataFile to own this method, or get a delegate | 256 // there's no need for HgDataFile to own this method, or get a delegate |
| 257 // as most of HgDataFile API is using file revision indexes, and there's easy step from file revision index to | 257 // as most of HgDataFile API is using file revision indexes, and there's easy step from file revision index to |
| 258 // both file revision and changeset revision index. But there's no easy way to go from changesetRevisionIndex to | 258 // both file revision and changeset revision index. But there's no easy way to go from changesetRevisionIndex to |
| 259 // file revision (the task this method solves), exept for HgFileInformer | 259 // file revision (the task this method solves), except for HgFileInformer |
| 260 // I feel methods dealing with changeset indexes shall be more exposed in HgChangelog and HgManifest API. | 260 // I feel methods dealing with changeset indexes shall be more exposed in HgChangelog and HgManifest API. |
| 261 // TODO need tests | 261 // TODO need tests (e.g. pass TIP here to see resMap.get(-1) doesn't fail) |
| 262 int manifestRevIndex = fromChangelog(changelogRevisionIndex); | 262 int manifestRevIndex = fromChangelog(changelogRevisionIndex); |
| 263 if (manifestRevIndex == BAD_REVISION) { | 263 if (manifestRevIndex == BAD_REVISION) { |
| 264 return null; | 264 return null; |
| 265 } | 265 } |
| 266 IntMap<Nodeid> resMap = new IntMap<Nodeid>(3); | 266 IntMap<Nodeid> resMap = new IntMap<Nodeid>(3); |
| 267 FileLookupInspector parser = new FileLookupInspector(encodingHelper, file, resMap, null); | 267 FileLookupInspector parser = new FileLookupInspector(encodingHelper, file, resMap, null); |
| 268 parser.walk(manifestRevIndex, content); | 268 parser.walk(manifestRevIndex, content); |
| 269 return resMap.get(changelogRevisionIndex); | 269 assert resMap.size() == 1; |
| 270 // can't use changelogRevisionIndex as key - it might have been TIP | |
| 271 return resMap.get(resMap.firstKey()); | |
| 270 } | 272 } |
| 271 | 273 |
| 272 /** | 274 /** |
| 273 * Visit file revisions as they were recorded at the time of given changesets. Same file revision may be reported as many times as | 275 * Visit file revisions as they were recorded at the time of given changesets. Same file revision may be reported as many times as |
| 274 * there are changesets that refer to that revision. Both {@link Inspector#begin(int, Nodeid, int)} and {@link Inspector#end(int)} | 276 * there are changesets that refer to that revision. Both {@link Inspector#begin(int, Nodeid, int)} and {@link Inspector#end(int)} |
| 306 public Flags getFileFlags(int changesetRevIndex, Path file) throws HgInvalidRevisionException, HgInvalidControlFileException { | 308 public Flags getFileFlags(int changesetRevIndex, Path file) throws HgInvalidRevisionException, HgInvalidControlFileException { |
| 307 int manifestRevIdx = fromChangelog(changesetRevIndex); | 309 int manifestRevIdx = fromChangelog(changesetRevIndex); |
| 308 IntMap<Flags> resMap = new IntMap<Flags>(2); | 310 IntMap<Flags> resMap = new IntMap<Flags>(2); |
| 309 FileLookupInspector parser = new FileLookupInspector(encodingHelper, file, null, resMap); | 311 FileLookupInspector parser = new FileLookupInspector(encodingHelper, file, null, resMap); |
| 310 parser.walk(manifestRevIdx, content); | 312 parser.walk(manifestRevIdx, content); |
| 311 return resMap.get(changesetRevIndex); | 313 assert resMap.size() == 1; |
| 314 // can't use changesetRevIndex as key - it might have been TIP | |
| 315 return resMap.get(resMap.firstKey()); | |
| 312 } | 316 } |
| 313 | 317 |
| 314 | 318 |
| 315 /** | 319 /** |
| 316 * @param changelogRevisionIndexes non-null | 320 * @param changelogRevisionIndexes non-null |
