com.intellij.openapi.vcs.diff.DiffProvider Java Examples

The following examples show how to use com.intellij.openapi.vcs.diff.DiffProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VcsHistoryProviderBackgroundableProxy.java    From consulo with Apache License 2.0 6 votes vote down vote up
public VcsHistoryProviderBackgroundableProxy(final AbstractVcs vcs, final VcsHistoryProvider delegate, DiffProvider diffProvider) {
  myDelegate = delegate;
  myProject = vcs.getProject();
  myConfiguration = VcsConfiguration.getInstance(myProject);
  myCachesHistory = myDelegate instanceof VcsCacheableHistorySessionFactory;
  myDiffProvider = diffProvider;
  myVcsHistoryCache = ProjectLevelVcsManager.getInstance(myProject).getVcsHistoryCache();
  myType = vcs.getType();
  myHistoryComputerFactory = new HistoryComputerFactory() {
    @Override
    public ThrowableComputable<VcsHistorySession, VcsException> create(FilePath filePath,
                                                                       Consumer<VcsHistorySession> consumer,
                                                                       VcsKey vcsKey) {
      if (myCachesHistory) {
        return new CachingHistoryComputer(filePath, consumer, vcsKey);
      } else {
        return new SimpleHistoryComputer(filePath, consumer);
      }
    }
  };
}
 
Example #2
Source File: SelectAndCompareWithSelectedRevisionAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void actionPerformed(VcsContext vcsContext) {

    final VirtualFile file = vcsContext.getSelectedFiles()[0];
    final Project project = vcsContext.getProject();
    final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
    if (vcs == null) {
      return;
    }
    RevisionSelector selector = vcs.getRevisionSelector();
    final DiffProvider diffProvider = vcs.getDiffProvider();

    if (selector != null) {
      final VcsRevisionNumber vcsRevisionNumber = selector.selectNumber(file);

      if (vcsRevisionNumber != null) {
        DiffActionExecutor.showDiff(diffProvider, vcsRevisionNumber, file, project, VcsBackgroundableActions.COMPARE_WITH);
      }
    }

  }
 
Example #3
Source File: ChangesCacheFile.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean refreshIncomingChanges() throws IOException, VcsException {
  if (myProject.isDisposed()) return false;

  DiffProvider diffProvider = myVcs.getDiffProvider();
  if (diffProvider == null) return false;

  return new RefreshIncomingChangesOperation(this, myProject, diffProvider).invoke();
}
 
Example #4
Source File: CompareWithSelectedRevisionAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void showTreePopup(final List<TreeItem<VcsFileRevision>> roots, final VirtualFile file, final Project project, final DiffProvider diffProvider) {
  final TreeTableView treeTable = new TreeTableView(new ListTreeTableModelOnColumns(new TreeNodeAdapter(null, null, roots),
                                                                                    new ColumnInfo[]{BRANCH_COLUMN, REVISION_COLUMN,
                                                                                    DATE_COLUMN, AUTHOR_COLUMN}));
  Runnable runnable = new Runnable() {
    public void run() {
      int index = treeTable.getSelectionModel().getMinSelectionIndex();
      if (index == -1) {
        return;
      }
      VcsFileRevision revision = getRevisionAt(treeTable, index);
      if (revision != null) {
        DiffActionExecutor.showDiff(diffProvider, revision.getRevisionNumber(), file, project, VcsBackgroundableActions.COMPARE_WITH);
      }
    }
  };

  treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  new PopupChooserBuilder(treeTable).
    setTitle(VcsBundle.message("lookup.title.vcs.file.revisions")).
    setItemChoosenCallback(runnable).
    setSouthComponent(createCommentsPanel(treeTable)).
    setResizable(true).
    setDimensionServiceKey("Vcs.CompareWithSelectedRevision.Popup").
    createPopup().
    showCenteredInCurrentWindow(project);
}
 
Example #5
Source File: TFSVcs.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Override
public DiffProvider getDiffProvider() {
    if (myDiffProvider == null) {
        myDiffProvider = new TFSDiffProvider(myProject);
    }
    return myDiffProvider;
}
 
Example #6
Source File: DiffActionExecutor.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected DiffActionExecutor(final DiffProvider diffProvider, final VirtualFile selectedFile, final Project project,
                             final VcsBackgroundableActions actionKey) {
  final ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(project);
  myHandler = vcsManager.getBackgroundableActionHandler(actionKey);
  myDiffProvider = diffProvider;
  mySelectedFile = selectedFile;
  myProject = project;
}
 
Example #7
Source File: VcsAnnotationLocalChangesListenerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private VcsRevisionNumber fromDiffProvider(final VirtualFile vf) {
  final VcsRoot vcsRoot = myVcsManager.getVcsRootObjectFor(vf);
  DiffProvider diffProvider;
  if (vcsRoot != null && vcsRoot.getVcs() != null && (diffProvider = vcsRoot.getVcs().getDiffProvider()) != null) {
    return diffProvider.getCurrentRevision(vf);
  }
  return null;
}
 
Example #8
Source File: VcsCurrentRevisionProxy.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static VcsCurrentRevisionProxy create(@Nonnull VirtualFile file, @Nonnull Project project) {
  AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
  if (vcs != null) {
    DiffProvider diffProvider = vcs.getDiffProvider();
    if (diffProvider != null) {
      return new VcsCurrentRevisionProxy(diffProvider, file, project, vcs.getKeyInstanceMethod());
    }
  }
  return null;
}
 
Example #9
Source File: AbstractShowDiffAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void actionPerformed(VcsContext vcsContext) {
  final Project project = vcsContext.getProject();
  if (project == null) return;
  if (ChangeListManager.getInstance(project).isFreezedWithNotification("Can not " + vcsContext.getActionName() + " now")) return;
  final VirtualFile selectedFile = vcsContext.getSelectedFiles()[0];

  final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
  final AbstractVcs vcs = vcsManager.getVcsFor(selectedFile);
  final DiffProvider diffProvider = vcs.getDiffProvider();

  final DiffActionExecutor actionExecutor = getExecutor(diffProvider, selectedFile, project);
  actionExecutor.showDiff();
}
 
Example #10
Source File: AbstractShowDiffAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
protected static AbstractVcs isEnabled(final VcsContext vcsContext, @Nullable final VcsBackgroundableActions actionKey) {
  if (!(isVisible(vcsContext))) return null;

  final Project project = vcsContext.getProject();
  if (project == null) return null;
  final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);

  final VirtualFile[] selectedFilePaths = vcsContext.getSelectedFiles();
  if (selectedFilePaths == null || selectedFilePaths.length != 1) return null;

  final VirtualFile selectedFile = selectedFilePaths[0];
  if (selectedFile.isDirectory()) return null;

  if (actionKey != null) {
    final BackgroundableActionEnabledHandler handler = ((ProjectLevelVcsManagerImpl)vcsManager).getBackgroundableActionHandler(actionKey);
    if (handler.isInProgress(VcsBackgroundableActions.keyFrom(selectedFile))) return null;
  }

  final AbstractVcs vcs = vcsManager.getVcsFor(selectedFile);
  if (vcs == null) return null;

  final DiffProvider diffProvider = vcs.getDiffProvider();

  if (diffProvider == null) return null;

  if (AbstractVcs.fileInVcsByFileStatus(project, new FilePathImpl(selectedFile))) {
    return vcs;
  }
  return null;
}
 
Example #11
Source File: VcsAnnotationCachedProxy.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public FileAnnotation annotate(final VirtualFile file) throws VcsException {
  final DiffProvider diffProvider = myVcs.getDiffProvider();
  final VcsRevisionNumber currentRevision = diffProvider.getCurrentRevision(file);

  return annotate(file, currentRevision, true, new ThrowableComputable<FileAnnotation, VcsException>() {
    @Override
    public FileAnnotation compute() throws VcsException {
      return myAnnotationProvider.annotate(file);
    }
  });
}
 
Example #12
Source File: VcsCurrentRevisionProxy.java    From consulo with Apache License 2.0 5 votes vote down vote up
private VcsCurrentRevisionProxy(@Nonnull DiffProvider diffProvider,
                                @Nonnull VirtualFile file,
                                @Nonnull Project project,
                                @Nonnull VcsKey vcsKey) {
  myDiffProvider = diffProvider;
  myFile = file;
  myProject = project;
  myVcsKey = vcsKey;
}
 
Example #13
Source File: RemoteRevisionsNumbersCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void consume(String s) {
  LOG.debug("update for: " + s);
  //todo check canceled - check VCS's ready for asynchronous queries
  // get last remote revision for file
  final VirtualFile vf = myLfs.refreshAndFindFileByIoFile(new File(s));
  final ItemLatestState state;
  final DiffProvider diffProvider = myVcsRoot.getVcs().getDiffProvider();
  if (vf == null) {
    // doesnt matter if directory or not
    state = diffProvider.getLastRevision(VcsUtil.getFilePath(s, false));
  } else {
    state = diffProvider.getLastRevision(vf);
  }
  final VcsRevisionNumber newNumber = (state == null) || state.isDefaultHead() ? UNKNOWN : state.getNumber();

  final Pair<VcsRoot, VcsRevisionNumber> oldPair;
  // update value in cache
  synchronized (myLock) {
    oldPair = myData.get(s);
    myData.put(s, Pair.create(myVcsRoot, newNumber));
  }

  if (oldPair == null || oldPair.getSecond().compareTo(newNumber) != 0) {
    LOG.debug("refresh triggered by " + s);
    mySomethingChanged = true;
  }
}
 
Example #14
Source File: MockAbstractVcs.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setDiffProvider(final DiffProvider diffProvider) {
  myDiffProvider = diffProvider;
}
 
Example #15
Source File: MockAbstractVcs.java    From consulo with Apache License 2.0 4 votes vote down vote up
public DiffProvider getDiffProvider() {
  return myDiffProvider;
}
 
Example #16
Source File: ChangesCacheFile.java    From consulo with Apache License 2.0 4 votes vote down vote up
RefreshIncomingChangesOperation(ChangesCacheFile changesCacheFile, Project project, final DiffProvider diffProvider) {
  myChangesCacheFile = changesCacheFile;
  myProject = project;
  myDiffProvider = diffProvider;
  myClManager = ChangeListManagerImpl.getInstanceImpl(project);
}
 
Example #17
Source File: DiffActionExecutor.java    From consulo with Apache License 2.0 4 votes vote down vote up
public CompareToFixedExecutor(final DiffProvider diffProvider,
                              final VirtualFile selectedFile, final Project project, final VcsRevisionNumber number,
                              final VcsBackgroundableActions actionKey) {
  super(diffProvider, selectedFile, project, actionKey);
  myNumber = number;
}
 
Example #18
Source File: DiffActionExecutor.java    From consulo with Apache License 2.0 4 votes vote down vote up
public DeletionAwareExecutor(final DiffProvider diffProvider,
                             final VirtualFile selectedFile, final Project project, final VcsBackgroundableActions actionKey) {
  super(diffProvider, selectedFile, project, actionKey);
}
 
Example #19
Source File: DiffActionExecutor.java    From consulo with Apache License 2.0 4 votes vote down vote up
public CompareToCurrentExecutor(final DiffProvider diffProvider, final VirtualFile selectedFile, final Project project,
                                final VcsBackgroundableActions actionKey) {
  super(diffProvider, selectedFile, project, actionKey);
}
 
Example #20
Source File: DiffActionExecutor.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void showDiff(final DiffProvider diffProvider, final VcsRevisionNumber revisionNumber, final VirtualFile selectedFile,
                            final Project project, final VcsBackgroundableActions actionKey) {
  final DiffActionExecutor executor = new CompareToFixedExecutor(diffProvider, selectedFile, project, revisionNumber, actionKey);
  executor.showDiff();
}
 
Example #21
Source File: CompareWithLastVersion.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected DiffActionExecutor getExecutor(final DiffProvider diffProvider, final VirtualFile selectedFile, final Project project) {
  return new DiffActionExecutor.DeletionAwareExecutor(diffProvider, selectedFile, project, getKey());
}
 
Example #22
Source File: AbstractShowDiffAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected DiffActionExecutor getExecutor(final DiffProvider diffProvider, final VirtualFile selectedFile, final Project project) {
  return new DiffActionExecutor.CompareToCurrentExecutor(diffProvider, selectedFile, project, getKey());
}
 
Example #23
Source File: AbstractVcs.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public DiffProvider getDiffProvider() {
  return null;
}
 
Example #24
Source File: GtUtil.java    From GitToolBox with Apache License 2.0 4 votes vote down vote up
@NotNull
public static VcsRevisionNumber getCurrentRevision(@NotNull Project project, @NotNull VirtualFile file) {
  DiffProvider diffProvider = GitVcs.getInstance(project).getDiffProvider();
  VcsRevisionNumber currentRevision = diffProvider.getCurrentRevision(file);
  return ObjectUtils.defaultIfNull(currentRevision, VcsRevisionNumber.NULL);
}
 
Example #25
Source File: P4Vcs.java    From p4ic4idea with Apache License 2.0 4 votes vote down vote up
@Override
@Nullable
public DiffProvider getDiffProvider() {
    return diffProvider;
}