@@ -56,6 +56,18 @@ public bool CanCommitWithPush
56
56
}
57
57
}
58
58
59
+ public bool HasUnsolvedConflicts
60
+ {
61
+ get => _hasUnsolvedConflicts ;
62
+ set => SetProperty ( ref _hasUnsolvedConflicts , value ) ;
63
+ }
64
+
65
+ public InProgressContext InProgressContext
66
+ {
67
+ get => _inProgressContext ;
68
+ private set => SetProperty ( ref _inProgressContext , value ) ;
69
+ }
70
+
59
71
public bool IsStaging
60
72
{
61
73
get => _isStaging ;
@@ -191,6 +203,7 @@ public WorkingCopy(Repository repo)
191
203
public void Cleanup ( )
192
204
{
193
205
_repo = null ;
206
+ _inProgressContext = null ;
194
207
195
208
_selectedUnstaged . Clear ( ) ;
196
209
OnPropertyChanged ( nameof ( SelectedUnstaged ) ) ;
@@ -208,7 +221,7 @@ public void Cleanup()
208
221
_commitMessage = string . Empty ;
209
222
}
210
223
211
- public bool SetData ( List < Models . Change > changes )
224
+ public void SetData ( List < Models . Change > changes )
212
225
{
213
226
if ( ! IsChanged ( _cached , changes ) )
214
227
{
@@ -221,9 +234,22 @@ public bool SetData(List<Models.Change> changes)
221
234
SetDetail ( _selectedStaged [ 0 ] , false ) ;
222
235
else
223
236
SetDetail ( null , false ) ;
237
+
238
+ var inProgress = null as InProgressContext ;
239
+ if ( File . Exists ( Path . Combine ( _repo . GitDir , "CHERRY_PICK_HEAD" ) ) )
240
+ inProgress = new CherryPickInProgress ( _repo . FullPath ) ;
241
+ else if ( File . Exists ( Path . Combine ( _repo . GitDir , "REBASE_HEAD" ) ) && Directory . Exists ( Path . Combine ( _repo . GitDir , "rebase-merge" ) ) )
242
+ inProgress = new RebaseInProgress ( _repo ) ;
243
+ else if ( File . Exists ( Path . Combine ( _repo . GitDir , "REVERT_HEAD" ) ) )
244
+ inProgress = new RevertInProgress ( _repo . FullPath ) ;
245
+ else if ( File . Exists ( Path . Combine ( _repo . GitDir , "MERGE_HEAD" ) ) )
246
+ inProgress = new MergeInProgress ( _repo . FullPath ) ;
247
+
248
+ HasUnsolvedConflicts = _cached . Find ( x => x . IsConflit ) != null ;
249
+ InProgressContext = inProgress ;
224
250
} ) ;
225
251
226
- return _cached . Find ( x => x . IsConflit ) != null ;
252
+ return ;
227
253
}
228
254
229
255
_cached = changes ;
@@ -268,6 +294,7 @@ public bool SetData(List<Models.Change> changes)
268
294
Dispatcher . UIThread . Invoke ( ( ) =>
269
295
{
270
296
_isLoadingData = true ;
297
+ HasUnsolvedConflicts = hasConflict ;
271
298
Unstaged = unstaged ;
272
299
Staged = staged ;
273
300
SelectedUnstaged = selectedUnstaged ;
@@ -281,6 +308,18 @@ public bool SetData(List<Models.Change> changes)
281
308
else
282
309
SetDetail ( null , false ) ;
283
310
311
+ var inProgress = null as InProgressContext ;
312
+ if ( File . Exists ( Path . Combine ( _repo . GitDir , "CHERRY_PICK_HEAD" ) ) )
313
+ inProgress = new CherryPickInProgress ( _repo . FullPath ) ;
314
+ else if ( File . Exists ( Path . Combine ( _repo . GitDir , "REBASE_HEAD" ) ) && Directory . Exists ( Path . Combine ( _repo . GitDir , "rebase-merge" ) ) )
315
+ inProgress = new RebaseInProgress ( _repo ) ;
316
+ else if ( File . Exists ( Path . Combine ( _repo . GitDir , "REVERT_HEAD" ) ) )
317
+ inProgress = new RevertInProgress ( _repo . FullPath ) ;
318
+ else if ( File . Exists ( Path . Combine ( _repo . GitDir , "MERGE_HEAD" ) ) )
319
+ inProgress = new MergeInProgress ( _repo . FullPath ) ;
320
+
321
+ InProgressContext = inProgress ;
322
+
284
323
// Try to load merge message from MERGE_MSG
285
324
if ( string . IsNullOrEmpty ( _commitMessage ) )
286
325
{
@@ -289,8 +328,6 @@ public bool SetData(List<Models.Change> changes)
289
328
CommitMessage = File . ReadAllText ( mergeMsgFile ) ;
290
329
}
291
330
} ) ;
292
-
293
- return hasConflict ;
294
331
}
295
332
296
333
public void OpenAssumeUnchanged ( )
@@ -403,6 +440,52 @@ public void Discard(List<Models.Change> changes)
403
440
}
404
441
}
405
442
443
+ public void ContinueMerge ( )
444
+ {
445
+ if ( _inProgressContext != null )
446
+ {
447
+ _repo . SetWatcherEnabled ( false ) ;
448
+ Task . Run ( ( ) =>
449
+ {
450
+ var succ = _inProgressContext . Continue ( ) ;
451
+ Dispatcher . UIThread . Invoke ( ( ) =>
452
+ {
453
+ if ( succ )
454
+ CommitMessage = string . Empty ;
455
+
456
+ _repo . SetWatcherEnabled ( true ) ;
457
+ } ) ;
458
+ } ) ;
459
+ }
460
+ else
461
+ {
462
+ _repo . MarkWorkingCopyDirtyManually ( ) ;
463
+ }
464
+ }
465
+
466
+ public void AbortMerge ( )
467
+ {
468
+ if ( _inProgressContext != null )
469
+ {
470
+ _repo . SetWatcherEnabled ( false ) ;
471
+ Task . Run ( ( ) =>
472
+ {
473
+ var succ = _inProgressContext . Abort ( ) ;
474
+ Dispatcher . UIThread . Invoke ( ( ) =>
475
+ {
476
+ if ( succ )
477
+ CommitMessage = string . Empty ;
478
+
479
+ _repo . SetWatcherEnabled ( true ) ;
480
+ } ) ;
481
+ } ) ;
482
+ }
483
+ else
484
+ {
485
+ _repo . MarkWorkingCopyDirtyManually ( ) ;
486
+ }
487
+ }
488
+
406
489
public void Commit ( )
407
490
{
408
491
DoCommit ( false , false , false ) ;
@@ -1475,5 +1558,8 @@ private bool IsChanged(List<Models.Change> old, List<Models.Change> cur)
1475
1558
private int _count = 0 ;
1476
1559
private object _detailContext = null ;
1477
1560
private string _commitMessage = string . Empty ;
1561
+
1562
+ private bool _hasUnsolvedConflicts = false ;
1563
+ private InProgressContext _inProgressContext = null ;
1478
1564
}
1479
1565
}
0 commit comments