mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[log] IDEA-121992 Recalculate old heads values
The VcsLogBranchFilter used to store precalculated values of commit indices of its heads. However, is it likely that after refresh these values change => setFilter will get either non-head commits, or even invalid (if head commit was rebased/amended). Don't precalculate these values, perform calculation each time, which is fast because there are not too many head ref in the filter (usually 0, 1 or 2).
This commit is contained in:
@@ -26,9 +26,4 @@ public interface VcsLogBranchFilter extends VcsLogFilter {
|
||||
|
||||
@NotNull
|
||||
Collection<String> getBranchNames();
|
||||
|
||||
// TODO remove from the API
|
||||
@NotNull
|
||||
Collection<Integer> getMatchingHeads();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,16 @@
|
||||
package com.intellij.vcs.log.data;
|
||||
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.log.VcsLogBranchFilter;
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class VcsLogBranchFilterImpl implements VcsLogBranchFilter {
|
||||
|
||||
@NotNull private final Collection<Integer> myMatchingHeads;
|
||||
@NotNull private final Collection<String> myBranchNames;
|
||||
|
||||
public VcsLogBranchFilterImpl(@NotNull Collection<VcsRef> allRefs, @NotNull final Collection<String> branchNames) {
|
||||
public VcsLogBranchFilterImpl(@NotNull final Collection<String> branchNames) {
|
||||
myBranchNames = branchNames;
|
||||
myMatchingHeads = ContainerUtil.mapNotNull(allRefs, new Function<VcsRef, Integer>() {
|
||||
@Override
|
||||
public Integer fun(VcsRef ref) {
|
||||
if (branchNames.contains(ref.getName())) {
|
||||
return ref.getCommitIndex();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,11 +23,4 @@ public class VcsLogBranchFilterImpl implements VcsLogBranchFilter {
|
||||
public Collection<String> getBranchNames() {
|
||||
return myBranchNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<Integer> getMatchingHeads() {
|
||||
return myMatchingHeads;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import gnu.trove.TIntHashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -119,7 +121,21 @@ public class VcsLogFilterer {
|
||||
myUI.getTable().executeWithoutRepaint(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dataPack.getGraphFacade().setVisibleBranches(branchFilter != null ? branchFilter.getMatchingHeads() : null);
|
||||
dataPack.getGraphFacade().setVisibleBranches(branchFilter != null ? getMatchingHeads(dataPack, branchFilter) : null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<Integer> getMatchingHeads(@NotNull DataPack dataPack, @NotNull VcsLogBranchFilter branchFilter) {
|
||||
final Collection<String> branchNames = new HashSet<String>(branchFilter.getBranchNames());
|
||||
return ContainerUtil.mapNotNull(dataPack.getRefsModel().getAllRefs(), new Function<VcsRef, Integer>() {
|
||||
@Override
|
||||
public Integer fun(VcsRef ref) {
|
||||
if (branchNames.contains(ref.getName())) {
|
||||
return ref.getCommitIndex();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-2
@@ -158,8 +158,7 @@ public class BranchFilterPopupComponent extends MultipleValueFilterPopupComponen
|
||||
if (getSelectedValues() == null) {
|
||||
return null;
|
||||
}
|
||||
Collection<VcsRef> allBranches = myDataPack.getRefs().getBranches();
|
||||
return new VcsLogBranchFilterImpl(allBranches, getSelectedValues());
|
||||
return new VcsLogBranchFilterImpl(getSelectedValues());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -60,8 +60,7 @@ public class DeepCompareAction extends ToggleAction implements DumbAware {
|
||||
selectBranchAndPerformAction(ui.getDataPack(), e, new Consumer<String>() {
|
||||
@Override
|
||||
public void consume(String selectedBranch) {
|
||||
ui.getFilterUi().setFilter(new VcsLogBranchFilterImpl(ui.getDataPack().getRefs().getBranches(),
|
||||
Collections.singleton(selectedBranch)));
|
||||
ui.getFilterUi().setFilter(new VcsLogBranchFilterImpl(Collections.singleton(selectedBranch)));
|
||||
dc.highlightInBackground(selectedBranch, dataProvider);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user