private GitUpdateResult handleRebaseFailure( GitLineHandler pullHandler, GitRebaseProblemDetector rebaseConflictDetector, final GitMessageWithFilesDetector untrackedWouldBeOverwrittenDetector) { if (rebaseConflictDetector.isMergeConflict()) { LOG.info("handleRebaseFailure merge conflict"); final boolean allMerged = new MyConflictResolver(myProject, myGit, myRoot, myRebaser).merge(); return allMerged ? GitUpdateResult.SUCCESS_WITH_RESOLVED_CONFLICTS : GitUpdateResult.INCOMPLETE; } else if (untrackedWouldBeOverwrittenDetector.wasMessageDetected()) { LOG.info("handleRebaseFailure: untracked files would be overwritten by checkout"); UntrackedFilesNotifier.notifyUntrackedFilesOverwrittenBy( myProject, ServiceManager.getService(myProject, GitPlatformFacade.class), untrackedWouldBeOverwrittenDetector.getFiles(), "rebase", null); return GitUpdateResult.ERROR; } else { LOG.info("handleRebaseFailure error " + pullHandler.errors()); GitUIUtil.notifyImportantError( myProject, "Rebase error", GitUIUtil.stringifyErrors(pullHandler.errors())); return GitUpdateResult.ERROR; } }
/** * When checkout or merge operation on a repository fails with the error "local changes would be * overwritten by...", affected local files are captured by the {@link * git4idea.commands.GitMessageWithFilesDetector detector}. Then all remaining (non successful * repositories) are searched if they are about to fail with the same problem. All collected local * changes which prevent the operation, together with these repositories, are returned. * * @param currentRepository The first repository which failed the operation. * @param localChangesOverwrittenBy The detector of local changes would be overwritten by * merge/checkout. * @param currentBranch Current branch. * @param nextBranch Branch to compare with (the branch to be checked out, or the branch to be * merged). * @return Repositories that have failed or would fail with the "local changes" error, together * with these local changes. */ @NotNull protected Pair<List<GitRepository>, List<Change>> getConflictingRepositoriesAndAffectedChanges( @NotNull GitRepository currentRepository, @NotNull GitMessageWithFilesDetector localChangesOverwrittenBy, String currentBranch, String nextBranch) { // get changes overwritten by checkout from the error message captured from Git List<Change> affectedChanges = convertPathsToChanges( currentRepository, localChangesOverwrittenBy.getRelativeFilePaths(), true); // get all other conflicting changes // get changes in all other repositories (except those which already have succeeded) to avoid // multiple dialogs proposing smart checkout Map<GitRepository, List<Change>> conflictingChangesInRepositories = collectLocalChangesConflictingWithBranch( getRemainingRepositoriesExceptGiven(currentRepository), currentBranch, nextBranch); Set<GitRepository> otherProblematicRepositories = conflictingChangesInRepositories.keySet(); List<GitRepository> allConflictingRepositories = new ArrayList<GitRepository>(otherProblematicRepositories); allConflictingRepositories.add(currentRepository); for (List<Change> changes : conflictingChangesInRepositories.values()) { affectedChanges.addAll(changes); } return Pair.create(allConflictingRepositories, affectedChanges); }