@Nullable
  private byte[] loadFromVersionControl(long date, VirtualFile f) {
    try {
      final AbstractVcs vcs = VcsUtil.getVcsFor(myProject, f);
      if (vcs == null) return null;

      final VcsHistoryProvider historyProvider = vcs.getVcsHistoryProvider();
      if (historyProvider == null) return null;

      final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(f);
      final VcsHistorySession session = historyProvider.createSessionFor(filePath);
      if (session == null) return null;

      final List<VcsFileRevision> list = session.getRevisionList();

      if (list != null) {
        for (VcsFileRevision revision : list) {
          final Date revisionDate = revision.getRevisionDate();
          if (revisionDate == null) {
            return null;
          }

          if (revisionDate.getTime() < date) {
            return revision.loadContent();
          }
        }
      }
    } catch (Exception e) {
      LOG.info(e);
      return null;
    }
    return null;
  }
  public void setSelected(AnActionEvent e, boolean state) {
    VcsContext context = VcsContextFactory.SERVICE.getInstance().createContextOn(e);
    Editor editor = context.getEditor();
    if (!state) {
      if (editor != null) {
        editor.getGutter().closeAllAnnotations();
      }
    } else {
      if (editor == null) {
        VirtualFile selectedFile = context.getSelectedFile();
        if (selectedFile == null) {
          return;
        }

        FileEditor[] fileEditors =
            FileEditorManager.getInstance(context.getProject()).openFile(selectedFile, false);
        for (FileEditor fileEditor : fileEditors) {
          if (fileEditor instanceof TextEditor) {
            editor = ((TextEditor) fileEditor).getEditor();
          }
        }
      }

      LOGGER.assertTrue(editor != null);

      doAnnotate(editor, context.getProject());
    }
  }
  public boolean isSelected(AnActionEvent e) {
    VcsContext context = VcsContextFactory.SERVICE.getInstance().createContextOn(e);
    Editor editor = context.getEditor();
    if (editor == null) {
      return false;
    }

    Collection annotations = editor.getUserData(KEY_IN_EDITOR);
    return annotations != null && !annotations.isEmpty();
  }
 private static boolean isActionEnabled(final AnActionEvent e) {
   Project project = e.getData(CommonDataKeys.PROJECT);
   if (project == null) return false;
   VirtualFile vFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
   if (vFile == null) return false;
   AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(vFile);
   if (vcs == null || vcs.getCommittedChangesProvider() == null || !vcs.allowsRemoteCalls(vFile)) {
     return false;
   }
   FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(vFile);
   return AbstractVcs.fileInVcsByFileStatus(project, filePath);
 }
 private void fillDeletedFiles(
     Project project,
     List<Pair<FilePath, WorkingCopyFormat>> deletedFiles,
     Collection<FilePath> deleteAnyway)
     throws SVNException {
   final SvnVcs vcs = SvnVcs.getInstance(project);
   final Collection<File> files = myDeletedFiles.remove(project);
   for (final File file : files) {
     final SVNStatus status =
         new RepeatSvnActionThroughBusy() {
           @Override
           protected void executeImpl() throws SVNException {
             myT = vcs.getFactory(file).createStatusClient().doStatus(file, false);
           }
         }.compute();
     boolean isAdded = SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus());
     final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file);
     if (isAdded) {
       deleteAnyway.add(filePath);
     } else {
       deletedFiles.add(Pair.create(filePath, vcs.getWorkingCopyFormat(file)));
     }
   }
 }
Example #6
0
 public static void markFileAsDirty(final Project project, final String path) {
   final FilePath filePath =
       VcsContextFactory.SERVICE.getInstance().createFilePathOn(new File(path));
   markFileAsDirty(project, filePath);
 }
Example #7
0
 @NotNull
 public static FilePath getFilePath(
     @NotNull VirtualFile parent, @NotNull String fileName, boolean isDirectory) {
   return VcsContextFactory.SERVICE.getInstance().createFilePath(parent, fileName, isDirectory);
 }
Example #8
0
 @NotNull
 public static FilePath getFilePath(@NotNull VirtualFile parent, @NotNull String name) {
   return VcsContextFactory.SERVICE.getInstance().createFilePathOn(parent, name);
 }
Example #9
0
 public static FilePath getFilePathForDeletedFile(@NotNull String path, boolean isDirectory) {
   return VcsContextFactory.SERVICE
       .getInstance()
       .createFilePathOnDeleted(new File(path), isDirectory);
 }
Example #10
0
 public static FilePath getFilePath(@NotNull File file, boolean isDirectory) {
   return VcsContextFactory.SERVICE.getInstance().createFilePathOn(file, isDirectory);
 }
Example #11
0
 public static FilePath getFilePathOnNonLocal(String path, boolean isDirectory) {
   return VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(path, isDirectory);
 }
Example #12
0
 public static FilePath getFilePath(@NotNull File file) {
   return VcsContextFactory.SERVICE.getInstance().createFilePathOn(file);
 }