view mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java @ 322:6667765025c6

Merge branch Eluru-6.5.x
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Mon, 19 Sep 2011 12:02:37 +0400
parents e9cdb499350d 01a64fe3b896
children dd55596a5753
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;

import com.intellij.openapi.util.Pair;
import jetbrains.buildServer.agent.AgentRunningBuild;
import jetbrains.buildServer.agent.BuildAgentConfiguration;
import jetbrains.buildServer.agent.BuildProgressLogger;
import jetbrains.buildServer.agent.vcs.AgentVcsSupport;
import jetbrains.buildServer.agent.vcs.IncludeRuleUpdater;
import jetbrains.buildServer.agent.vcs.UpdateByIncludeRules2;
import jetbrains.buildServer.agent.vcs.UpdatePolicy;
import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.*;
import jetbrains.buildServer.util.FileUtil;
import jetbrains.buildServer.vcs.CheckoutRules;
import jetbrains.buildServer.vcs.IncludeRule;
import jetbrains.buildServer.vcs.VcsException;
import jetbrains.buildServer.vcs.VcsRoot;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.IOException;
import java.util.*;

import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandUtil.removePrivateData;

public class MercurialAgentSideVcsSupport extends AgentVcsSupport implements UpdateByIncludeRules2 {

  private final MirrorManager myMirrorManager;
  private final HgPathProvider myHgPathProvider;

  public MercurialAgentSideVcsSupport(@NotNull final BuildAgentConfiguration agentConfiguration,
                                      @NotNull final HgPathProvider hgPathProvider) {
    myMirrorManager = new MirrorManager(agentConfiguration.getCacheDirectory("mercurial"));
    myHgPathProvider = hgPathProvider;
  }

  public IncludeRuleUpdater getUpdater(@NotNull final VcsRoot vcsRoot, @NotNull final CheckoutRules checkoutRules, @NotNull final String toVersion, @NotNull final File checkoutDirectory, @NotNull final AgentRunningBuild build, boolean cleanCheckoutRequested) throws VcsException {
    return new MercurialIncludeRuleUpdater(myMirrorManager, myHgPathProvider, vcsRoot, toVersion, build);
  }

  @NotNull
  @Override
  public String getName() {
    return Constants.VCS_NAME;
  }

  @NotNull
  @Override
  public UpdatePolicy getUpdatePolicy() {
    return this;
  }
}