@@ -146,7 +146,6 @@ public static CommitGraph Parse(List<Commit> commits, bool firstParentOnlyEnable
146
146
147
147
var temp = new CommitGraph ( ) ;
148
148
var unsolved = new List < PathHelper > ( ) ;
149
- var mapUnsolved = new Dictionary < string , PathHelper > ( ) ;
150
149
var ended = new List < PathHelper > ( ) ;
151
150
var offsetY = - HALF_HEIGHT ;
152
151
var colorIdx = 0 ;
@@ -174,19 +173,17 @@ public static CommitGraph Parse(List<Commit> commits, bool firstParentOnlyEnable
174
173
if ( commit . Parents . Count > 0 )
175
174
{
176
175
major . Next = commit . Parents [ 0 ] ;
177
- if ( ! mapUnsolved . ContainsKey ( major . Next ) )
178
- mapUnsolved . Add ( major . Next , major ) ;
176
+ major . Add ( offsetX , offsetY , HALF_HEIGHT ) ;
179
177
}
180
178
else
181
179
{
182
- major . Next = "ENDED" ;
180
+ major . Add ( offsetX , offsetY , HALF_HEIGHT , true ) ;
183
181
ended . Add ( l ) ;
184
182
}
185
-
186
- major . Add ( offsetX , offsetY , HALF_HEIGHT ) ;
187
183
}
188
184
else
189
185
{
186
+ l . Add ( major . LastX , offsetY , HALF_HEIGHT , true ) ;
190
187
ended . Add ( l ) ;
191
188
}
192
189
@@ -195,13 +192,16 @@ public static CommitGraph Parse(List<Commit> commits, bool firstParentOnlyEnable
195
192
}
196
193
else
197
194
{
198
- if ( ! mapUnsolved . ContainsKey ( l . Next ) )
199
- mapUnsolved . Add ( l . Next , l ) ;
200
195
offsetX += UNIT_WIDTH ;
201
196
l . Add ( offsetX , offsetY , HALF_HEIGHT ) ;
202
197
}
203
198
}
204
199
200
+ // Remove ended curves from unsolved
201
+ foreach ( var l in ended )
202
+ unsolved . Remove ( l ) ;
203
+ ended . Clear ( ) ;
204
+
205
205
// Create new curve for branch head
206
206
if ( major == null )
207
207
{
@@ -218,13 +218,8 @@ public static CommitGraph Parse(List<Commit> commits, bool firstParentOnlyEnable
218
218
}
219
219
220
220
// Calculate link position of this commit.
221
- Point position = new Point ( offsetX , offsetY ) ;
222
- int dotColor = 0 ;
223
- if ( major != null )
224
- {
225
- position = new Point ( major . LastX , offsetY ) ;
226
- dotColor = major . Path . Color ;
227
- }
221
+ Point position = new Point ( major ? . LastX ?? offsetX , offsetY ) ;
222
+ int dotColor = major ? . Path . Color ?? 0 ;
228
223
Dot anchor = new Dot ( ) { Center = position , Color = dotColor } ;
229
224
if ( commit . IsCurrentHead )
230
225
anchor . Type = DotType . Head ;
@@ -239,11 +234,12 @@ public static CommitGraph Parse(List<Commit> commits, bool firstParentOnlyEnable
239
234
{
240
235
for ( int j = 1 ; j < commit . Parents . Count ; j ++ )
241
236
{
242
- var parent = commit . Parents [ j ] ;
243
- if ( mapUnsolved . TryGetValue ( parent , out var value ) )
237
+ var parentSHA = commit . Parents [ j ] ;
238
+ var parent = unsolved . Find ( x => x . Next . Equals ( parentSHA , StringComparison . Ordinal ) ) ;
239
+ if ( parent != null )
244
240
{
245
241
// Try to change the merge state of linked graph
246
- var l = value ;
242
+ var l = parent ;
247
243
if ( isMerged )
248
244
l . IsMerged = true ;
249
245
@@ -260,28 +256,17 @@ public static CommitGraph Parse(List<Commit> commits, bool firstParentOnlyEnable
260
256
offsetX += UNIT_WIDTH ;
261
257
262
258
// Create new curve for parent commit that not includes before
263
- var l = new PathHelper ( parent , isMerged , colorIdx , position , new Point ( offsetX , position . Y + HALF_HEIGHT ) ) ;
259
+ var l = new PathHelper ( parentSHA , isMerged , colorIdx , position , new Point ( offsetX , position . Y + HALF_HEIGHT ) ) ;
264
260
unsolved . Add ( l ) ;
265
261
temp . Paths . Add ( l . Path ) ;
266
262
colorIdx = ( colorIdx + 1 ) % _penCount ;
267
263
}
268
264
}
269
265
}
270
266
271
- // Remove ended curves from unsolved
272
- foreach ( var l in ended )
273
- {
274
- l . Add ( position . X , position . Y , HALF_HEIGHT , true ) ;
275
- unsolved . Remove ( l ) ;
276
- }
277
-
278
267
// Margins & merge state (used by Views.Histories).
279
268
commit . IsMerged = isMerged ;
280
269
commit . Margin = new Thickness ( Math . Max ( offsetX + HALF_WIDTH , oldCount * UNIT_WIDTH + H_MARGIN ) + H_MARGIN , 0 , 0 , 0 ) ;
281
-
282
- // Clean up
283
- ended . Clear ( ) ;
284
- mapUnsolved . Clear ( ) ;
285
270
}
286
271
287
272
// Deal with curves haven't ended yet.
0 commit comments