view mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialModificationInfoBuilder.java @ 877:45311425ee3c

Remove unused field HgPathProvider wasn't used in OperationContext. Remove it from all the places where it was needed only to create the context.
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Fri, 03 Oct 2014 22:29:27 +0200
parents 31a1aca3305c
children c0c1a3f4b6f7
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.ChangeSet;
import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot;
import jetbrains.buildServer.vcs.*;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.Collections;

public class MercurialModificationInfoBuilder implements ChangesInfoBuilder, MercurialServerExtension {

  private final MercurialVcsSupport myVcs;
  private final HgVcsRootFactory myHgVcsRootFactory;
  private final RepoFactory myRepoFactory;
  private final HgPathProvider myHgPathProvider;

  public MercurialModificationInfoBuilder(@NotNull MercurialVcsSupport vcs,
                                          @NotNull HgVcsRootFactory hgVcsRootFactory,
                                          @NotNull RepoFactory repoFactory,
                                          @NotNull HgPathProvider hgPathProvider) {
    myVcs = vcs;
    myHgVcsRootFactory = hgVcsRootFactory;
    myRepoFactory = repoFactory;
    myHgPathProvider = hgPathProvider;
    myVcs.addExtension(this);
  }

  public void fetchChangesInfo(@NotNull final VcsRoot root,
                               @NotNull final CheckoutRules checkoutRules,
                               @NotNull final Collection<String> revisions,
                               @NotNull final ChangesConsumer consumer) throws VcsException {
    final HgVcsRoot hgRoot = myHgVcsRootFactory.createHgRoot(root);

    final OperationContext ctx = new OperationContext(myVcs,
            myRepoFactory,
            Collections.<String>emptyList(),
            RepositoryStateData.createVersionState("", Collections.<String, String>emptyMap()));

    //TODO: it's better if we call log command once (or by chunks) instead of simple for-each
    for (String commitId : revisions) {
      for (ChangeSet set : myVcs.createRepo(hgRoot).log().withRevsets(commitId).call()) {
        consumer.consumeChange(ModificationDataFactory.createModificationData(ctx, set, root, checkoutRules));
      }
    }
  }
}