use of org.zmlx.hg4idea.provider.update.HgConflictResolver in project intellij-community by JetBrains.
the class HgUpdateCommand method updateRepoToInCurrentThread.
public static boolean updateRepoToInCurrentThread(@NotNull final Project project, @NotNull final VirtualFile repository, @NotNull final String targetRevision, final boolean clean) {
final HgUpdateCommand hgUpdateCommand = new HgUpdateCommand(project, repository);
hgUpdateCommand.setRevision(targetRevision);
hgUpdateCommand.setClean(clean);
HgCommandResult result = hgUpdateCommand.execute();
new HgConflictResolver(project).resolve(repository);
boolean success = !HgErrorUtil.isCommandExecutionFailed(result);
boolean hasUnresolvedConflicts = HgConflictResolver.hasConflicts(project, repository);
if (!success) {
new HgCommandResultNotifier(project).notifyError(result, "", "Update failed");
} else if (hasUnresolvedConflicts) {
new VcsNotifier(project).notifyImportantWarning("Unresolved conflicts.", HgVcsMessages.message("hg4idea.update.warning.merge.conflicts", repository.getPath()));
}
getRepositoryManager(project).updateRepository(repository);
HgErrorUtil.markDirtyAndHandleErrors(project, repository);
return success;
}
use of org.zmlx.hg4idea.provider.update.HgConflictResolver in project intellij-community by JetBrains.
the class HgMergeCommand method mergeWith.
public static void mergeWith(@NotNull final HgRepository repository, @NotNull final String branchName, @NotNull final UpdatedFiles updatedFiles, @Nullable final Runnable onSuccessHandler) {
final Project project = repository.getProject();
final VirtualFile repositoryRoot = repository.getRoot();
final HgMergeCommand hgMergeCommand = new HgMergeCommand(project, repository);
//there is no difference between branch or revision or bookmark as parameter to merge,
hgMergeCommand.setRevision(branchName);
// we need just a string
new Task.Backgroundable(project, "Merging Changes...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
HgCommandResult result = hgMergeCommand.mergeSynchronously();
if (HgErrorUtil.isAncestorMergeError(result)) {
//skip and notify
VcsNotifier.getInstance(project).notifyMinorWarning("Merging is skipped for " + repositoryRoot.getPresentableName(), "Merging with a working directory ancestor has no effect");
return;
}
new HgConflictResolver(project, updatedFiles).resolve(repositoryRoot);
if (!HgConflictResolver.hasConflicts(project, repositoryRoot) && onSuccessHandler != null) {
// for example commit changes
onSuccessHandler.run();
}
} catch (VcsException exception) {
if (exception.isWarning()) {
VcsNotifier.getInstance(project).notifyWarning("Warning during merge", exception.getMessage());
} else {
VcsNotifier.getInstance(project).notifyError("Exception during merge", exception.getMessage());
}
}
}
}.queue();
}
use of org.zmlx.hg4idea.provider.update.HgConflictResolver in project intellij-community by JetBrains.
the class HgCherryPicker method processGrafting.
private static void processGrafting(@NotNull HgRepository repository, @NotNull List<String> hashes) {
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(result, "Hg Error", "Couldn't graft.");
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(result, "Hg Error", "Couldn't continue grafting");
break;
}
}
repository.update();
root.refresh(true, true);
}
Aggregations