use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchOperation method groupByBranches.
@NotNull
private static MultiMap<String, VirtualFile> groupByBranches(@NotNull Map<GitRepository, String> heads) {
MultiMap<String, VirtualFile> result = MultiMap.createLinked();
List<GitRepository> sortedRepos = DvcsUtil.sortRepositories(heads.keySet());
for (GitRepository repo : sortedRepos) {
result.putValue(heads.get(repo), repo.getRoot());
}
return result;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchOperation method updateRecentBranch.
/**
* Updates the recently visited branch in the settings.
* This is to be performed after successful checkout operation.
*/
protected void updateRecentBranch() {
if (getRepositories().size() == 1) {
GitRepository repository = myRepositories.iterator().next();
String currentHead = myCurrentHeads.get(repository);
if (currentHead != null) {
mySettings.setRecentBranchOfRepository(repository.getRoot().getPath(), currentHead);
} else {
LOG.error("Current head is not known for " + repository.getRoot().getPath());
}
} else {
String recentCommonBranch = getRecentCommonBranch();
if (recentCommonBranch != null) {
mySettings.setRecentCommonBranch(recentCommonBranch);
}
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchOperation method markSuccessful.
/**
* Marks repositories as successful, i.e. they won't be handled again.
*/
protected void markSuccessful(GitRepository... repositories) {
for (GitRepository repository : repositories) {
mySuccessfulRepositories.add(repository);
myRemainingRepositories.remove(repository);
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitMergeOperation method doMerge.
/**
* Performs merge in the given repositories.
* Handle only merge conflict situation: all other cases should have been handled before and are treated as errors.
* Conflict is treated as a success: the repository with conflict is remembered and will be handled later along with all other conflicts.
* If an error happens in one repository, the method doesn't go further in others, and shows a notification.
*
* @return true if merge has succeeded without errors (but possibly with conflicts) in all repositories;
* false if it failed at least in one of them.
*/
private boolean doMerge(@NotNull Collection<GitRepository> repositories) {
for (GitRepository repository : repositories) {
GitSimpleEventDetector mergeConflict = new GitSimpleEventDetector(GitSimpleEventDetector.Event.MERGE_CONFLICT);
GitCommandResult result = myGit.merge(repository, myBranchToMerge, Collections.<String>emptyList(), mergeConflict);
if (!result.success()) {
if (mergeConflict.hasHappened()) {
myConflictedRepositories.put(repository, Boolean.TRUE);
refresh(repository);
markSuccessful(repository);
} else {
fatalError(getCommonErrorTitle(), result.getErrorOutputAsJoinedString());
return false;
}
} else {
refresh(repository);
markSuccessful(repository);
}
}
return true;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitMergeOperation method rollback.
@Override
protected void rollback() {
LOG.info("starting rollback...");
Collection<GitRepository> repositoriesForSmartRollback = new ArrayList<>();
Collection<GitRepository> repositoriesForSimpleRollback = new ArrayList<>();
Collection<GitRepository> repositoriesForMergeRollback = new ArrayList<>();
for (GitRepository repository : getSuccessfulRepositories()) {
if (myConflictedRepositories.containsKey(repository)) {
repositoriesForMergeRollback.add(repository);
} else if (thereAreLocalChangesIn(repository)) {
repositoriesForSmartRollback.add(repository);
} else {
repositoriesForSimpleRollback.add(repository);
}
}
LOG.info("for smart rollback: " + DvcsUtil.getShortNames(repositoriesForSmartRollback) + "; for simple rollback: " + DvcsUtil.getShortNames(repositoriesForSimpleRollback) + "; for merge rollback: " + DvcsUtil.getShortNames(repositoriesForMergeRollback));
GitCompoundResult result = smartRollback(repositoriesForSmartRollback);
for (GitRepository repository : repositoriesForSimpleRollback) {
result.append(repository, rollback(repository));
}
for (GitRepository repository : repositoriesForMergeRollback) {
result.append(repository, rollbackMerge(repository));
}
myConflictedRepositories.clear();
if (!result.totalSuccess()) {
VcsNotifier.getInstance(myProject).notifyError("Error during rollback", result.getErrorOutputWithReposIndication());
}
LOG.info("rollback finished.");
}
Aggregations