use of git4idea.repo.GitRepository 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.repo.GitRepository in project intellij-community by JetBrains.
the class DeepComparator method getRepositories.
@NotNull
private Map<GitRepository, GitBranch> getRepositories(@NotNull Map<VirtualFile, VcsLogProvider> providers, @NotNull String branchToCompare) {
Map<GitRepository, GitBranch> repos = ContainerUtil.newHashMap();
for (VirtualFile root : providers.keySet()) {
GitRepository repository = myRepositoryManager.getRepositoryForRoot(root);
if (repository == null || repository.getCurrentBranch() == null || repository.getBranches().findBranchByName(branchToCompare) == null) {
continue;
}
repos.put(repository, repository.getCurrentBranch());
}
return repos;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchIsNotFullyMergedDialog method createNorthPanel.
@Override
protected JComponent createNorthPanel() {
JBLabel descriptionLabel = new JBLabel(makeDescription(myInitialRepository));
JComboBox repositorySelector = new JComboBox(ArrayUtil.toObjectArray(myRepositories, GitRepository.class));
repositorySelector.setRenderer(new GitRepositoryComboboxListCellRenderer(repositorySelector));
repositorySelector.setSelectedItem(myInitialRepository);
repositorySelector.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
GitRepository selectedRepo = (GitRepository) repositorySelector.getSelectedItem();
descriptionLabel.setText(makeDescription(selectedRepo));
myCommitListWithDiffPanel.setCommits(myCommits.get(selectedRepo));
}
});
JPanel repoSelectorPanel = new JPanel(new BorderLayout());
JBLabel label = new JBLabel("Repository: ");
label.setLabelFor(repoSelectorPanel);
repoSelectorPanel.add(label, BorderLayout.WEST);
repoSelectorPanel.add(repositorySelector);
if (myRepositories.size() < 2) {
repoSelectorPanel.setVisible(false);
}
JPanel northPanel = new JPanel(new BorderLayout());
northPanel.add(descriptionLabel);
northPanel.add(repoSelectorPanel, BorderLayout.SOUTH);
return northPanel;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchOperation method collectLocalChangesConflictingWithBranch.
/**
* TODO this is non-optimal and even incorrect, since such diff shows the difference between committed changes
* For each of the given repositories looks to the diff between current branch and the given branch and converts it to the list of
* local changes.
*/
@NotNull
Map<GitRepository, List<Change>> collectLocalChangesConflictingWithBranch(@NotNull Collection<GitRepository> repositories, @NotNull String currentBranch, @NotNull String otherBranch) {
Map<GitRepository, List<Change>> changes = new HashMap<>();
for (GitRepository repository : repositories) {
try {
Collection<String> diff = GitUtil.getPathsDiffBetweenRefs(myGit, repository, currentBranch, otherBranch);
List<Change> changesInRepo = GitUtil.findLocalChangesForPaths(myProject, repository.getRoot(), diff, false);
if (!changesInRepo.isEmpty()) {
changes.put(repository, changesInRepo);
}
} catch (VcsException e) {
// ignoring the exception: this is not fatal if we won't collect such a diff from other repositories.
// At worst, use will get double dialog proposing the smart checkout.
LOG.warn(String.format("Couldn't collect diff between %s and %s in %s", currentBranch, otherBranch, repository.getRoot()), e);
}
}
return changes;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchOperation method markSkip.
/**
* Marks repositories as successful, i.e. they won't be handled again.
*/
protected void markSkip(GitRepository... repositories) {
for (GitRepository repository : repositories) {
mySkippedRepositories.add(repository);
myRemainingRepositories.remove(repository);
}
}
Aggregations