Fixed uncommited changes parent node lane position

This commit is contained in:
Abdelilah El Aissaoui 2021-10-30 19:38:11 +02:00
parent ba4c9596f8
commit b63614d68d

View File

@ -61,9 +61,11 @@ class GraphCommitList : RevCommitList<GraphNode>() {
} }
override fun enter(index: Int, currCommit: GraphNode) { override fun enter(index: Int, currCommit: GraphNode) {
if(currCommit.id == parentId) { var isUncommitedChangesNodeParent = false
if (currCommit.id == parentId) {
graphCommit.graphParent = currCommit graphCommit.graphParent = currCommit
currCommit.addChild(graphCommit, addFirst = true) currCommit.addChild(graphCommit, addFirst = true)
isUncommitedChangesNodeParent = true
} }
setupChildren(currCommit) setupChildren(currCommit)
@ -80,7 +82,7 @@ class GraphCommitList : RevCommitList<GraphNode>() {
var len = laneLength[currCommit.lane] var len = laneLength[currCommit.lane]
len = if (len != null) Integer.valueOf(len.toInt() + 1) else Integer.valueOf(0) len = if (len != null) Integer.valueOf(len.toInt() + 1) else Integer.valueOf(0)
if(currCommit.lane.position != INVALID_LANE_POSITION) if (currCommit.lane.position != INVALID_LANE_POSITION)
laneLength[currCommit.lane] = len laneLength[currCommit.lane] = len
} else { } else {
// More than one child, or our child is a merge. // More than one child, or our child is a merge.
@ -100,6 +102,16 @@ class GraphCommitList : RevCommitList<GraphNode>() {
var reservedLane: GraphLane? = null var reservedLane: GraphLane? = null
var childOnReservedLane: GraphNode? = null var childOnReservedLane: GraphNode? = null
var lengthOfReservedLane = -1 var lengthOfReservedLane = -1
if (isUncommitedChangesNodeParent) {
val length = laneLength[graphCommit.lane]
if (length != null) {
reservedLane = graphCommit.lane
childOnReservedLane = graphCommit
lengthOfReservedLane = length
}
} else {
for (i in 0 until nChildren) { for (i in 0 until nChildren) {
val c: GraphNode = currCommit.children[i] val c: GraphNode = currCommit.children[i]
if (c.getGraphParent(0) === currCommit) { if (c.getGraphParent(0) === currCommit) {
@ -117,6 +129,7 @@ class GraphCommitList : RevCommitList<GraphNode>() {
} }
} }
} }
}
if (reservedLane != null) { if (reservedLane != null) {
currCommit.lane = reservedLane currCommit.lane = reservedLane
laneLength[reservedLane] = Integer.valueOf(lengthOfReservedLane + 1) laneLength[reservedLane] = Integer.valueOf(lengthOfReservedLane + 1)