mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] remove usages of GitLogUtil.collectFullDetails and deprecate the method
This commit is contained in:
@@ -204,7 +204,7 @@ public class GitCommittedChangeListProvider implements CommittedChangesProvider<
|
||||
GitVcs gitVcs = GitVcs.getInstance(project);
|
||||
|
||||
String[] hashParameters = GitHistoryUtils.formHashParameters(gitVcs, Collections.singleton(number.asString()));
|
||||
List<GitCommit> gitCommits = GitLogUtil.collectFullDetails(project, root, hashParameters);
|
||||
List<GitCommit> gitCommits = GitHistoryUtils.history(project, root, hashParameters);
|
||||
if (gitCommits.size() != 1) return null;
|
||||
|
||||
return gitCommits.get(0);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package git4idea.history;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -38,6 +39,8 @@ import static git4idea.history.GitLogParser.GitLogOption.*;
|
||||
* A collection of methods for retrieving history information from native Git.
|
||||
*/
|
||||
public class GitHistoryUtils {
|
||||
private static final Logger LOG = Logger.getInstance(GitHistoryUtils.class);
|
||||
|
||||
private GitHistoryUtils() {
|
||||
}
|
||||
|
||||
@@ -135,7 +138,18 @@ public class GitHistoryUtils {
|
||||
if (factory == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return GitLogUtil.collectFullDetails(project, root, parameters);
|
||||
|
||||
List<GitCommit> commits = ContainerUtil.newArrayList();
|
||||
try {
|
||||
GitLogUtil.readFullDetails(project, root, commits::add, true, true, false, parameters);
|
||||
}
|
||||
catch (VcsException e) {
|
||||
if (commits.isEmpty()) {
|
||||
throw e;
|
||||
}
|
||||
LOG.warn("Error during loading details, returning partially loaded commits\n", e);
|
||||
}
|
||||
return commits;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -225,6 +225,10 @@ public class GitLogUtil {
|
||||
return ContainerUtil.map(record.getParentsHashes(), factory::createHash);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link GitHistoryUtils#history(Project, VirtualFile, String...)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public static List<GitCommit> collectFullDetails(@NotNull Project project,
|
||||
@NotNull VirtualFile root,
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import git4idea.DialogManager;
|
||||
import git4idea.GitCommit;
|
||||
import git4idea.history.GitHistoryUtils;
|
||||
import git4idea.history.GitLogUtil;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -76,7 +77,7 @@ public class GitRebaseOverMergeProblem {
|
||||
@NotNull String currentRef) {
|
||||
String range = baseRef + ".." + currentRef;
|
||||
try {
|
||||
List<GitCommit> commits = GitLogUtil.collectFullDetails(project, root, range, "--merges");
|
||||
List<GitCommit> commits = GitHistoryUtils.history(project, root, range, "--merges");
|
||||
return StreamEx.of(commits).anyMatch(commit -> !commit.getChanges().isEmpty());
|
||||
}
|
||||
catch (VcsException e) {
|
||||
|
||||
@@ -4,6 +4,7 @@ package git4idea.history
|
||||
import com.intellij.openapi.vcs.Executor.echo
|
||||
import com.intellij.openapi.vcs.Executor.touch
|
||||
import com.intellij.util.CollectConsumer
|
||||
import com.intellij.util.Consumer
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails
|
||||
import git4idea.GitCommit
|
||||
@@ -47,10 +48,9 @@ class GitLogUtilTest : GitSingleRepoTest() {
|
||||
}
|
||||
expected.reverse()
|
||||
|
||||
val actualHashes = ContainerUtil.map<GitCommit, String>(GitLogUtil.collectFullDetails(myProject, repo.root,
|
||||
"--max-count=$commitCount")
|
||||
) { detail -> detail.id.asString() }
|
||||
|
||||
val actualHashes = mutableListOf<String>()
|
||||
GitLogUtil.readFullDetails(project, repo.root, Consumer<GitCommit> { actualHashes.add(it.id.asString()) },
|
||||
true, true, false, "--max-count=$commitCount")
|
||||
assertEquals(expected, actualHashes)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.vcs.log.util.VcsLogUtil
|
||||
import com.intellij.vcsUtil.VcsUtil.getFilePath
|
||||
import git4idea.GitContentRevision.createRevision
|
||||
import git4idea.GitRevisionNumber
|
||||
import git4idea.history.GitHistoryUtils
|
||||
import git4idea.history.GitLogUtil
|
||||
import git4idea.test.*
|
||||
import java.nio.charset.Charset
|
||||
@@ -214,7 +215,7 @@ class GitRevertTest : GitSingleRepoTest() {
|
||||
fun `test reverting commit doesn't preserve authorship of the original commit`() {
|
||||
file("a.txt").create("initial\n").add()
|
||||
git("commit --author='Original Author <original@example.com>' -m original_commit")
|
||||
val commit = GitLogUtil.collectFullDetails(project, projectRoot, "-1").first()
|
||||
val commit = GitHistoryUtils.history(project, projectRoot, "-1").first()
|
||||
|
||||
vcsHelper.onCommit { false }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user