Mercurial > hg > mercurial
view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java @ 429:04eab204ba39
Remove HgVcsRoot's dependency on HgPathProvider
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Fri, 11 May 2012 16:37:00 +0400 |
parents | c91c4f1ebd53 |
children | 26b02b419f71 |
line wrap: on
line source
/* * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants; import jetbrains.buildServer.buildTriggers.vcs.mercurial.PathUtil; import jetbrains.buildServer.util.StringUtil; import jetbrains.buildServer.vcs.VcsRoot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.Map; /** * Represents mercurial VCS root */ public class HgVcsRoot implements VcsRoot { private static final String DEFAULT_BRANCH_NAME = "default"; private final VcsRoot myRoot; private final String myRepository; private final String myHgCommandPath; private final String myBranchName; private final boolean myUncompressedTransfer; private final String myCustomClonePath; private final String myUserForTag; private final AuthSettings myAuthSettings; private File myCustomWorkingDir; public HgVcsRoot(@NotNull final VcsRoot vcsRoot) { myRoot = vcsRoot; myRepository = getProperty(Constants.REPOSITORY_PROP); myHgCommandPath = getProperty(Constants.HG_COMMAND_PATH_PROP); myBranchName = getProperty(Constants.BRANCH_NAME_PROP); myCustomClonePath = getProperty(Constants.SERVER_CLONE_PATH_PROP); myUncompressedTransfer = "true".equals(getProperty(Constants.UNCOMPRESSED_TRANSFER)); myUserForTag = getProperty(Constants.USER_FOR_TAG); myAuthSettings = new AuthSettings(getProperty(Constants.USERNAME), getProperty(Constants.PASSWORD)); } public String getCustomClonePath() { return myCustomClonePath; } public String getRepository() { return myRepository; } /** * Returns name of the branch to use (returns 'default' if no branch specified) * @return see above */ @NotNull public String getBranchName() { return StringUtil.isEmpty(myBranchName) ? DEFAULT_BRANCH_NAME : myBranchName; } public boolean isUncompressedTransfer() { return myUncompressedTransfer; } /** * @return path to hg command as it is set in VCS root settings */ public String getHgPath() { return myHgCommandPath; } @Nullable public String getUserForTag() { return myUserForTag; } public String getRepositoryUrlWithCredentials() { return myAuthSettings.getRepositoryUrlWithCredentials(myRepository); } /** * Set custom working dir for vcs root. This option make sence only for server-side checkout * @param customWorkingDir custom working dir */ public void setCustomWorkingDir(@NotNull final File customWorkingDir) { myCustomWorkingDir = PathUtil.getCanonicalFile(customWorkingDir); } /** * Returns custom working dir for root or null if default working dir should be used. * This options make sence only with server-side checkout. * @return see above */ @Nullable public File getCustomWorkingDir() { return myCustomWorkingDir; } public AuthSettings getAuthSettings() { return myAuthSettings; } public String getVcsName() { return myRoot.getVcsName(); } public String getProperty(String propertyName) { return myRoot.getProperty(propertyName); } public String getProperty(String propertyName, String defaultValue) { return myRoot.getProperty(propertyName, defaultValue); } public Map<String, String> getProperties() { return myRoot.getProperties(); } public String convertToString() { return myRoot.convertToString(); } public String convertToPresentableString() { return myRoot.convertToPresentableString(); } public long getPropertiesHash() { return myRoot.getPropertiesHash(); } public long getVcsRepositoryPropertiesHash() { return myRoot.getVcsRepositoryPropertiesHash(); } public String getName() { return myRoot.getName(); } public long getId() { return myRoot.getId(); } public Map<String, String> getPublicProperties() { return myRoot.getPublicProperties(); } }