view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ChangeSet.java @ 271:c0540bbe7c2a

Revert premature commit. Parents are not part of API yet
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Wed, 20 Jul 2011 17:40:04 +0400
parents 0af40adc4791
children 8c10f5cec37d
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.command;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Represents Mercurial change set
 */
public class ChangeSet extends ChangeSetRevision {
  @NotNull private String myUser;
  @NotNull private Date myTimestamp;
  private String myDescription;
  private boolean myContainsFiles;
  private List<ChangeSetRevision> myParents;

  public ChangeSet(final int revNumber, @NotNull final String id) {
    super(revNumber, id);
  }

  /**
   * Constructor for version in the form revnum:changeset_id or just changeset_id (in this case rev number is set to -1)
   * @param fullVersion full changeset version as reported by hg log command
   */
  public ChangeSet(@NotNull final String fullVersion) {
    super(fullVersion);
  }

  public void setUser(@NotNull final String user) {
    myUser = user;
  }

  public void setTimestamp(@NotNull final Date timestamp) {
    myTimestamp = timestamp;
  }

  public void setDescription(final String description) {
    myDescription = description;
  }

  public void setContainsFiles(final boolean containsFiles) {
    myContainsFiles = containsFiles;
  }

  public void addParent(@NotNull ChangeSetRevision rev) {
    if (myParents == null) {
      myParents = new ArrayList<ChangeSetRevision>();
    }
    myParents.add(rev);
  }

  /**
   * Returns user who made changeset
   * @return user who made changeset
   */
  @NotNull
  public String getUser() {
    return myUser;
  }

  /**
   * Returns changeset timestamp
   * @return changeset timestamp
   */
  @NotNull
  public Date getTimestamp() {
    return myTimestamp;
  }

  /**
   * Returns changeset summary specified by user
   * @return changeset summary
   */
  public String getDescription() {
    return myDescription;
  }

  /**
   * Returns parrents of this change set, or null if there were no parents.
   * @return see above
   */
  @Nullable
  public List<ChangeSetRevision> getParents() {
    return myParents;
  }

  /**
   * Returns true if this change has changed files
   * @return see above
   */
  public boolean containsFiles() {
    return myContainsFiles;
  }


  /**
   * Check if changeset is initial changeset (has no parents)
   * @return true if changeset is initial changeset
   */
  public boolean isInitial() {
    return getParents() == null;
  }
}