view mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/MergeBaseCommand.java @ 732:31a1aca3305c

Update copyright
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Tue, 14 Jan 2014 12:45:10 +0100
parents 45f25ca68312
children 7bf4d943d5bb
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.command;

import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgRepo;
import jetbrains.buildServer.vcs.VcsException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * Analog of git merge-base. It returns a last common ancestor between two revisions.
 *
 * @author dmitry.neverov
 */
public abstract class MergeBaseCommand {

  protected final HgRepo myRepo;
  protected String myRevision1;
  protected String myRevision2;

  protected MergeBaseCommand(@NotNull HgRepo repo) {
    myRepo = repo;
  }

  public MergeBaseCommand revision1(String revision1) {
    myRevision1 = revision1;
    return this;
  }

  public MergeBaseCommand revision2(String revision2) {
    myRevision2 = revision2;
    return this;
  }

  /**
   * Returns hash of least common ancestor between two revisions or null
   * if common ancestor is not found
   * @return see above
   * @throws VcsException if some commands fail
   */
  @Nullable
  public abstract String call() throws VcsException;

}