tikhomirov@347: /*
tikhomirov@396: * Copyright (c) 2011-2012 TMate Software Ltd
tikhomirov@347: *
tikhomirov@347: * This program is free software; you can redistribute it and/or modify
tikhomirov@347: * it under the terms of the GNU General Public License as published by
tikhomirov@347: * the Free Software Foundation; version 2 of the License.
tikhomirov@347: *
tikhomirov@347: * This program is distributed in the hope that it will be useful,
tikhomirov@347: * but WITHOUT ANY WARRANTY; without even the implied warranty of
tikhomirov@347: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tikhomirov@347: * GNU General Public License for more details.
tikhomirov@347: *
tikhomirov@347: * For information on how to redistribute this software under
tikhomirov@347: * the terms of a license other than GNU General Public License
tikhomirov@347: * contact TMate Software at support@hg4j.com
tikhomirov@347: */
tikhomirov@423: package org.tmatesoft.hg.repo;
tikhomirov@347:
tikhomirov@423: import org.tmatesoft.hg.core.Nodeid;
tikhomirov@347:
tikhomirov@347: /**
tikhomirov@368: * Use of revision or revision local index that is not valid for a given revlog.
tikhomirov@347: *
tikhomirov@347: * @author Artem Tikhomirov
tikhomirov@347: * @author TMate Software Ltd.
tikhomirov@347: */
tikhomirov@347: @SuppressWarnings("serial")
tikhomirov@423: public class HgInvalidRevisionException extends HgRuntimeException {
tikhomirov@347:
tikhomirov@347: /**
tikhomirov@347: *
tikhomirov@423: * This exception is not expected to be initialized with another exception, although those who need to,
tikhomirov@347: * may still use {@link #initCause(Throwable)}
tikhomirov@423: *
tikhomirov@347: * @param message optional description of the issue
tikhomirov@347: * @param revision invalid revision, may be null
if revisionIndex is used
tikhomirov@347: * @param revisionIndex invalid revision index, may be null
if not known and revision is supplied
tikhomirov@347: */
tikhomirov@347: public HgInvalidRevisionException(String message, Nodeid revision, Integer revisionIndex) {
tikhomirov@423: super(message, null);
tikhomirov@423: assert revision != null || revisionIndex != null;
tikhomirov@423: if (revision != null) {
tikhomirov@423: setRevision(revision);
tikhomirov@423: }
tikhomirov@423: if (revisionIndex != null) {
tikhomirov@423: setRevisionIndex(revisionIndex);
tikhomirov@423: }
tikhomirov@347: }
tikhomirov@347:
tikhomirov@347: public HgInvalidRevisionException(Nodeid revision) {
tikhomirov@347: this(null, revision, null);
tikhomirov@347: }
tikhomirov@347:
tikhomirov@347: public HgInvalidRevisionException(int revisionIndex) {
tikhomirov@347: this(null, null, revisionIndex);
tikhomirov@347: }
tikhomirov@347:
tikhomirov@347: public HgInvalidRevisionException setRevisionIndex(int revisionIndex, int rangeLeft, int rangeRight) {
tikhomirov@423: details.setRevisionIndexBoundary(revisionIndex, rangeLeft, rangeRight);
tikhomirov@347: return this;
tikhomirov@347: }
tikhomirov@347: }