view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfigBuilder.java @ 946:50968ab011d9

TW-34711 update libraries
author Dmitry Neverov <dmitry.neverov@gmail.com>
date Wed, 16 Mar 2016 14:20:46 +0100
parents 3d700493d033
children 31ac1d822fd7
line wrap: on
line source
/*
 * Copyright 2000-2014 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 org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.quartz.CronExpression;

import java.io.File;

/**
 * @author dmitry.neverov
 */
public class ServerPluginConfigBuilder {

  private boolean myUsePullProtocol = true;
  private String myHgPath;
  private File myCachesDir;
  private boolean myDontUseRevsets = false;
  private boolean myDetectSubrepoChanges = true;
  private long myMirrorExpirationTimeout;
  private boolean myTagsAsBranches = true;

  @NotNull
  public ServerPluginConfig build() {
    return new ServerPluginConfig() {

      public boolean isUsePullProtocol() {
        return myUsePullProtocol;
      }

      public String getHgPath() {
        return myHgPath;
      }

      @NotNull
      public File getCachesDir() {
        if (myCachesDir == null)
          throw new IllegalStateException("Caches dir is not set");
        return myCachesDir;
      }

      public int getPullTimeout() {
        return ServerPluginConfigImpl.DEFAULT_PULL_TIMEOUT_SECONDS;
      }

      public boolean dontUseRevsets() {
        return myDontUseRevsets;
      }

      public boolean detectSubrepoChanges() {
        return myDetectSubrepoChanges;
      }

      public boolean bookmarksEnabled() {
        return true;
      }

      public boolean useTagsAsBranches() {
        return myTagsAsBranches;
      }

      public int getMaxDagNodesCount() {
        return 0;
      }

      public int getLogOutputLimit() {
        return 0;
      }

      public long getMirrorExpirationTimeoutMillis() {
        return myMirrorExpirationTimeout;
      }

      @Nullable
      public CronExpression getCleanupCronExpression() {
        return null;
      }

      public boolean reportSubrepoChangesFileStatus() {
        return false;
      }

      public boolean allowSourceCaching() {
        return false;
      }

      public int listFilesTTLSeconds() {
        return 0;
      }

      public String getMergeTool() {
        return "internal:merge";
      }

      public boolean runWithProfile(@NotNull HgVcsRoot root) {
        return false;
      }
    };
  }


  public static ServerPluginConfigBuilder serverPluginConfig() {
    return new ServerPluginConfigBuilder();
  }

  public ServerPluginConfigBuilder userPullProtocol(boolean doUse) {
    myUsePullProtocol = doUse;
    return this;
  }

  public ServerPluginConfigBuilder hgPath(String hgPath) {
    myHgPath = hgPath;
    return this;
  }

  public ServerPluginConfigBuilder cachesDir(File cachesDir) {
    myCachesDir = cachesDir;
    return this;
  }

  public ServerPluginConfigBuilder dontUseRevsets() {
    myDontUseRevsets = true;
    return this;
  }

  public ServerPluginConfigBuilder detectSubrepoChanges(boolean doDetect) {
    myDetectSubrepoChanges = doDetect;
    return this;
  }

  public ServerPluginConfigBuilder withMirrorExpirationTimeout(long timeoutMillis) {
    myMirrorExpirationTimeout = timeoutMillis;
    return this;
  }

  public ServerPluginConfigBuilder withTagsAsBranches(boolean tagsAsBranches) {
    myTagsAsBranches = tagsAsBranches;
    return this;
  }
}