view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfigBuilder.java @ 715:be86907926ae

new approach: remember hg sub-state file hash per commit, dump hash -> file, and log with refs
author eugene.petrenko@jetbrains.com
date Mon, 13 Jan 2014 18:51:13 +0100
parents 3cc513b9e3c1
children 31a1aca3305c
line wrap: on
line source
package jetbrains.buildServer.buildTriggers.vcs.mercurial;

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 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;
  }
}