tikhomirov@373: /* tikhomirov@626: * Copyright (c) 2012-2013 TMate Software Ltd tikhomirov@373: * tikhomirov@373: * This program is free software; you can redistribute it and/or modify tikhomirov@373: * it under the terms of the GNU General Public License as published by tikhomirov@373: * the Free Software Foundation; version 2 of the License. tikhomirov@373: * tikhomirov@373: * This program is distributed in the hope that it will be useful, tikhomirov@373: * but WITHOUT ANY WARRANTY; without even the implied warranty of tikhomirov@373: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tikhomirov@373: * GNU General Public License for more details. tikhomirov@373: * tikhomirov@373: * For information on how to redistribute this software under tikhomirov@373: * the terms of a license other than GNU General Public License tikhomirov@373: * contact TMate Software at support@hg4j.com tikhomirov@373: */ tikhomirov@373: package org.tmatesoft.hg.repo; tikhomirov@373: tikhomirov@373: tikhomirov@373: /** tikhomirov@442: * Names of some Mercurial configuration/service files. tikhomirov@442: * tikhomirov@373: * @author Artem Tikhomirov tikhomirov@373: * @author TMate Software Ltd. tikhomirov@373: */ tikhomirov@373: public enum HgRepositoryFiles { tikhomirov@373: tikhomirov@647: HgIgnore(Home.Root, ".hgignore"), HgTags(Home.Root, ".hgtags"), HgEol(Home.Root, ".hgeol"), tikhomirov@647: Dirstate(Home.Repo, "dirstate"), HgLocalTags(Home.Repo, "localtags"), tikhomirov@647: HgSub(Home.Root, ".hgsub"), HgSubstate(Home.Root, ".hgsubstate"), tikhomirov@647: LastMessage(Home.Repo, "last-message.txt"), tikhomirov@647: Bookmarks(Home.Repo, "bookmarks"), BookmarksCurrent(Home.Repo, "bookmarks.current"), tikhomirov@647: Branch(Home.Repo, "branch"), tikhomirov@647: UndoBranch(Home.Repo, "undo.branch"), UndoDirstate(Home.Repo, "undo.dirstate"), tikhomirov@647: Phaseroots(Home.Store, "phaseroots"), FNCache(Home.Store, "fncache"), tikhomirov@707: WorkingCopyLock(Home.Repo, "wlock"), StoreLock(Home.Store, "lock"), tikhomirov@711: MergeState(Home.Repo, "merge/state"), tikhomirov@711: RepoConfig(Home.Repo, "hgrc"); tikhomirov@647: tikhomirov@647: /** tikhomirov@707: * Possible file locations tikhomirov@707: *
null
tikhomirov@482: */
tikhomirov@373: public String getPath() {
tikhomirov@647: switch (residesIn) {
tikhomirov@647: case Store : return ".hg/store/" + getName();
tikhomirov@647: case Repo : return ".hg/" + getName();
tikhomirov@647: default : return getName();
tikhomirov@647: }
tikhomirov@482: }
tikhomirov@482:
tikhomirov@482: /**
tikhomirov@482: * File name without any path information
tikhomirov@482: * @return file name, never null
tikhomirov@482: */
tikhomirov@482: public String getName() {
tikhomirov@373: return fname;
tikhomirov@373: }
tikhomirov@482:
tikhomirov@482: /**
tikhomirov@482: * Files that reside under working directory may be accessed like:
tikhomirov@482: * tikhomirov@482: * HgRepository hgRepo = ...; tikhomirov@482: * File f = new File(hgRepo.getWorkingDir(), HgRepositoryFiles.HgIgnore.getPath()) tikhomirov@482: *tikhomirov@482: * @return
true
if file lives in working tree
tikhomirov@482: */
tikhomirov@482: public boolean residesUnderWorkingDir() {
tikhomirov@647: return residesIn == Home.Root;
tikhomirov@482: }
tikhomirov@482:
tikhomirov@482: /**
tikhomirov@482: * @return true
if file lives under '.hg/'
tikhomirov@482: */
tikhomirov@482: public boolean residesUnderRepositoryRoot() {
tikhomirov@647: return residesIn == Home.Repo;
tikhomirov@647: }
tikhomirov@647:
tikhomirov@647: /**
tikhomirov@647: * Identify a root the file lives under
tikhomirov@647: */
tikhomirov@647: public Home getHome() {
tikhomirov@647: return residesIn;
tikhomirov@482: }
tikhomirov@373: }