Mercurial > hg4j
view src/org/tmatesoft/hg/repo/HgSubrepoLocation.java @ 429:cd658b24a620
FIXMEs: javadoc, proper use of constants
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 29 Mar 2012 18:29:03 +0200 |
parents | 9c9c442b5f2e |
children | 6865eb742883 |
line wrap: on
line source
/* * Copyright (c) 2011-2012 TMate Software Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * For information on how to redistribute this software under * the terms of a license other than GNU General Public License * contact TMate Software at support@hg4j.com */ package org.tmatesoft.hg.repo; import java.io.File; import org.tmatesoft.hg.core.HgRepositoryNotFoundException; import org.tmatesoft.hg.internal.Experimental; import org.tmatesoft.hg.util.Path; /** * WORK IN PROGRESS, DO NOT USE * @author Artem Tikhomirov * @author TMate Software Ltd. */ @Experimental(reason="Work in progress") public class HgSubrepoLocation { private final HgRepository owner; private final Kind kind; private final Path location; private final String source; private final String revInfo; public enum Kind { Hg, SVN, Git, } public HgSubrepoLocation(HgRepository parentRepo, String repoLocation, String actualLocation, Kind type, String revision) { owner = parentRepo; location = Path.create(repoLocation); source = actualLocation; kind = type; revInfo = revision; } // as defined in .hgsub, key value public Path getLocation() { return location; } // value from .hgsub public String getSource() { return source; } public Kind getType() { return kind; } public String getRevision() { return revInfo; } /** * @return whether this sub repository is known only locally */ public boolean isCommitted() { return revInfo != null; } /** * @return <code>true</code> when there are local changes in the sub repository */ public boolean hasChanges() { throw HgRepository.notImplemented(); } // public boolean isLocal() { // } public HgRepository getOwner() { return owner; } /** * * @return object to access sub-repository * @throws HgRepositoryNotFoundException if failed to find repository * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> */ public HgRepository getRepo() throws HgRepositoryNotFoundException { if (kind != Kind.Hg) { throw new HgInvalidStateException(String.format("Unsupported subrepository %s", kind)); } return new HgLookup().detect(new File(owner.getWorkingDir(), source)); } }