diff options
author | Tor Norbye <tnorbye@google.com> | 2014-08-20 17:01:23 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-08-20 17:01:23 -0700 |
commit | 1aa2e09bdbd413eacb677e9fa4b50630530d0656 (patch) | |
tree | 2f4cc6d69645bd460aa253fdecb606d764fbd25d /plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java | |
parent | 02cf98d65c798d368fcec43ed64a001d513bdd4f (diff) | |
download | idea-1aa2e09bdbd413eacb677e9fa4b50630530d0656.tar.gz |
Snapshot idea/138.1696 from git://git.jetbrains.org/idea/community.git
Change-Id: I50c97b83a815ce635e49a38380ba5b8765e4b16a
Diffstat (limited to 'plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java')
-rw-r--r-- | plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java index dfb576f98ab3..de565484e2d5 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java @@ -94,25 +94,35 @@ public class HgHistoryUtil { } /** - * <p>Get & parse hg log detailed output with commits, their parents and their changes.</p> + * <p>Get & parse hg log detailed output with commits, their parents and their changes. + * For null destination return log command result</p> * <p/> * <p>Warning: this is method is efficient by speed, but don't query too much, because the whole log output is retrieved at once, * and it can occupy too much memory. The estimate is ~600Kb for 1000 commits.</p> */ @NotNull - public static List<? extends VcsFullCommitDetails> history(@NotNull final Project project, @NotNull final VirtualFile root, int limit, + public static List<? extends VcsFullCommitDetails> history(@NotNull final Project project, + @NotNull final VirtualFile root, + int limit, @NotNull List<String> parameters) throws VcsException { - final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project); - if (factory == null) { - return Collections.emptyList(); - } HgVcs hgvcs = HgVcs.getInstance(project); assert hgvcs != null; final HgVersion version = hgvcs.getVersion(); String[] templates = HgBaseLogParser.constructFullTemplateArgument(true, version); HgCommandResult result = getLogResult(project, root, version, limit, parameters, HgChangesetUtil.makeTemplate(templates)); + return createFullCommitsFromResult(project, root, result, version, false); + } + + public static List<? extends VcsFullCommitDetails> createFullCommitsFromResult(@NotNull Project project, + @NotNull VirtualFile root, + @Nullable HgCommandResult result, + @NotNull HgVersion version, boolean silent) { + final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project); + if (factory == null) { + return Collections.emptyList(); + } List<HgFileRevision> hgRevisions = - getCommitRecords(project, result, new HgFileRevisionLogParser(project, getOriginalHgFile(project, root), version)); + getCommitRecords(project, result, new HgFileRevisionLogParser(project, getOriginalHgFile(project, root), version), silent); List<VcsFullCommitDetails> vcsFullCommitDetailsList = new ArrayList<VcsFullCommitDetails>(); for (HgFileRevision revision : hgRevisions) { @@ -184,6 +194,13 @@ public class HgHistoryUtil { public static <CommitInfo> List<CommitInfo> getCommitRecords(@NotNull Project project, @Nullable HgCommandResult result, @NotNull Function<String, CommitInfo> converter) { + return getCommitRecords(project, result, converter, false); + } + + @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; @@ -192,7 +209,12 @@ public class HgHistoryUtil { List<String> errors = result.getErrorLines(); if (errors != null && !errors.isEmpty()) { if (result.getExitValue() != 0) { - VcsNotifier.getInstance(project).notifyError(HgVcsMessages.message("hg4idea.error.log.command.execution"), errors.toString()); + 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()); @@ -331,4 +353,8 @@ public class HgHistoryUtil { } return branchHeads; } + + public static String prepareParameter(String paramName, String value) { + return "--" + paramName + "=" + value; // no value escaping needed, because the parameter itself will be quoted by GeneralCommandLine + } } |