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@423: import org.tmatesoft.hg.internal.Callback;
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@423: @Callback
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@423: * @throws HgCallbackTargetException wrapper for any exception user code may produce
tikhomirov@328: */
tikhomirov@427: public void treeElement(HgChangesetTreeHandler.TreeElement entry) throws HgCallbackTargetException;
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@328: */
tikhomirov@423: public Nodeid fileRevision();
tikhomirov@366:
tikhomirov@328: /**
tikhomirov@328: * @return changeset associated with the current revision
tikhomirov@328: */
tikhomirov@423: public HgChangeset changeset();
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@328: */
tikhomirov@423: public Nodeid changesetRevision();
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@328: */
tikhomirov@423: public Pair parents();
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@328: */
tikhomirov@423: public Pair parentRevisions();
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@366: */
tikhomirov@423: public Collection children();
tikhomirov@328:
tikhomirov@328: /**
tikhomirov@328: * Lightweight alternative to {@link #children()}.
tikhomirov@328: * @return never null
tikhomirov@328: */
tikhomirov@423: public Collection childRevisions();
tikhomirov@328: }
tikhomirov@328: }