Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/VcsRootBuilder.java @ 982:4a0ea921c214 Indore-2017.2.x
Merge back changes since 28.04.2017
author | Dmitry Neverov <dmitry.neverov@gmail.com> |
---|---|
date | Wed, 24 Jan 2018 22:02:52 +0100 |
parents | 7bf4d943d5bb 38adef4f1b8f |
children | 6e4a700806e4 |
line wrap: on
line source
/* * Copyright 2000-2018 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; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.util.StringUtil; import jetbrains.buildServer.vcs.impl.VcsRootImpl; import org.jetbrains.annotations.NotNull; import java.io.File; import java.io.IOException; /** * @author dmitry.neverov */ public class VcsRootBuilder { private String myExtensions; private String myRepository; private String myUsername; private String myPassword; private String myBranch; private long myRootId = 1L; private String myHgPath; private String myUserForTag; private boolean myUncompressed = true; private File myCloneRepositoryTo; private boolean myDetectSubrepoChanges = false; private boolean myTagsAsBranches = false; private boolean myIncludeSubreposInPatch = true; private boolean myUseArchiveForPatch = false; private HgVcsRoot.PurgePolicy myPurgePolicy; private String myCustomConfig; public static VcsRootBuilder vcsRoot() { return new VcsRootBuilder(); } public VcsRootImpl build() throws IOException { VcsRootImpl vcsRoot = new VcsRootImpl(myRootId, Constants.VCS_NAME); vcsRoot.addProperty(Constants.REPOSITORY_PROP, myRepository); vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, myHgPath != null ? myHgPath : Util.getHgPath()); vcsRoot.addProperty(Constants.USERNAME, myUsername); vcsRoot.addProperty(Constants.PASSWORD, myPassword); vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, myBranch); vcsRoot.addProperty(Constants.USER_FOR_TAG, myUserForTag); vcsRoot.addProperty(Constants.UNCOMPRESSED_TRANSFER, String.valueOf(myUncompressed)); vcsRoot.addProperty(Constants.DETECT_SUBREPO_CHANGES, String.valueOf(myDetectSubrepoChanges)); vcsRoot.addProperty(Constants.INCLUDE_SUBREPOS_IN_PATCH, String.valueOf(myIncludeSubreposInPatch)); vcsRoot.addProperty(Constants.USE_ARCHIVE_FOR_PATCH, String.valueOf(myUseArchiveForPatch)); vcsRoot.addProperty(Constants.HG_EXTENSIONS, myExtensions); if (myCloneRepositoryTo != null) vcsRoot.addProperty(Constants.SERVER_CLONE_PATH_PROP, String.valueOf(myCloneRepositoryTo.getAbsolutePath())); vcsRoot.addProperty(Constants.USE_TAGS_AS_BRANCHES, String.valueOf(myTagsAsBranches)); if (myPurgePolicy != null) vcsRoot.addProperty(Constants.PURGE_POLICY, myPurgePolicy.name()); if (myCustomConfig != null) vcsRoot.addProperty(Constants.CUSTOM_HG_CONFIG_PROP, myCustomConfig); return vcsRoot; } public VcsRootBuilder withUrl(@NotNull String repository) { myRepository = repository; return this; } @NotNull public VcsRootBuilder withExtensions(@NotNull String... extensions) { myExtensions = StringUtil.join(extensions, "\n"); return this; } public VcsRootBuilder withLocalRepository(@NotNull final File repo) { return withUrl(repo.getPath()).withCloneRepositoryTo(repo.getParentFile()); } public VcsRootBuilder withUrl(@NotNull File repository) { myRepository = repository.getAbsolutePath(); return this; } public VcsRootBuilder withUserName(@NotNull String username) { myUsername = username; return this; } public VcsRootBuilder withPassword(@NotNull String password) { myPassword = password; return this; } public VcsRootBuilder withBranch(@NotNull String branch) { myBranch = branch; return this; } public VcsRootBuilder withId(long rootId) { myRootId = rootId; return this; } public VcsRootBuilder withHgPath(String hgPath) { myHgPath = hgPath; return this; } public VcsRootBuilder withUserForTag(String username) { myUserForTag = username; return this; } public VcsRootBuilder withCloneRepositoryTo(File cloneTo) { myCloneRepositoryTo = cloneTo; return this; } public VcsRootBuilder withSubrepoChanges(boolean detectSubrepoChanges) { myDetectSubrepoChanges = detectSubrepoChanges; return this; } public VcsRootBuilder withSubreposInPatch(boolean includeSubreposInPatch) { myIncludeSubreposInPatch = includeSubreposInPatch; return this; } public VcsRootBuilder withArchiveForPatch(boolean useArchiveForPatch) { myUseArchiveForPatch = useArchiveForPatch; return this; } public VcsRootBuilder withTagsEnabled(boolean useTagsAsBranches) { myTagsAsBranches = useTagsAsBranches; return this; } public VcsRootBuilder withPurgePolicy(HgVcsRoot.PurgePolicy policy) { myPurgePolicy = policy; return this; } public VcsRootBuilder withCustomConfig(String customConfig) { myCustomConfig = customConfig; return this; } }