use of git4idea.GitVcs in project intellij-community by JetBrains.
the class GitResolveConflictsAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
Project project = ObjectUtils.assertNotNull(event.getProject());
GitVcs vcs = ObjectUtils.assertNotNull(GitVcs.getInstance(project));
final Set<VirtualFile> conflictedFiles = new TreeSet<>(new Comparator<VirtualFile>() {
@Override
public int compare(@NotNull VirtualFile f1, @NotNull VirtualFile f2) {
return f1.getPresentableUrl().compareTo(f2.getPresentableUrl());
}
});
for (Change change : ChangeListManager.getInstance(project).getAllChanges()) {
if (change.getFileStatus() != FileStatus.MERGED_WITH_CONFLICTS) {
continue;
}
ContentRevision before = change.getBeforeRevision();
ContentRevision after = change.getAfterRevision();
if (before != null) {
VirtualFile file = before.getFile().getVirtualFile();
if (file != null) {
conflictedFiles.add(file);
}
}
if (after != null) {
VirtualFile file = after.getFile().getVirtualFile();
if (file != null) {
conflictedFiles.add(file);
}
}
}
AbstractVcsHelper.getInstance(project).showMergeDialog(newArrayList(conflictedFiles), vcs.getMergeProvider());
for (GitRepository repository : GitUtil.getRepositoriesForFiles(project, conflictedFiles)) {
repository.update();
}
}
use of git4idea.GitVcs in project intellij-community by JetBrains.
the class GitAnnotationProvider method annotate.
@NotNull
private GitFileAnnotation annotate(@NotNull final FilePath repositoryFilePath, @Nullable final VcsRevisionNumber revision, @NotNull final VirtualFile file) throws VcsException {
GitVcs vcs = GitVcs.getInstance(myProject);
assert vcs != null;
VcsRevisionNumber actualRevision = revision != null ? revision : vcs.getDiffProvider().getCurrentRevision(file);
if (actualRevision != null) {
Object annotatedData = myCache.get(repositoryFilePath, GitVcs.getKey(), actualRevision);
if (annotatedData instanceof CachedData)
return restoreFromCache(file, actualRevision, (CachedData) annotatedData);
}
GitFileAnnotation fileAnnotation = doAnnotate(repositoryFilePath, actualRevision, file);
if (actualRevision != null) {
myCache.put(repositoryFilePath, GitVcs.getKey(), actualRevision, cacheData(fileAnnotation));
}
return fileAnnotation;
}
use of git4idea.GitVcs in project intellij-community by JetBrains.
the class GitRepositoryAction method actionPerformed.
public void actionPerformed(@NotNull final AnActionEvent e) {
FileDocumentManager.getInstance().saveAllDocuments();
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
GitVcs vcs = GitVcs.getInstance(project);
final List<VirtualFile> roots = getGitRoots(project, vcs);
if (roots == null)
return;
final VirtualFile defaultRoot = getDefaultRoot(project, roots, e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY));
perform(project, roots, defaultRoot);
}
use of git4idea.GitVcs in project intellij-community by JetBrains.
the class BasicAction method update.
/**
* Disable the action if the event does not apply in this context.
*
* @param e The update event
*/
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
Presentation presentation = e.getPresentation();
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) {
presentation.setEnabled(false);
presentation.setVisible(false);
return;
}
VirtualFile[] vFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (vFiles == null || vFiles.length == 0) {
presentation.setEnabled(false);
presentation.setVisible(true);
return;
}
GitVcs vcs = GitVcs.getInstance(project);
boolean enabled = ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, vFiles) && isEnabled(project, vcs, vFiles);
// only enable action if all the targets are under the vcs and the action supports all of them
presentation.setEnabled(enabled);
if (ActionPlaces.isPopupPlace(e.getPlace())) {
presentation.setVisible(enabled);
} else {
presentation.setVisible(true);
}
}
use of git4idea.GitVcs in project intellij-community by JetBrains.
the class GitCloneAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
GitVcs vcs = assertNotNull(GitVcs.getInstance(project));
vcs.getCheckoutProvider().doCheckout(project, ProjectLevelVcsManager.getInstance(project).getCompositeCheckoutListener());
}
Aggregations