Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgManifest.java @ 368:8107b95f4280
Update Javadoc with 'revision index'
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 16 Dec 2011 16:00:57 +0100 |
parents | 2fadf8695f8a |
children | 155c1893bda4 |
comparison
equal
deleted
inserted
replaced
367:2fadf8695f8a | 368:8107b95f4280 |
---|---|
125 */ | 125 */ |
126 public void walk(final Inspector inspector, int... revisionIndexes) throws HgInvalidControlFileException{ | 126 public void walk(final Inspector inspector, int... revisionIndexes) throws HgInvalidControlFileException{ |
127 if (inspector == null || revisionIndexes == null) { | 127 if (inspector == null || revisionIndexes == null) { |
128 throw new IllegalArgumentException(); | 128 throw new IllegalArgumentException(); |
129 } | 129 } |
130 int[] localManifestRevs = toManifestRevisionIndexes(revisionIndexes); | 130 int[] manifestRevs = toManifestRevisionIndexes(revisionIndexes); |
131 content.iterate(localManifestRevs, true, new ManifestParser(inspector)); | 131 content.iterate(manifestRevs, true, new ManifestParser(inspector)); |
132 } | 132 } |
133 | 133 |
134 // manifest revision number that corresponds to the given changeset | 134 // manifest revision number that corresponds to the given changeset |
135 /*package-local*/ int fromChangelog(int revisionNumber) throws HgInvalidControlFileException { | 135 /*package-local*/ int fromChangelog(int changesetRevisionIndex) throws HgInvalidControlFileException { |
136 if (HgInternals.wrongRevisionIndex(revisionNumber)) { | 136 if (HgInternals.wrongRevisionIndex(changesetRevisionIndex)) { |
137 throw new IllegalArgumentException(String.valueOf(revisionNumber)); | 137 throw new IllegalArgumentException(String.valueOf(changesetRevisionIndex)); |
138 } | 138 } |
139 if (revisionNumber == HgRepository.WORKING_COPY || revisionNumber == HgRepository.BAD_REVISION) { | 139 if (changesetRevisionIndex == HgRepository.WORKING_COPY || changesetRevisionIndex == HgRepository.BAD_REVISION) { |
140 throw new IllegalArgumentException("Can't use constants like WORKING_COPY or BAD_REVISION"); | 140 throw new IllegalArgumentException("Can't use constants like WORKING_COPY or BAD_REVISION"); |
141 } | 141 } |
142 // revisionNumber == TIP is processed by RevisionMapper | 142 // revisionNumber == TIP is processed by RevisionMapper |
143 if (revisionMap == null) { | 143 if (revisionMap == null) { |
144 revisionMap = new RevisionMapper(getRepo()); | 144 revisionMap = new RevisionMapper(getRepo()); |
145 content.iterate(0, TIP, false, revisionMap); | 145 content.iterate(0, TIP, false, revisionMap); |
146 } | 146 } |
147 return revisionMap.at(revisionNumber); | 147 return revisionMap.at(changesetRevisionIndex); |
148 } | 148 } |
149 | 149 |
150 /** | 150 /** |
151 * Extracts file revision as it was known at the time of given changeset. | 151 * Extracts file revision as it was known at the time of given changeset. |
152 * | 152 * |
198 return rv; | 198 return rv; |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 private int[] toManifestRevisionIndexes(int[] changelogRevisionIndexes) throws HgInvalidControlFileException { | 202 private int[] toManifestRevisionIndexes(int[] changelogRevisionIndexes) throws HgInvalidControlFileException { |
203 int[] localManifestRevs = new int[changelogRevisionIndexes.length]; | 203 int[] manifestRevs = new int[changelogRevisionIndexes.length]; |
204 boolean needsSort = false; | 204 boolean needsSort = false; |
205 for (int i = 0; i < changelogRevisionIndexes.length; i++) { | 205 for (int i = 0; i < changelogRevisionIndexes.length; i++) { |
206 final int manifestRevisionIndex = fromChangelog(changelogRevisionIndexes[i]); | 206 final int manifestRevisionIndex = fromChangelog(changelogRevisionIndexes[i]); |
207 localManifestRevs[i] = manifestRevisionIndex; | 207 manifestRevs[i] = manifestRevisionIndex; |
208 if (i > 0 && localManifestRevs[i-1] > manifestRevisionIndex) { | 208 if (i > 0 && manifestRevs[i-1] > manifestRevisionIndex) { |
209 needsSort = true; | 209 needsSort = true; |
210 } | 210 } |
211 } | 211 } |
212 if (needsSort) { | 212 if (needsSort) { |
213 Arrays.sort(localManifestRevs); | 213 Arrays.sort(manifestRevs); |
214 } | 214 } |
215 return localManifestRevs; | 215 return manifestRevs; |
216 } | 216 } |
217 | 217 |
218 public interface Inspector { | 218 public interface Inspector { |
219 boolean begin(int mainfestRevision, Nodeid nid, int changelogRevision); | 219 boolean begin(int mainfestRevision, Nodeid nid, int changelogRevision); |
220 /** | 220 /** |