Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgDataFile.java @ 347:8da7ade36c57
Add specific IAE subclass to handle wrong (e.g. outdated after rollback) revisions
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 22 Nov 2011 05:25:57 +0100 |
parents | a674b8590362 |
children | 5f9073eabf06 |
comparison
equal
deleted
inserted
replaced
346:6d2c6b2469fc | 347:8da7ade36c57 |
---|---|
31 import java.util.Collections; | 31 import java.util.Collections; |
32 import java.util.List; | 32 import java.util.List; |
33 | 33 |
34 import org.tmatesoft.hg.core.HgDataStreamException; | 34 import org.tmatesoft.hg.core.HgDataStreamException; |
35 import org.tmatesoft.hg.core.HgException; | 35 import org.tmatesoft.hg.core.HgException; |
36 import org.tmatesoft.hg.core.HgInvalidRevisionException; | |
36 import org.tmatesoft.hg.core.HgLogCommand; | 37 import org.tmatesoft.hg.core.HgLogCommand; |
37 import org.tmatesoft.hg.core.Nodeid; | 38 import org.tmatesoft.hg.core.Nodeid; |
38 import org.tmatesoft.hg.internal.DataAccess; | 39 import org.tmatesoft.hg.internal.DataAccess; |
39 import org.tmatesoft.hg.internal.FilterByteChannel; | 40 import org.tmatesoft.hg.internal.FilterByteChannel; |
40 import org.tmatesoft.hg.internal.FilterDataAccess; | 41 import org.tmatesoft.hg.internal.FilterDataAccess; |
175 // } while (left > 0); | 176 // } while (left > 0); |
176 // progressSupport.done(); // XXX shall specify whether #done() is invoked always or only if completed successfully. | 177 // progressSupport.done(); // XXX shall specify whether #done() is invoked always or only if completed successfully. |
177 // } | 178 // } |
178 | 179 |
179 /*XXX not sure distinct method contentWithFilters() is the best way to do, perhaps, callers shall add filters themselves?*/ | 180 /*XXX not sure distinct method contentWithFilters() is the best way to do, perhaps, callers shall add filters themselves?*/ |
180 public void contentWithFilters(int revision, ByteChannel sink) throws HgDataStreamException, CancelledException { | 181 public void contentWithFilters(int revision, ByteChannel sink) throws HgDataStreamException, CancelledException, HgInvalidRevisionException { |
181 if (revision == WORKING_COPY) { | 182 if (revision == WORKING_COPY) { |
182 workingCopy(sink); // pass un-mangled sink | 183 workingCopy(sink); // pass un-mangled sink |
183 } else { | 184 } else { |
184 content(revision, new FilterByteChannel(sink, getRepo().getFiltersFromRepoToWorkingDir(getPath()))); | 185 content(revision, new FilterByteChannel(sink, getRepo().getFiltersFromRepoToWorkingDir(getPath()))); |
185 } | 186 } |
186 } | 187 } |
187 | 188 |
188 // for data files need to check heading of the file content for possible metadata | 189 // for data files need to check heading of the file content for possible metadata |
189 // @see http://mercurial.selenic.com/wiki/FileFormats#data.2BAC8- | 190 // @see http://mercurial.selenic.com/wiki/FileFormats#data.2BAC8- |
190 public void content(int revision, ByteChannel sink) throws HgDataStreamException, CancelledException { | 191 public void content(int revision, ByteChannel sink) throws HgDataStreamException, CancelledException, HgInvalidRevisionException { |
191 if (revision == TIP) { | 192 if (revision == TIP) { |
192 revision = getLastRevision(); | 193 revision = getLastRevision(); |
193 } | 194 } |
194 if (revision == WORKING_COPY) { | 195 if (revision == WORKING_COPY) { |
195 // sink is supposed to come into workingCopy without filters | 196 // sink is supposed to come into workingCopy without filters |
196 // thus we shall not get here (into #content) from #contentWithFilters(WC) | 197 // thus we shall not get here (into #content) from #contentWithFilters(WC) |
197 workingCopy(sink); | 198 workingCopy(sink); |
198 return; | 199 return; |
199 } | 200 } |
200 if (wrongLocalRevision(revision) || revision == BAD_REVISION) { | 201 if (wrongLocalRevision(revision) || revision == BAD_REVISION) { |
201 throw new IllegalArgumentException(String.valueOf(revision)); | 202 throw new HgInvalidRevisionException(revision); |
202 } | 203 } |
203 if (sink == null) { | 204 if (sink == null) { |
204 throw new IllegalArgumentException(); | 205 throw new IllegalArgumentException(); |
205 } | 206 } |
206 if (metadata == null) { | 207 if (metadata == null) { |
348 | 349 |
349 public void history(HgChangelog.Inspector inspector) { | 350 public void history(HgChangelog.Inspector inspector) { |
350 history(0, getLastRevision(), inspector); | 351 history(0, getLastRevision(), inspector); |
351 } | 352 } |
352 | 353 |
353 public void history(int start, int end, HgChangelog.Inspector inspector) { | 354 public void history(int start, int end, HgChangelog.Inspector inspector) throws HgInvalidRevisionException { |
354 if (!exists()) { | 355 if (!exists()) { |
355 throw new IllegalStateException("Can't get history of invalid repository file node"); | 356 throw new IllegalStateException("Can't get history of invalid repository file node"); |
356 } | 357 } |
357 final int last = getLastRevision(); | 358 final int last = getLastRevision(); |
358 if (end == TIP) { | 359 if (end == TIP) { |