use of git4idea.GitVcs in project intellij-community by JetBrains.
the class GitShowExternalLogAction method createManagerAndContent.
@NotNull
private static MyContentComponent createManagerAndContent(@NotNull Project project, @NotNull final GitVcs vcs, @NotNull final List<VirtualFile> roots, @Nullable String tabName) {
final GitRepositoryManager repositoryManager = GitRepositoryManager.getInstance(project);
for (VirtualFile root : roots) {
repositoryManager.addExternalRepository(root, GitRepositoryImpl.getInstance(root, project, true));
}
VcsLogManager manager = new VcsLogManager(project, ServiceManager.getService(project, VcsLogTabsProperties.class), ContainerUtil.map(roots, root -> new VcsRoot(vcs, root)));
return new MyContentComponent(manager.createLogPanel(calcLogId(roots), tabName), roots, () -> {
for (VirtualFile root : roots) {
repositoryManager.removeExternalRepository(root);
}
});
}
use of git4idea.GitVcs in project intellij-community by JetBrains.
the class GitMergeUtil method showUpdates.
/**
* Show updates caused by git operation
*
* @param project the context project
* @param exceptions the exception list
* @param root the git root
* @param currentRev the revision before update
* @param beforeLabel the local history label before update
* @param actionName the action name
* @param actionInfo the information about the action
*/
public static void showUpdates(final Project project, final List<VcsException> exceptions, final VirtualFile root, final GitRevisionNumber currentRev, final Label beforeLabel, final String actionName, final ActionInfo actionInfo) {
UpdatedFiles files = UpdatedFiles.create();
MergeChangeCollector collector = new MergeChangeCollector(project, root, currentRev);
collector.collect(files, exceptions);
if (!exceptions.isEmpty())
return;
GuiUtils.invokeLaterIfNeeded(() -> {
ProjectLevelVcsManagerEx manager = (ProjectLevelVcsManagerEx) ProjectLevelVcsManager.getInstance(project);
UpdateInfoTree tree = manager.showUpdateProjectInfo(files, actionName, actionInfo, false);
tree.setBefore(beforeLabel);
tree.setAfter(LocalHistory.getInstance().putSystemLabel(project, "After update"));
}, ModalityState.defaultModalityState());
Collection<String> unmergedNames = files.getGroupById(FileGroup.MERGED_WITH_CONFLICT_ID).getFiles();
if (!unmergedNames.isEmpty()) {
List<VirtualFile> unmerged = mapNotNull(unmergedNames, name -> LocalFileSystem.getInstance().findFileByPath(name));
GuiUtils.invokeLaterIfNeeded(() -> {
GitVcs vcs = GitVcs.getInstance(project);
if (vcs != null) {
AbstractVcsHelper.getInstance(project).showMergeDialog(unmerged, vcs.getMergeProvider());
}
}, ModalityState.defaultModalityState());
}
}
use of git4idea.GitVcs in project intellij-community by JetBrains.
the class GitChangeProvider method getChanges.
@Override
public void getChanges(@NotNull VcsDirtyScope dirtyScope, @NotNull final ChangelistBuilder builder, @NotNull final ProgressIndicator progress, @NotNull final ChangeListManagerGate addGate) throws VcsException {
final GitVcs vcs = GitVcs.getInstance(myProject);
if (vcs == null) {
// already disposed or not yet initialized => ignoring
return;
}
if (LOG.isDebugEnabled())
LOG.debug("initial dirty scope: " + dirtyScope);
appendNestedVcsRootsToDirt(dirtyScope, vcs, myVcsManager);
if (LOG.isDebugEnabled())
LOG.debug("after adding nested vcs roots to dirt: " + dirtyScope);
final Collection<VirtualFile> affected = dirtyScope.getAffectedContentRoots();
Collection<VirtualFile> roots = GitUtil.gitRootsForPaths(affected);
try {
final MyNonChangedHolder holder = new MyNonChangedHolder(myProject, dirtyScope.getDirtyFilesNoExpand(), addGate, myFileDocumentManager, myVcsManager);
for (VirtualFile root : roots) {
LOG.debug("checking root: " + root.getPath());
GitChangesCollector collector = isNewGitChangeProviderAvailable() ? GitNewChangesCollector.collect(myProject, myGit, myChangeListManager, myVcsManager, vcs, dirtyScope, root) : GitOldChangesCollector.collect(myProject, myChangeListManager, myVcsManager, vcs, dirtyScope, root);
final Collection<Change> changes = collector.getChanges();
holder.changed(changes);
for (Change file : changes) {
LOG.debug("process change: " + ChangesUtil.getFilePath(file).getPath());
builder.processChange(file, GitVcs.getKey());
}
for (VirtualFile f : collector.getUnversionedFiles()) {
builder.processUnversionedFile(f);
holder.unversioned(f);
}
holder.feedBuilder(builder);
}
} catch (VcsException e) {
LOG.info(e);
// most probably the error happened because git is not configured
vcs.getExecutableValidator().showNotificationOrThrow(e);
}
}
use of git4idea.GitVcs in project intellij-community by JetBrains.
the class GitChangeProvider method isNewGitChangeProviderAvailable.
private boolean isNewGitChangeProviderAvailable() {
GitVcs vcs = GitVcs.getInstance(myProject);
if (vcs == null) {
return false;
}
final GitVersion version = vcs.getVersion();
return GitVersionSpecialty.KNOWS_STATUS_PORCELAIN.existsIn(version);
}
use of git4idea.GitVcs in project intellij-community by JetBrains.
the class GitFetcher method displayFetchResult.
public static void displayFetchResult(@NotNull Project project, @NotNull GitFetchResult result, @Nullable String errorNotificationTitle, @NotNull Collection<? extends Exception> errors) {
if (result.isSuccess()) {
VcsNotifier.getInstance(project).notifySuccess("Fetched successfully" + result.getAdditionalInfo());
} else if (result.isCancelled()) {
VcsNotifier.getInstance(project).notifyMinorWarning("", "Fetch cancelled by user" + result.getAdditionalInfo());
} else if (result.isNotAuthorized()) {
String title;
String description;
if (errorNotificationTitle != null) {
title = errorNotificationTitle;
description = "Fetch failed: couldn't authorize";
} else {
title = "Fetch failed";
description = "Couldn't authorize";
}
description += result.getAdditionalInfo();
GitUIUtil.notifyMessage(project, title, description, true, null);
} else {
GitVcs instance = GitVcs.getInstance(project);
if (instance != null && instance.getExecutableValidator().isExecutableValid()) {
GitUIUtil.notifyMessage(project, "Fetch failed", result.getAdditionalInfo(), true, errors);
}
}
}
Aggregations