tikhomirov@328: /*
tikhomirov@628: * Copyright (c) 2011-2013 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@515: import org.tmatesoft.hg.repo.HgDataFile;
tikhomirov@628: import org.tmatesoft.hg.repo.HgRuntimeException;
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@628: * @throws HgRuntimeException propagates library issues. Runtime exception
tikhomirov@328: */
tikhomirov@628: public void treeElement(HgChangesetTreeHandler.TreeElement entry) throws HgCallbackTargetException, HgRuntimeException;
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@628: * @throws HgRuntimeException subclass thereof to indicate issues with the library. Runtime exception
tikhomirov@328: */
tikhomirov@628: public Nodeid fileRevision() throws HgRuntimeException;
tikhomirov@515:
tikhomirov@515: /**
tikhomirov@515: * File node, provided revlog being iterated is a {@link HgDataFile}; {@link #fileRevision()}
tikhomirov@515: * references revision from the history of this very {@link HgDataFile file}.
tikhomirov@515: *
tikhomirov@515: * Comes handy when file history with renames is being followed to find out
tikhomirov@515: * file name for particular revision in the history.
tikhomirov@515: *
tikhomirov@515: * @return instance of the file being walked, or null
if it's not a file but other revlog.
tikhomirov@628: * @throws HgRuntimeException subclass thereof to indicate issues with the library. Runtime exception
tikhomirov@515: */
tikhomirov@628: public HgDataFile file() throws HgRuntimeException;
tikhomirov@366:
tikhomirov@328: /**
tikhomirov@507: * @return changeset associated with the current file revision
tikhomirov@628: * @throws HgRuntimeException subclass thereof to indicate issues with the library. Runtime exception
tikhomirov@328: */
tikhomirov@628: public HgChangeset changeset() throws HgRuntimeException;
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@628: * @throws HgRuntimeException subclass thereof to indicate issues with the library. Runtime exception
tikhomirov@328: */
tikhomirov@628: public Nodeid changesetRevision() throws HgRuntimeException;
tikhomirov@328:
tikhomirov@328: /**
tikhomirov@507: * Identifies parent changes, changesets where file/revlog in question was modified prior to change being visited.
tikhomirov@507: *
tikhomirov@507: * Note, these are not necessarily in direct relation to parents of changeset from {@link #changeset()}
tikhomirov@507: *
tikhomirov@507: * Imagine next history (grows from bottom to top):
tikhomirov@507: *
tikhomirov@507: * o A o tikhomirov@507: * | \ | tikhomirov@507: * o B \/ tikhomirov@507: * | o C tikhomirov@507: * | / tikhomirov@507: * o / tikhomirov@507: * | / tikhomirov@507: * o D tikhomirov@507: *tikhomirov@507: * tikhomirov@507: * When we are at {@link TreeElement} for
A
, B
and C
are changeset parents, naturally. However
tikhomirov@507: * if the file/revlog we've been walking has not been changed in B
and C
, but e.g. in D
only,
tikhomirov@507: * then this {@link #parents()} call would return pair with single element only, pointing to D
tikhomirov@507: *
tikhomirov@328: * @return changesets that correspond to parents of the current file node, either pair element may be null
.
tikhomirov@628: * @throws HgRuntimeException subclass thereof to indicate issues with the library. Runtime exception
tikhomirov@328: */
tikhomirov@628: public Pairnull
, use {@link Nodeid#isNull()} to identify parent not set
tikhomirov@628: * @throws HgRuntimeException subclass thereof to indicate issues with the library. Runtime exception
tikhomirov@328: */
tikhomirov@628: public Pairnull
tikhomirov@628: * @throws HgRuntimeException subclass thereof to indicate issues with the library. Runtime exception
tikhomirov@328: */
tikhomirov@628: public Collection