mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-11 23:57:21 -08:00
fix: endpoint of a graph path has been added twice (#528)
This commit is contained in:
parent
c7332aff03
commit
fe015f9bfd
1 changed files with 15 additions and 30 deletions
|
@ -146,7 +146,6 @@ namespace SourceGit.Models
|
||||||
|
|
||||||
var temp = new CommitGraph();
|
var temp = new CommitGraph();
|
||||||
var unsolved = new List<PathHelper>();
|
var unsolved = new List<PathHelper>();
|
||||||
var mapUnsolved = new Dictionary<string, PathHelper>();
|
|
||||||
var ended = new List<PathHelper>();
|
var ended = new List<PathHelper>();
|
||||||
var offsetY = -HALF_HEIGHT;
|
var offsetY = -HALF_HEIGHT;
|
||||||
var colorIdx = 0;
|
var colorIdx = 0;
|
||||||
|
@ -174,19 +173,17 @@ namespace SourceGit.Models
|
||||||
if (commit.Parents.Count > 0)
|
if (commit.Parents.Count > 0)
|
||||||
{
|
{
|
||||||
major.Next = commit.Parents[0];
|
major.Next = commit.Parents[0];
|
||||||
if (!mapUnsolved.ContainsKey(major.Next))
|
|
||||||
mapUnsolved.Add(major.Next, major);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
major.Next = "ENDED";
|
|
||||||
ended.Add(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
major.Add(offsetX, offsetY, HALF_HEIGHT);
|
major.Add(offsetX, offsetY, HALF_HEIGHT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
major.Add(offsetX, offsetY, HALF_HEIGHT, true);
|
||||||
|
ended.Add(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l.Add(major.LastX, offsetY, HALF_HEIGHT, true);
|
||||||
ended.Add(l);
|
ended.Add(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,13 +192,16 @@ namespace SourceGit.Models
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!mapUnsolved.ContainsKey(l.Next))
|
|
||||||
mapUnsolved.Add(l.Next, l);
|
|
||||||
offsetX += UNIT_WIDTH;
|
offsetX += UNIT_WIDTH;
|
||||||
l.Add(offsetX, offsetY, HALF_HEIGHT);
|
l.Add(offsetX, offsetY, HALF_HEIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove ended curves from unsolved
|
||||||
|
foreach (var l in ended)
|
||||||
|
unsolved.Remove(l);
|
||||||
|
ended.Clear();
|
||||||
|
|
||||||
// Create new curve for branch head
|
// Create new curve for branch head
|
||||||
if (major == null)
|
if (major == null)
|
||||||
{
|
{
|
||||||
|
@ -218,13 +218,8 @@ namespace SourceGit.Models
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate link position of this commit.
|
// Calculate link position of this commit.
|
||||||
Point position = new Point(offsetX, offsetY);
|
Point position = new Point(major?.LastX ?? offsetX, offsetY);
|
||||||
int dotColor = 0;
|
int dotColor = major?.Path.Color ?? 0;
|
||||||
if (major != null)
|
|
||||||
{
|
|
||||||
position = new Point(major.LastX, offsetY);
|
|
||||||
dotColor = major.Path.Color;
|
|
||||||
}
|
|
||||||
Dot anchor = new Dot() { Center = position, Color = dotColor };
|
Dot anchor = new Dot() { Center = position, Color = dotColor };
|
||||||
if (commit.IsCurrentHead)
|
if (commit.IsCurrentHead)
|
||||||
anchor.Type = DotType.Head;
|
anchor.Type = DotType.Head;
|
||||||
|
@ -239,11 +234,12 @@ namespace SourceGit.Models
|
||||||
{
|
{
|
||||||
for (int j = 1; j < commit.Parents.Count; j++)
|
for (int j = 1; j < commit.Parents.Count; j++)
|
||||||
{
|
{
|
||||||
var parent = commit.Parents[j];
|
var parentSHA = commit.Parents[j];
|
||||||
if (mapUnsolved.TryGetValue(parent, out var value))
|
var parent = unsolved.Find(x => x.Next.Equals(parentSHA, StringComparison.Ordinal));
|
||||||
|
if (parent != null)
|
||||||
{
|
{
|
||||||
// Try to change the merge state of linked graph
|
// Try to change the merge state of linked graph
|
||||||
var l = value;
|
var l = parent;
|
||||||
if (isMerged)
|
if (isMerged)
|
||||||
l.IsMerged = true;
|
l.IsMerged = true;
|
||||||
|
|
||||||
|
@ -260,7 +256,7 @@ namespace SourceGit.Models
|
||||||
offsetX += UNIT_WIDTH;
|
offsetX += UNIT_WIDTH;
|
||||||
|
|
||||||
// Create new curve for parent commit that not includes before
|
// Create new curve for parent commit that not includes before
|
||||||
var l = new PathHelper(parent, isMerged, colorIdx, position, new Point(offsetX, position.Y + HALF_HEIGHT));
|
var l = new PathHelper(parentSHA, isMerged, colorIdx, position, new Point(offsetX, position.Y + HALF_HEIGHT));
|
||||||
unsolved.Add(l);
|
unsolved.Add(l);
|
||||||
temp.Paths.Add(l.Path);
|
temp.Paths.Add(l.Path);
|
||||||
colorIdx = (colorIdx + 1) % _penCount;
|
colorIdx = (colorIdx + 1) % _penCount;
|
||||||
|
@ -268,20 +264,9 @@ namespace SourceGit.Models
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove ended curves from unsolved
|
|
||||||
foreach (var l in ended)
|
|
||||||
{
|
|
||||||
l.Add(position.X, position.Y, HALF_HEIGHT, true);
|
|
||||||
unsolved.Remove(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Margins & merge state (used by Views.Histories).
|
// Margins & merge state (used by Views.Histories).
|
||||||
commit.IsMerged = isMerged;
|
commit.IsMerged = isMerged;
|
||||||
commit.Margin = new Thickness(Math.Max(offsetX + HALF_WIDTH, oldCount * UNIT_WIDTH + H_MARGIN) + H_MARGIN, 0, 0, 0);
|
commit.Margin = new Thickness(Math.Max(offsetX + HALF_WIDTH, oldCount * UNIT_WIDTH + H_MARGIN) + H_MARGIN, 0, 0, 0);
|
||||||
|
|
||||||
// Clean up
|
|
||||||
ended.Clear();
|
|
||||||
mapUnsolved.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deal with curves haven't ended yet.
|
// Deal with curves haven't ended yet.
|
||||||
|
|
Loading…
Reference in a new issue