Package org.intellij.vcs.mks

Source Code of org.intellij.vcs.mks.MksContentRevision

package org.intellij.vcs.mks;

import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import org.intellij.vcs.mks.sicommands.cli.GetContentRevision;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;

/**
* @author Thibaut Fagart
*/
public class MksContentRevision implements ContentRevision {

  final VcsRevisionNumber myRevision;
  private MksVcs mksvcs;
  final FilePath myFile;

  public MksContentRevision(@NotNull MksVcs mksvcs, @NotNull FilePath myFile, @NotNull VcsRevisionNumber myRevision) {
    this.mksvcs = mksvcs;
    this.myFile = myFile;
    this.myRevision = myRevision;
  }

  @Nullable
  public String getContent() throws VcsException {
    if (VcsRevisionNumber.NULL.equals(myRevision)) {
      return null;
    } else {
      GetContentRevision getRevisionCommand = new GetContentRevision(new ArrayList<VcsException>(), mksvcs,
          this.getRevisionNumber(), this.getFile().getPath());
      getRevisionCommand.execute();
      return getRevisionCommand.getContent();
    }
  }

  @NotNull
  public FilePath getFile() {
    return myFile;
  }

  @NotNull
  public VcsRevisionNumber getRevisionNumber() {
    return myRevision;
  }

  @Override
  public String toString() {
    return "MksContentRevision[" + getFile() + ":" + getRevisionNumber() + "]";
  }
}
TOP

Related Classes of org.intellij.vcs.mks.MksContentRevision

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.