comparison src/org/tmatesoft/hg/core/HgChangesetTreeHandler.java @ 423:9c9c442b5f2e

Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 23 Mar 2012 22:51:18 +0100
parents 2747b0723867
children 31a89587eb04
comparison
equal deleted inserted replaced
422:5d1cc7366d04 423:9c9c442b5f2e
16 */ 16 */
17 package org.tmatesoft.hg.core; 17 package org.tmatesoft.hg.core;
18 18
19 import java.util.Collection; 19 import java.util.Collection;
20 20
21 import org.tmatesoft.hg.internal.Callback;
21 import org.tmatesoft.hg.util.CancelledException; 22 import org.tmatesoft.hg.util.CancelledException;
22 import org.tmatesoft.hg.util.Pair; 23 import org.tmatesoft.hg.util.Pair;
23 24
24 /** 25 /**
25 * Handler to iterate file history (generally, any revlog) with access to parent-child relations between changesets. 26 * Handler to iterate file history (generally, any revlog) with access to parent-child relations between changesets.
27 * @see HgLogCommand#execute(HgChangesetTreeHandler) 28 * @see HgLogCommand#execute(HgChangesetTreeHandler)
28 * 29 *
29 * @author Artem Tikhomirov 30 * @author Artem Tikhomirov
30 * @author TMate Software Ltd. 31 * @author TMate Software Ltd.
31 */ 32 */
33 @Callback
32 public interface HgChangesetTreeHandler { 34 public interface HgChangesetTreeHandler {
33 /** 35 /**
34 * @param entry access to various pieces of information about current tree node. Instances might be 36 * @param entry access to various pieces of information about current tree node. Instances might be
35 * reused across calls and shall not be kept by client's code 37 * reused across calls and shall not be kept by client's code
36 * @throws HgException allows implementers propagate errors from {@link TreeElement} or other parts of the library. 38 * @throws HgCallbackTargetException wrapper for any exception user code may produce
37 * @throws HgCallbackTargetException.Wrap wrapper object for any exception user code may produce. Wrapped exception would get re-thrown with {@link HgCallbackTargetException}
38 * @throws CancelledException if execution of the operation was cancelled 39 * @throws CancelledException if execution of the operation was cancelled
39 */ 40 */
40 public void next(HgChangesetTreeHandler.TreeElement entry) throws HgException, HgCallbackTargetException.Wrap, CancelledException; 41 public void next(HgChangesetTreeHandler.TreeElement entry) throws HgCallbackTargetException, CancelledException;
41 42
42 interface TreeElement { 43 interface TreeElement {
43 /** 44 /**
44 * Revision of the revlog being iterated. For example, when walking file history, return value represents file revisions. 45 * Revision of the revlog being iterated. For example, when walking file history, return value represents file revisions.
45 * 46 *
46 * @return revision of the revlog being iterated. 47 * @return revision of the revlog being iterated.
47 * @throws HgException to indicate failure dealing with Mercurial data
48 */ 48 */
49 public Nodeid fileRevision() throws HgException; 49 public Nodeid fileRevision();
50 50
51 /** 51 /**
52 * @return changeset associated with the current revision 52 * @return changeset associated with the current revision
53 * @throws HgException to indicate failure dealing with Mercurial data
54 */ 53 */
55 public HgChangeset changeset() throws HgException; 54 public HgChangeset changeset();
56 55
57 /** 56 /**
58 * Lightweight alternative to {@link #changeset()}, identifies changeset in which current file node has been modified 57 * Lightweight alternative to {@link #changeset()}, identifies changeset in which current file node has been modified
59 * @return changeset {@link Nodeid revision} 58 * @return changeset {@link Nodeid revision}
60 * @throws HgException to indicate failure dealing with Mercurial data
61 */ 59 */
62 public Nodeid changesetRevision() throws HgException; 60 public Nodeid changesetRevision();
63 61
64 /** 62 /**
65 * Node, these are not necessarily in direct relation to parents of changeset from {@link #changeset()} 63 * Node, these are not necessarily in direct relation to parents of changeset from {@link #changeset()}
66 * @return changesets that correspond to parents of the current file node, either pair element may be <code>null</code>. 64 * @return changesets that correspond to parents of the current file node, either pair element may be <code>null</code>.
67 * @throws HgException to indicate failure dealing with Mercurial data
68 */ 65 */
69 public Pair<HgChangeset, HgChangeset> parents() throws HgException; 66 public Pair<HgChangeset, HgChangeset> parents();
70 67
71 /** 68 /**
72 * Lightweight alternative to {@link #parents()}, give {@link Nodeid nodeids} only 69 * Lightweight alternative to {@link #parents()}, give {@link Nodeid nodeids} only
73 * @return two values, neither is <code>null</code>, use {@link Nodeid#isNull()} to identify parent not set 70 * @return two values, neither is <code>null</code>, use {@link Nodeid#isNull()} to identify parent not set
74 * @throws HgException to indicate failure dealing with Mercurial data
75 */ 71 */
76 public Pair<Nodeid, Nodeid> parentRevisions() throws HgException; 72 public Pair<Nodeid, Nodeid> parentRevisions();
77 73
78 /** 74 /**
79 * Changes that originate from the given change and bear it as their parent. 75 * Changes that originate from the given change and bear it as their parent.
80 * @return collection (possibly empty) of immediate children of the change 76 * @return collection (possibly empty) of immediate children of the change
81 * @throws HgException to indicate failure dealing with Mercurial data
82 */ 77 */
83 public Collection<HgChangeset> children() throws HgException; 78 public Collection<HgChangeset> children();
84 79
85 /** 80 /**
86 * Lightweight alternative to {@link #children()}. 81 * Lightweight alternative to {@link #children()}.
87 * @return never <code>null</code> 82 * @return never <code>null</code>
88 * @throws HgException to indicate failure dealing with Mercurial data
89 */ 83 */
90 public Collection<Nodeid> childRevisions() throws HgException; 84 public Collection<Nodeid> childRevisions();
91 } 85 }
92 } 86 }