Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgLogCommand.java @ 354:5f9073eabf06
Propagate errors with exceptions up to a end client
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 01 Dec 2011 05:21:40 +0100 |
parents | a674b8590362 |
children | 189dc6dc1c3e |
comparison
equal
deleted
inserted
replaced
353:0f3687e79f5a | 354:5f9073eabf06 |
---|---|
32 import org.tmatesoft.hg.internal.IntMap; | 32 import org.tmatesoft.hg.internal.IntMap; |
33 import org.tmatesoft.hg.internal.IntVector; | 33 import org.tmatesoft.hg.internal.IntVector; |
34 import org.tmatesoft.hg.repo.HgChangelog; | 34 import org.tmatesoft.hg.repo.HgChangelog; |
35 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; | 35 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
36 import org.tmatesoft.hg.repo.HgDataFile; | 36 import org.tmatesoft.hg.repo.HgDataFile; |
37 import org.tmatesoft.hg.repo.HgInternals; | |
37 import org.tmatesoft.hg.repo.HgRepository; | 38 import org.tmatesoft.hg.repo.HgRepository; |
38 import org.tmatesoft.hg.repo.HgStatusCollector; | 39 import org.tmatesoft.hg.repo.HgStatusCollector; |
39 import org.tmatesoft.hg.util.CancelSupport; | 40 import org.tmatesoft.hg.util.CancelSupport; |
40 import org.tmatesoft.hg.util.CancelledException; | 41 import org.tmatesoft.hg.util.CancelledException; |
41 import org.tmatesoft.hg.util.Pair; | 42 import org.tmatesoft.hg.util.Pair; |
152 /** | 153 /** |
153 * Select specific changeset | 154 * Select specific changeset |
154 * | 155 * |
155 * @param nid changeset revision | 156 * @param nid changeset revision |
156 * @return <code>this</code> for convenience | 157 * @return <code>this</code> for convenience |
157 */ | 158 * @throws HgInvalidRevisionException if supplied nodeid doesn't identify any revision from this revlog |
158 public HgLogCommand changeset(Nodeid nid) { | 159 * @throws HgInvalidControlFileException if access to revlog index/data entry failed |
160 */ | |
161 public HgLogCommand changeset(Nodeid nid) throws HgInvalidControlFileException, HgInvalidRevisionException { | |
159 // XXX perhaps, shall support multiple (...) arguments and extend #execute to handle not only range, but also set of revisions. | 162 // XXX perhaps, shall support multiple (...) arguments and extend #execute to handle not only range, but also set of revisions. |
160 final int csetLocal = repo.getChangelog().getLocalRevision(nid); | 163 final int csetLocal = repo.getChangelog().getLocalRevision(nid); |
161 return range(csetLocal, csetLocal); | 164 return range(csetLocal, csetLocal); |
162 } | 165 } |
163 | 166 |
201 * | 204 * |
202 * @param handler callback to process changesets. | 205 * @param handler callback to process changesets. |
203 * @throws IllegalArgumentException when inspector argument is null | 206 * @throws IllegalArgumentException when inspector argument is null |
204 * @throws ConcurrentModificationException if this log command instance is already running | 207 * @throws ConcurrentModificationException if this log command instance is already running |
205 */ | 208 */ |
206 public void execute(HgChangesetHandler handler) throws HgDataStreamException, HgCallbackTargetException, CancelledException { | 209 public void execute(HgChangesetHandler handler) throws HgDataStreamException, HgInvalidControlFileException, HgCallbackTargetException, CancelledException { |
207 if (handler == null) { | 210 if (handler == null) { |
208 throw new IllegalArgumentException(); | 211 throw new IllegalArgumentException(); |
209 } | 212 } |
210 if (csetTransform != null) { | 213 if (csetTransform != null) { |
211 throw new ConcurrentModificationException(); | 214 throw new ConcurrentModificationException(); |
592 // XXX pipe through pool | 595 // XXX pipe through pool |
593 HgChangeset cs = cachedChangesets.get(changelogRevisionNumber); | 596 HgChangeset cs = cachedChangesets.get(changelogRevisionNumber); |
594 if (cs != null) { | 597 if (cs != null) { |
595 return cs.getNodeid(); | 598 return cs.getNodeid(); |
596 } else { | 599 } else { |
597 return repo.getChangelog().getRevision(changelogRevisionNumber); | 600 try { |
601 return repo.getChangelog().getRevision(changelogRevisionNumber); | |
602 } catch (HgException ex) { | |
603 HgInternals.getContext(repo).getLog().error(getClass(), ex, null); | |
604 // FIXME propagate, perhaps? | |
605 return Nodeid.NULL; // FIXME this is quick-n-dirty hack to move forward with introducing exceptions | |
606 } | |
598 } | 607 } |
599 } | 608 } |
600 } | 609 } |
601 } | 610 } |