@NotNull public static <CommitInfo> List<CommitInfo> getCommitRecords( @NotNull Project project, @Nullable HgCommandResult result, @NotNull Function<String, CommitInfo> converter, boolean silent) { final List<CommitInfo> revisions = new LinkedList<CommitInfo>(); if (result == null) { return revisions; } List<String> errors = result.getErrorLines(); if (errors != null && !errors.isEmpty()) { if (result.getExitValue() != 0) { if (silent) { LOG.warn(errors.toString()); } else { VcsNotifier.getInstance(project) .notifyError( HgVcsMessages.message("hg4idea.error.log.command.execution"), errors.toString()); } return Collections.emptyList(); } LOG.warn(errors.toString()); } String output = result.getRawOutput(); List<String> changeSets = StringUtil.split(output, HgChangesetUtil.CHANGESET_SEPARATOR); return ContainerUtil.mapNotNull(changeSets, converter); }
private void commitOrWarnAboutConflicts( List<VcsException> exceptions, HgCommandResult mergeResult) throws VcsException { if (mergeResult.getExitValue() == 0) { // operation successful and no conflicts try { new HgCommitCommand(project, repoRoot, "Automated merge").execute(); } catch (HgCommandException e) { throw new VcsException(e); } } else { reportWarning( exceptions, HgVcsMessages.message("hg4idea.update.warning.merge.conflicts", repoRoot.getPath())); } }
private void processRebase(final UpdatedFiles updatedFiles) throws VcsException { HgRepository repository = HgUtil.getRepositoryManager(project).getRepositoryForRoot(repoRoot); HgCommandResult result; do { resolvePossibleConflicts(updatedFiles); if (repository == null || !HgConflictResolver.findConflicts(project, repoRoot).isEmpty()) { return; } HgRebaseCommand rebaseCommand = new HgRebaseCommand(project, repository); result = rebaseCommand.continueRebase(); if (HgErrorUtil.isAbort(result)) { new HgCommandResultNotifier(project) .notifyError(result, "Hg Error", "Couldn't continue rebasing"); return; } } while (result.getExitValue() == 1); }
@NotNull public static Collection<String> getDescendingHeadsOfBranches( @NotNull Project project, @NotNull VirtualFile root, @NotNull Hash hash) throws VcsException { // hg log -r "descendants(659db54c1b6865c97c4497fa867194bcd759ca76) and head()" --template // "{branch}{bookmarks}" Set<String> branchHeads = new HashSet<String>(); List<String> params = new ArrayList<String>(); params.add("-r"); params.add("descendants(" + hash.asString() + ") and head()"); HgLogCommand hgLogCommand = new HgLogCommand(project); hgLogCommand.setLogFile(false); String template = HgChangesetUtil.makeTemplate("{branch}", "{bookmarks}"); HgCommandResult logResult = hgLogCommand.execute(root, template, -1, null, params); if (logResult == null || logResult.getExitValue() != 0) { throw new VcsException("Couldn't get commit details: log command execution error."); } String output = logResult.getRawOutput(); List<String> changeSets = StringUtil.split(output, HgChangesetUtil.CHANGESET_SEPARATOR); for (String line : changeSets) { List<String> attributes = StringUtil.split(line, HgChangesetUtil.ITEM_SEPARATOR); branchHeads.addAll(attributes); } return branchHeads; }