tikhomirov@328: /* tikhomirov@403: * Copyright (c) 2011-2012 TMate Software Ltd tikhomirov@328: * tikhomirov@328: * This program is free software; you can redistribute it and/or modify tikhomirov@328: * it under the terms of the GNU General Public License as published by tikhomirov@328: * the Free Software Foundation; version 2 of the License. tikhomirov@328: * tikhomirov@328: * This program is distributed in the hope that it will be useful, tikhomirov@328: * but WITHOUT ANY WARRANTY; without even the implied warranty of tikhomirov@328: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tikhomirov@328: * GNU General Public License for more details. tikhomirov@328: * tikhomirov@328: * For information on how to redistribute this software under tikhomirov@328: * the terms of a license other than GNU General Public License tikhomirov@328: * contact TMate Software at support@hg4j.com tikhomirov@328: */ tikhomirov@328: package org.tmatesoft.hg.core; tikhomirov@328: tikhomirov@328: import java.util.Collection; tikhomirov@328: tikhomirov@328: import org.tmatesoft.hg.util.CancelledException; tikhomirov@328: import org.tmatesoft.hg.util.Pair; tikhomirov@328: tikhomirov@328: /** tikhomirov@403: * Handler to iterate file history (generally, any revlog) with access to parent-child relations between changesets. tikhomirov@403: * tikhomirov@403: * @see HgLogCommand#execute(HgChangesetTreeHandler) tikhomirov@403: * tikhomirov@328: * @author Artem Tikhomirov tikhomirov@328: * @author TMate Software Ltd. tikhomirov@328: */ tikhomirov@328: public interface HgChangesetTreeHandler { tikhomirov@328: /** tikhomirov@328: * @param entry access to various pieces of information about current tree node. Instances might be tikhomirov@370: * reused across calls and shall not be kept by client's code tikhomirov@403: * @throws HgException allows implementers propagate errors from {@link TreeElement} or other parts of the library. tikhomirov@370: * @throws HgCallbackTargetException.Wrap wrapper object for any exception user code may produce. Wrapped exception would get re-thrown with {@link HgCallbackTargetException} tikhomirov@383: * @throws CancelledException if execution of the operation was cancelled tikhomirov@328: */ tikhomirov@403: public void next(HgChangesetTreeHandler.TreeElement entry) throws HgException, HgCallbackTargetException.Wrap, CancelledException; tikhomirov@328: tikhomirov@328: interface TreeElement { tikhomirov@328: /** tikhomirov@328: * Revision of the revlog being iterated. For example, when walking file history, return value represents file revisions. tikhomirov@328: * tikhomirov@328: * @return revision of the revlog being iterated. tikhomirov@403: * @throws HgException to indicate failure dealing with Mercurial data tikhomirov@328: */ tikhomirov@403: public Nodeid fileRevision() throws HgException; tikhomirov@366: tikhomirov@328: /** tikhomirov@328: * @return changeset associated with the current revision tikhomirov@403: * @throws HgException to indicate failure dealing with Mercurial data tikhomirov@328: */ tikhomirov@366: public HgChangeset changeset() throws HgException; tikhomirov@328: tikhomirov@328: /** tikhomirov@328: * Lightweight alternative to {@link #changeset()}, identifies changeset in which current file node has been modified tikhomirov@403: * @return changeset {@link Nodeid revision} tikhomirov@403: * @throws HgException to indicate failure dealing with Mercurial data tikhomirov@328: */ tikhomirov@403: public Nodeid changesetRevision() throws HgException; tikhomirov@328: tikhomirov@328: /** tikhomirov@328: * Node, these are not necessarily in direct relation to parents of changeset from {@link #changeset()} tikhomirov@328: * @return changesets that correspond to parents of the current file node, either pair element may be null. tikhomirov@403: * @throws HgException to indicate failure dealing with Mercurial data tikhomirov@328: */ tikhomirov@366: public Pair parents() throws HgException; tikhomirov@328: tikhomirov@328: /** tikhomirov@328: * Lightweight alternative to {@link #parents()}, give {@link Nodeid nodeids} only tikhomirov@328: * @return two values, neither is null, use {@link Nodeid#isNull()} to identify parent not set tikhomirov@403: * @throws HgException to indicate failure dealing with Mercurial data tikhomirov@328: */ tikhomirov@403: public Pair parentRevisions() throws HgException; tikhomirov@328: tikhomirov@366: /** tikhomirov@366: * Changes that originate from the given change and bear it as their parent. tikhomirov@366: * @return collection (possibly empty) of immediate children of the change tikhomirov@403: * @throws HgException to indicate failure dealing with Mercurial data tikhomirov@366: */ tikhomirov@366: public Collection children() throws HgException; tikhomirov@328: tikhomirov@328: /** tikhomirov@328: * Lightweight alternative to {@link #children()}. tikhomirov@328: * @return never null tikhomirov@403: * @throws HgException to indicate failure dealing with Mercurial data tikhomirov@328: */ tikhomirov@403: public Collection childRevisions() throws HgException; tikhomirov@328: } tikhomirov@328: }