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

Add list files support
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Fri, 11 May 2012 15:21:35 +0400
parents 6667765025c6
children 3daa8e36f8f1
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 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 List<ChangeSetRevision> myParents = new ArrayList<ChangeSetRevision>();
  private List<FileStatus> myModifiedFiles = new ArrayList<FileStatus>();

  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 addParent(@NotNull ChangeSetRevision rev) {
    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
   * @return see above
   */
  @NotNull
  public List<ChangeSetRevision> getParents() {
    return myParents;
  }

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

  public void setModifiedFiles(@NotNull final List<FileStatus> files) {
    myModifiedFiles = files;
  }

  @NotNull
  public List<FileStatus> getModifiedFiles() {
    return myModifiedFiles;
  }
}