MksContentRevision.java :  » IntelliJ » ideamksplugin » org » intellij » vcs » mks » Java Open Source

Java Open Source » IntelliJ » ideamksplugin 
ideamksplugin » org » intellij » vcs » mks » MksContentRevision.java
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.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() + "]";
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.