private static void processGrafting(@NotNull HgRepository repository, @NotNull List<String> hashes, @NotNull IntRef totalCommitsGrafted) {
    Project project = repository.getProject();
    VirtualFile root = repository.getRoot();
    HgGraftCommand command = new HgGraftCommand(project, repository);
    HgCommandResult result = command.startGrafting(hashes);
    boolean hasConflicts = HgConflictResolver.hasConflicts(project, root);
    if (!hasConflicts && HgErrorUtil.isCommandExecutionFailed(result)) {
      new HgCommandResultNotifier(project).notifyError(GRAFT_ERROR,
                                                       result,
                                                       HgBundle.message("hg4idea.hg.error"),
                                                       HgBundle.message("action.hg4idea.Graft.error"));
      return;
    }
    final UpdatedFiles updatedFiles = UpdatedFiles.create();
    while (hasConflicts) {
      new HgConflictResolver(project, updatedFiles).resolve(root);
      hasConflicts = HgConflictResolver.hasConflicts(project, root);
      if (!hasConflicts) {
        result = command.continueGrafting();
        hasConflicts = HgConflictResolver.hasConflicts(project, root);
      }
      else {
        new HgCommandResultNotifier(project).notifyError(GRAFT_CONTINUE_ERROR,
                                                         result,
                                                         HgBundle.message("hg4idea.hg.error"),
                                                         HgBundle.message("action.hg4idea.Graft.continue.error"));
        break;
      }
    }
    if (!HgErrorUtil.isCommandExecutionFailed(result)) {
      totalCommitsGrafted.inc();
    }
    repository.update();
    root.refresh(true, true);
  }
private static void processGrafting(@NotNull HgRepository repository, @NotNull List<String> hashes, @NotNull IntRef totalCommitsGrafted)