mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[log] Added branch filter support.
This commit is contained in:
committed by
Julia Beliaeva
parent
1c0b9eb89d
commit
c7b6693d8a
+2
-1
@@ -18,6 +18,7 @@ package com.intellij.vcs.log.graph.api.permanent;
|
||||
import com.intellij.vcs.log.graph.GraphColorManager;
|
||||
import com.intellij.vcs.log.graph.api.GraphLayout;
|
||||
import com.intellij.vcs.log.graph.api.LinearGraph;
|
||||
import com.intellij.vcs.log.graph.impl.permanent.PermanentLinearGraphImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -28,7 +29,7 @@ public interface PermanentGraphInfo<CommitId> {
|
||||
PermanentCommitsInfo<CommitId> getPermanentCommitsInfo();
|
||||
|
||||
@NotNull
|
||||
LinearGraph getPermanentLinearGraph();
|
||||
PermanentLinearGraphImpl getPermanentLinearGraph();
|
||||
|
||||
@NotNull
|
||||
GraphLayout getPermanentGraphLayout();
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.vcs.log.graph.collapsing;
|
||||
|
||||
import com.intellij.vcs.log.graph.api.LiteLinearGraph;
|
||||
import com.intellij.vcs.log.graph.impl.permanent.PermanentLinearGraphImpl;
|
||||
import com.intellij.vcs.log.graph.utils.DfsUtil;
|
||||
import com.intellij.vcs.log.graph.utils.LinearGraphUtils;
|
||||
import com.intellij.vcs.log.graph.utils.UnsignedBitSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class BranchMatchedNodesGenerator {
|
||||
|
||||
@NotNull
|
||||
public static UnsignedBitSet generateVisibleNodes(@NotNull PermanentLinearGraphImpl permanentGraph, @Nullable Set<Integer> headNodeIndexes) {
|
||||
if (headNodeIndexes == null) {
|
||||
UnsignedBitSet nodesVisibility = new UnsignedBitSet();
|
||||
nodesVisibility.set(0, permanentGraph.nodesCount() - 1, true);
|
||||
return nodesVisibility;
|
||||
}
|
||||
|
||||
assert !headNodeIndexes.isEmpty();
|
||||
BranchMatchedNodesGenerator generator = new BranchMatchedNodesGenerator(LinearGraphUtils.asLiteLinearGraph(permanentGraph));
|
||||
generator.generate(headNodeIndexes);
|
||||
return generator.myNodesVisibility;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private final LiteLinearGraph myGraph;
|
||||
|
||||
@NotNull
|
||||
private final UnsignedBitSet myNodesVisibility;
|
||||
|
||||
@NotNull
|
||||
private final DfsUtil myDfsUtil = new DfsUtil();
|
||||
|
||||
BranchMatchedNodesGenerator(@NotNull LiteLinearGraph graph) {
|
||||
myGraph = graph;
|
||||
myNodesVisibility = new UnsignedBitSet();
|
||||
}
|
||||
|
||||
private void generate(@NotNull Set<Integer> startedNodes) {
|
||||
for (int startNode : startedNodes) {
|
||||
myNodesVisibility.set(startNode, true);
|
||||
myDfsUtil.nodeDfsIterator(startNode, new DfsUtil.NextNode() {
|
||||
@Override
|
||||
public int fun(int currentNode) {
|
||||
for (int downNode : myGraph.getNodes(currentNode, LiteLinearGraph.NodeFilter.DOWN)) {
|
||||
if (!myNodesVisibility.get(downNode)) {
|
||||
myNodesVisibility.set(downNode, true);
|
||||
return downNode;
|
||||
}
|
||||
}
|
||||
return NODE_NOT_FOUND;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-10
@@ -15,13 +15,11 @@
|
||||
*/
|
||||
package com.intellij.vcs.log.graph.collapsing;
|
||||
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.log.graph.api.EdgeFilter;
|
||||
import com.intellij.vcs.log.graph.api.LinearGraph;
|
||||
import com.intellij.vcs.log.graph.api.elements.GraphEdge;
|
||||
import com.intellij.vcs.log.graph.api.elements.GraphNode;
|
||||
import com.intellij.vcs.log.graph.utils.IntToIntMap;
|
||||
import com.intellij.vcs.log.graph.utils.UnsignedBitSet;
|
||||
import com.intellij.vcs.log.graph.utils.UpdatableIntToIntMap;
|
||||
import com.intellij.vcs.log.graph.utils.impl.ListIntToIntMap;
|
||||
@@ -33,14 +31,7 @@ import java.util.List;
|
||||
public class CollapsedGraph {
|
||||
|
||||
// initVisibility == null means, what all nodes is Visible
|
||||
public static CollapsedGraph newInstance(@NotNull LinearGraph delegateGraph, @Nullable UnsignedBitSet initVisibility) {
|
||||
if (initVisibility == null) { // todo fix performance
|
||||
initVisibility = new UnsignedBitSet();
|
||||
for (int i = 0; i < delegateGraph.nodesCount(); i++) {
|
||||
initVisibility.set(delegateGraph.getNodeId(i), true);
|
||||
}
|
||||
}
|
||||
|
||||
public static CollapsedGraph newInstance(@NotNull LinearGraph delegateGraph, @NotNull UnsignedBitSet initVisibility) {
|
||||
UnsignedBitSet visibleNodesId = initVisibility.clone(); // todo mm?
|
||||
return new CollapsedGraph(delegateGraph, visibleNodesId, new EdgeStorage());
|
||||
}
|
||||
|
||||
+7
-2
@@ -18,17 +18,22 @@ package com.intellij.vcs.log.graph.collapsing;
|
||||
import com.intellij.vcs.log.graph.api.LinearGraph;
|
||||
import com.intellij.vcs.log.graph.api.permanent.PermanentGraphInfo;
|
||||
import com.intellij.vcs.log.graph.impl.facade.CascadeLinearGraphController;
|
||||
import com.intellij.vcs.log.graph.utils.UnsignedBitSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class CollapsedLinearGraphController extends CascadeLinearGraphController {
|
||||
@NotNull
|
||||
private CollapsedGraph myCollapsedGraph;
|
||||
|
||||
public CollapsedLinearGraphController(@NotNull CascadeLinearGraphController delegateLinearGraphController,
|
||||
@NotNull final PermanentGraphInfo<?> permanentGraphInfo) {
|
||||
@NotNull final PermanentGraphInfo<?> permanentGraphInfo,
|
||||
@Nullable Set<Integer> IdsOfVisibleBranches) {
|
||||
super(delegateLinearGraphController, permanentGraphInfo);
|
||||
myCollapsedGraph = CollapsedGraph.newInstance(getDelegateLinearGraphController().getCompiledGraph(), null);
|
||||
UnsignedBitSet initVisibility = BranchMatchedNodesGenerator.generateVisibleNodes(permanentGraphInfo.getPermanentLinearGraph(), IdsOfVisibleBranches);
|
||||
myCollapsedGraph = CollapsedGraph.newInstance(getDelegateLinearGraphController().getCompiledGraph(), initVisibility);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+6
-2
@@ -124,7 +124,11 @@ public class PermanentGraphImpl<CommitId> implements PermanentGraph<CommitId>, P
|
||||
if (matchedCommits != null) {
|
||||
controller = new FilterLinearGraphController(baseController, this, myPermanentCommitsInfo.convertToNodeIds(matchedCommits));
|
||||
} else {
|
||||
controller = new CollapsedLinearGraphController(baseController, this);
|
||||
Set<Integer> idOfVisibleBranches = null;
|
||||
if (headsOfVisibleBranches != null) {
|
||||
idOfVisibleBranches = myPermanentCommitsInfo.convertToNodeIds(headsOfVisibleBranches);
|
||||
}
|
||||
controller = new CollapsedLinearGraphController(baseController, this, idOfVisibleBranches);
|
||||
}
|
||||
|
||||
return new VisibleGraphImpl<CommitId>(controller, this);
|
||||
@@ -165,7 +169,7 @@ public class PermanentGraphImpl<CommitId> implements PermanentGraph<CommitId>, P
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public LinearGraph getPermanentLinearGraph() {
|
||||
public PermanentLinearGraphImpl getPermanentLinearGraph() {
|
||||
return myPermanentLinearGraph;
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -24,8 +24,10 @@ import com.intellij.vcs.log.graph.api.elements.GraphEdgeType;
|
||||
import com.intellij.vcs.log.graph.api.elements.GraphNode;
|
||||
import com.intellij.vcs.log.graph.utils.Flags;
|
||||
import com.intellij.vcs.log.graph.utils.IntList;
|
||||
import com.intellij.vcs.log.graph.utils.impl.BitSetFlags;
|
||||
import com.intellij.vcs.log.graph.utils.impl.CompressedIntList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,6 +46,11 @@ public class PermanentLinearGraphImpl implements LinearGraph {
|
||||
myLongEdges = CompressedIntList.newInstance(longEdges);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public PermanentLinearGraphImpl() {
|
||||
this(new BitSetFlags(0), new int[0], new int[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nodesCount() {
|
||||
return mySimpleNodes.size();
|
||||
|
||||
@@ -36,6 +36,9 @@ import kotlin.test.assertTrue
|
||||
import kotlin.test.assertNull
|
||||
import com.intellij.vcs.log.graph.utils.LinearGraphUtils
|
||||
import com.intellij.vcs.log.graph.api.EdgeFilter
|
||||
import com.intellij.vcs.log.graph.impl.permanent.PermanentLinearGraphImpl
|
||||
import com.intellij.vcs.log.graph.utils.impl.BitSetFlags
|
||||
import com.intellij.vcs.log.graph.utils.impl.FullIntList
|
||||
|
||||
trait BaseTestGraphBuilder {
|
||||
val Int.U: SimpleNode get() = SimpleNode(this, GraphNodeType.USUAL)
|
||||
@@ -267,7 +270,7 @@ class TestPermanentGraphInfo(
|
||||
}
|
||||
|
||||
override fun getPermanentCommitsInfo() = commitInfo
|
||||
override fun getPermanentLinearGraph() = graph
|
||||
override fun getPermanentLinearGraph() = object : PermanentLinearGraphImpl(), LinearGraph by graph {}
|
||||
override fun getPermanentGraphLayout() = graphLayout
|
||||
override fun getBranchNodeIds() = branchNodes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user