mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[log] IDEA-121875 Enable manual commits sorting in VCS that support it
If the VCS can return unordered commits faster (like Git does), request more unordered commits & sort them by hands.
This commit is contained in:
@@ -95,4 +95,10 @@ public interface VcsLogProvider {
|
||||
@NotNull
|
||||
Collection<String> getContainingBranches(@NotNull VirtualFile root, @NotNull Hash commitHash) throws VcsException;
|
||||
|
||||
/**
|
||||
* Return true if the VCS supports some mode in which commits can be received faster, but unordered. <br/>
|
||||
* In this case the VCS Log will order commits manually
|
||||
*/
|
||||
boolean supportsFastUnorderedCommits();
|
||||
|
||||
}
|
||||
|
||||
@@ -440,7 +440,12 @@ public class VcsLogDataHolder implements Disposable, VcsLogDataProvider {
|
||||
RecentCommitsInfo info = entry.getValue();
|
||||
|
||||
// in this case new commits won't be attached to the log, but will substitute existing ones.
|
||||
List<TimedVcsCommit> firstBlockCommits = new VcsLogSorter<TimedVcsCommit>().sortByDateTopoOrder(info.firstBlockCommits);
|
||||
List<TimedVcsCommit> firstBlockCommits = info.firstBlockCommits;
|
||||
if (getLogProvider(root).supportsFastUnorderedCommits()) {
|
||||
// => we requested unordered => have to order them ourselves
|
||||
firstBlockCommits = new VcsLogSorter<TimedVcsCommit>().sortByDateTopoOrder(firstBlockCommits);
|
||||
firstBlockCommits = new ArrayList<TimedVcsCommit>(firstBlockCommits.subList(0, Math.min(firstBlockCommits.size(), commitCount)));
|
||||
}
|
||||
logsToBuild.put(root, firstBlockCommits);
|
||||
refsByRoot.put(root, info.newRefs);
|
||||
}
|
||||
@@ -479,7 +484,11 @@ public class VcsLogDataHolder implements Disposable, VcsLogDataProvider {
|
||||
VcsLogProvider logProvider = entry.getValue();
|
||||
|
||||
StopWatch sw = StopWatch.start("readFirstBlock for " + root.getName());
|
||||
List<? extends VcsFullCommitDetails> firstBlockDetails = logProvider.readFirstBlock(root, ordered, commitsCount);
|
||||
|
||||
boolean orderedForRepo = ordered && !logProvider.supportsFastUnorderedCommits(); // will order manually
|
||||
int commitCountForRepo = orderedForRepo ? commitsCount : commitsCount * 2; // but need to request more commits
|
||||
|
||||
List<? extends VcsFullCommitDetails> firstBlockDetails = logProvider.readFirstBlock(root, orderedForRepo, commitCountForRepo);
|
||||
sw.report();
|
||||
sw = StopWatch.start("readAllRefs for" + root.getName());
|
||||
Collection<VcsRef> newRefs = logProvider.readAllRefs(root);
|
||||
|
||||
@@ -259,6 +259,11 @@ public class GitLogProvider implements VcsLogProvider {
|
||||
return GitBranchUtil.getBranches(myProject, root, true, true, commitHash.asString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsFastUnorderedCommits() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String prepareParameter(String paramName, String value) {
|
||||
return "--" + paramName + "=" + value; // no value quoting needed, because the parameter itself will be quoted by GeneralCommandLine
|
||||
}
|
||||
|
||||
@@ -246,6 +246,11 @@ public class HgLogProvider implements VcsLogProvider {
|
||||
return HgHistoryUtil.getDescendingHeadsOfBranches(myProject, root, commitHash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsFastUnorderedCommits() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String prepareParameter(String paramName, String value) {
|
||||
return "--" + paramName + "=" + value; // no value escaping needed, because the parameter itself will be quoted by GeneralCommandLine
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user