// Path: src/org/github/irengrig/fossil4idea/FossilException.java
// public class FossilException extends VcsException {
//   public FossilException(final String message) {
//     super(message);
//   }
// 
//   public FossilException(final Throwable throwable, final boolean isWarning) {
//     super(throwable, isWarning);
//   }
// 
//   public FossilException(final Throwable throwable) {
//     super(throwable);
//   }
// 
//   public FossilException(final String message, final Throwable cause) {
//     super(message, cause);
//   }
// 
//   public FossilException(final String message, final boolean isWarning) {
//     super(message, isWarning);
//   }
// 
//   public FossilException(final Collection<String> messages) {
//     super(messages);
//   }
// }
// 
// Path: src/org/github/irengrig/fossil4idea/FossilVcs.java
// public class FossilVcs extends AbstractVcs {
//   public static String NAME = "fossil";
//   public static String DISPLAY_NAME = "Fossil";
//   private FossilChangeProvider myChangeProvider;
//   private static final VcsKey ourKey = createKey(NAME);
//   private FossilVfsListener myVfsListener;
//   private UiManager uiManager;
//   private FossilCheckinEnvironment fossilCheckinEnvironment;
// 
//   public FossilVcs(Project project) {
//     super(project, NAME);
//   }
// 
//   @Override
//   public String getDisplayName() {
//     return DISPLAY_NAME;
//   }
// 
//   @Override
//   public Configurable getConfigurable() {
//     return new FossilConfigurable(myProject);
//   }
// 
//   @Override
//   protected void activate() {
//     myVfsListener = new FossilVfsListener(myProject);
//     uiManager = new UiManager(myProject);
//   }
// 
//   @Override
//   protected void deactivate() {
//     if (myVfsListener != null) {
//       Disposer.dispose(myVfsListener);
//       myVfsListener = null;
//       uiManager.stop();
//     }
//   }
// 
//   public UiManager getUiManager() {
//     return uiManager;
//   }
// 
//   @Nullable
//   @Override
//   public ChangeProvider getChangeProvider() {
//     if (myChangeProvider == null) {
//       myChangeProvider = new FossilChangeProvider(myProject);
//     }
//     return myChangeProvider;
//   }
// 
//   @Nullable
//   @Override
//   protected CheckinEnvironment createCheckinEnvironment() {
//     if (fossilCheckinEnvironment == null) {
//       fossilCheckinEnvironment = new FossilCheckinEnvironment(this);
//     }
//     return fossilCheckinEnvironment;
//   }
// 
//   @Nullable
//   @Override
//   protected RollbackEnvironment createRollbackEnvironment() {
//     return new FossilRollbackEnvironment(this);
//   }
// 
//   @Nullable
//   @Override
//   public VcsHistoryProvider getVcsHistoryProvider() {
//     return new FossilHistoryProvider(this);
//   }
// 
//   @Nullable
//   @Override
//   protected UpdateEnvironment createUpdateEnvironment() {
//     return new FossilUpdateEnvironment(this);
//   }
// 
//   @Override
//   public List<CommitExecutor> getCommitExecutors() {
//     return Collections.<CommitExecutor>singletonList(new FossilCommitAndPushExecutor(myProject));
//   }
// 
//   public void checkVersion() {
//     //todo
//   }
// 
//   @Nullable
//   @Override
//   public DiffProvider getDiffProvider() {
//     return new FossilDiffProvider(this);
//   }
// 
//   public static FossilVcs getInstance(final Project project) {
//     return (FossilVcs) ProjectLevelVcsManager.getInstance(project).findVcsByName(NAME);
//   }
// 
//   public static VcsKey getVcsKey() {
//     return ourKey;
//   }
// 
//   @Nullable
//   @Override
//   public AnnotationProvider getAnnotationProvider() {
//     return new FossilAnnotationProvider(this);
//   }
// }
// 
// Path: src/org/github/irengrig/fossil4idea/log/CatWorker.java
// public class CatWorker {
//   private final Project myProject;
// 
//   public CatWorker(final Project project) {
//     myProject = project;
//   }
// 
//   public String cat(final File file, @Nullable final String revNum) throws VcsException {
//     final FossilSimpleCommand command = new FossilSimpleCommand(myProject, MoveWorker.findParent(file), FCommandName.finfo);
//     command.addParameters("-p");
//     if (revNum != null && ! "HEAD".equals(revNum)) {
//       command.addParameters("-r", revNum);
//     }
//     command.addParameters(file.getPath());
//     return command.run();
//   }
// }


import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Throwable2Computable;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vcs.impl.ContentRevisionCache;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.github.irengrig.fossil4idea.FossilException;
import org.github.irengrig.fossil4idea.FossilVcs;
import org.github.irengrig.fossil4idea.log.CatWorker;
import java.io.IOException;
package org.github.irengrig.fossil4idea.repository;



/**
 * Created with IntelliJ IDEA.
 * User: Irina.Chernushina
 * Date: 2/13/13
 * Time: 11:02 PM
 */
public class FossilContentRevision implements ContentRevision {
  private final Project myProject;
  private final FilePath myFilePath;
  private final FossilRevisionNumber myNumber;

  public FossilContentRevision(final Project project, final FilePath filePath, final FossilRevisionNumber number) {
    myProject = project;
    myFilePath = filePath;
    myNumber = number;
  }

  @Nullable
  @Override
  public String getContent() throws VcsException {
    try {
      return ContentRevisionCache.getOrLoadAsString(myProject, myFilePath, myNumber, FossilVcs.getVcsKey(),
          ContentRevisionCache.UniqueType.REPOSITORY_CONTENT, new Throwable2Computable<byte[], VcsException, IOException>() {
        @Override
        public byte[] compute() throws VcsException, IOException {
// Path: src/org/github/irengrig/fossil4idea/FossilException.java
// public class FossilException extends VcsException {
//   public FossilException(final String message) {
//     super(message);
//   }
// 
//   public FossilException(final Throwable throwable, final boolean isWarning) {
//     super(throwable, isWarning);
//   }
// 
//   public FossilException(final Throwable throwable) {
//     super(throwable);
//   }
// 
//   public FossilException(final String message, final Throwable cause) {
//     super(message, cause);
//   }
// 
//   public FossilException(final String message, final boolean isWarning) {
//     super(message, isWarning);
//   }
// 
//   public FossilException(final Collection<String> messages) {
//     super(messages);
//   }
// }
// 
// Path: src/org/github/irengrig/fossil4idea/FossilVcs.java
// public class FossilVcs extends AbstractVcs {
//   public static String NAME = "fossil";
//   public static String DISPLAY_NAME = "Fossil";
//   private FossilChangeProvider myChangeProvider;
//   private static final VcsKey ourKey = createKey(NAME);
//   private FossilVfsListener myVfsListener;
//   private UiManager uiManager;
//   private FossilCheckinEnvironment fossilCheckinEnvironment;
// 
//   public FossilVcs(Project project) {
//     super(project, NAME);
//   }
// 
//   @Override
//   public String getDisplayName() {
//     return DISPLAY_NAME;
//   }
// 
//   @Override
//   public Configurable getConfigurable() {
//     return new FossilConfigurable(myProject);
//   }
// 
//   @Override
//   protected void activate() {
//     myVfsListener = new FossilVfsListener(myProject);
//     uiManager = new UiManager(myProject);
//   }
// 
//   @Override
//   protected void deactivate() {
//     if (myVfsListener != null) {
//       Disposer.dispose(myVfsListener);
//       myVfsListener = null;
//       uiManager.stop();
//     }
//   }
// 
//   public UiManager getUiManager() {
//     return uiManager;
//   }
// 
//   @Nullable
//   @Override
//   public ChangeProvider getChangeProvider() {
//     if (myChangeProvider == null) {
//       myChangeProvider = new FossilChangeProvider(myProject);
//     }
//     return myChangeProvider;
//   }
// 
//   @Nullable
//   @Override
//   protected CheckinEnvironment createCheckinEnvironment() {
//     if (fossilCheckinEnvironment == null) {
//       fossilCheckinEnvironment = new FossilCheckinEnvironment(this);
//     }
//     return fossilCheckinEnvironment;
//   }
// 
//   @Nullable
//   @Override
//   protected RollbackEnvironment createRollbackEnvironment() {
//     return new FossilRollbackEnvironment(this);
//   }
// 
//   @Nullable
//   @Override
//   public VcsHistoryProvider getVcsHistoryProvider() {
//     return new FossilHistoryProvider(this);
//   }
// 
//   @Nullable
//   @Override
//   protected UpdateEnvironment createUpdateEnvironment() {
//     return new FossilUpdateEnvironment(this);
//   }
// 
//   @Override
//   public List<CommitExecutor> getCommitExecutors() {
//     return Collections.<CommitExecutor>singletonList(new FossilCommitAndPushExecutor(myProject));
//   }
// 
//   public void checkVersion() {
//     //todo
//   }
// 
//   @Nullable
//   @Override
//   public DiffProvider getDiffProvider() {
//     return new FossilDiffProvider(this);
//   }
// 
//   public static FossilVcs getInstance(final Project project) {
//     return (FossilVcs) ProjectLevelVcsManager.getInstance(project).findVcsByName(NAME);
//   }
// 
//   public static VcsKey getVcsKey() {
//     return ourKey;
//   }
// 
//   @Nullable
//   @Override
//   public AnnotationProvider getAnnotationProvider() {
//     return new FossilAnnotationProvider(this);
//   }
// }
// 
// Path: src/org/github/irengrig/fossil4idea/log/CatWorker.java
// public class CatWorker {
//   private final Project myProject;
// 
//   public CatWorker(final Project project) {
//     myProject = project;
//   }
// 
//   public String cat(final File file, @Nullable final String revNum) throws VcsException {
//     final FossilSimpleCommand command = new FossilSimpleCommand(myProject, MoveWorker.findParent(file), FCommandName.finfo);
//     command.addParameters("-p");
//     if (revNum != null && ! "HEAD".equals(revNum)) {
//       command.addParameters("-r", revNum);
//     }
//     command.addParameters(file.getPath());
//     return command.run();
//   }
// }


// Path: src/org/github/irengrig/fossil4idea/repository/FossilContentRevision.java
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Throwable2Computable;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vcs.impl.ContentRevisionCache;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.github.irengrig.fossil4idea.FossilException;
import org.github.irengrig.fossil4idea.FossilVcs;
import org.github.irengrig.fossil4idea.log.CatWorker;
import java.io.IOException;

package org.github.irengrig.fossil4idea.repository;



/**
 * Created with IntelliJ IDEA.
 * User: Irina.Chernushina
 * Date: 2/13/13
 * Time: 11:02 PM
 */
public class FossilContentRevision implements ContentRevision {
  private final Project myProject;
  private final FilePath myFilePath;
  private final FossilRevisionNumber myNumber;

  public FossilContentRevision(final Project project, final FilePath filePath, final FossilRevisionNumber number) {
    myProject = project;
    myFilePath = filePath;
    myNumber = number;
  }

  @Nullable
  @Override
  public String getContent() throws VcsException {
    try {
      return ContentRevisionCache.getOrLoadAsString(myProject, myFilePath, myNumber, FossilVcs.getVcsKey(),
          ContentRevisionCache.UniqueType.REPOSITORY_CONTENT, new Throwable2Computable<byte[], VcsException, IOException>() {
        @Override
        public byte[] compute() throws VcsException, IOException {
          return new CatWorker(myProject).cat(myFilePath.getIOFile(), myNumber.getHash()).getBytes();