@@ -305,33 +305,12 @@ public void ScrollTo(int index, float offset = 0f)
305
305
[ Serializable ]
306
306
class HistoryView : Subview
307
307
{
308
- private const string PullButton = "Pull" ;
309
- private const string PullButtonCount = "Pull (<b>{0}</b>)" ;
310
- private const string PushButton = "Push" ;
311
- private const string PushButtonCount = "Push (<b>{0}</b>)" ;
312
- private const string PullConfirmTitle = "Pull Changes?" ;
313
- private const string PullConfirmDescription = "Would you like to pull changes from remote '{0}'?" ;
314
- private const string PullConfirmYes = "Pull" ;
315
- private const string PullConfirmCancel = "Cancel" ;
316
- private const string PushConfirmTitle = "Push Changes?" ;
317
- private const string PushConfirmDescription = "Would you like to push changes to remote '{0}'?" ;
318
- private const string PushConfirmYes = "Push" ;
319
- private const string PushConfirmCancel = "Cancel" ;
320
308
private const string CommitDetailsTitle = "Commit details" ;
321
309
private const string ClearSelectionButton = "×" ;
322
- private const string PublishButton = "Publish" ;
323
- private const string FetchActionTitle = "Fetch Changes" ;
324
- private const string FetchButtonText = "Fetch" ;
325
- private const string FetchFailureDescription = "Could not fetch changes" ;
326
310
327
311
[ NonSerialized ] private bool currentLogHasUpdate ;
328
- [ NonSerialized ] private bool currentRemoteHasUpdate ;
329
312
[ NonSerialized ] private bool currentTrackingStatusHasUpdate ;
330
313
331
- [ SerializeField ] private bool hasItemsToCommit ;
332
- [ SerializeField ] private bool hasRemote ;
333
- [ SerializeField ] private string currentRemoteName ;
334
-
335
314
[ SerializeField ] private HistoryControl historyControl ;
336
315
[ SerializeField ] private GitLogEntry selectedEntry = GitLogEntry . Default ;
337
316
@@ -340,13 +319,11 @@ class HistoryView : Subview
340
319
[ SerializeField ] private List < GitLogEntry > logEntries = new List < GitLogEntry > ( ) ;
341
320
342
321
[ SerializeField ] private int statusAhead ;
343
- [ SerializeField ] private int statusBehind ;
344
322
345
323
[ SerializeField ] private ChangesTree treeChanges = new ChangesTree { IsSelectable = false , DisplayRootNode = false } ;
346
324
347
- [ SerializeField ] private CacheUpdateEvent lastCurrentRemoteChangedEvent ;
348
325
[ SerializeField ] private CacheUpdateEvent lastLogChangedEvent ;
349
- [ SerializeField ] private CacheUpdateEvent lastAheadBehindChangedEvent ;
326
+ [ SerializeField ] private CacheUpdateEvent lastTrackingStatusChangedEvent ;
350
327
351
328
public override void OnEnable ( )
352
329
{
@@ -387,68 +364,6 @@ public override void OnFocusChanged()
387
364
388
365
public override void OnGUI ( )
389
366
{
390
- // History toolbar
391
- GUILayout . BeginHorizontal ( EditorStyles . toolbar ) ;
392
- {
393
- GUILayout . FlexibleSpace ( ) ;
394
-
395
- if ( hasRemote )
396
- {
397
- EditorGUI . BeginDisabledGroup ( currentRemoteName == null ) ;
398
- {
399
- // Fetch button
400
- var fetchClicked = GUILayout . Button ( FetchButtonText , Styles . HistoryToolbarButtonStyle ) ;
401
- if ( fetchClicked )
402
- {
403
- Fetch ( ) ;
404
- }
405
-
406
- // Pull button
407
- var pullButtonText = statusBehind > 0 ? String . Format ( PullButtonCount , statusBehind ) : PullButton ;
408
- var pullClicked = GUILayout . Button ( pullButtonText , Styles . HistoryToolbarButtonStyle ) ;
409
-
410
- if ( pullClicked &&
411
- EditorUtility . DisplayDialog ( PullConfirmTitle ,
412
- String . Format ( PullConfirmDescription , currentRemoteName ) ,
413
- PullConfirmYes ,
414
- PullConfirmCancel )
415
- )
416
- {
417
- Pull ( ) ;
418
- }
419
- }
420
- EditorGUI . EndDisabledGroup ( ) ;
421
-
422
- // Push button
423
- EditorGUI . BeginDisabledGroup ( currentRemoteName == null || statusBehind != 0 ) ;
424
- {
425
- var pushButtonText = statusAhead > 0 ? String . Format ( PushButtonCount , statusAhead ) : PushButton ;
426
- var pushClicked = GUILayout . Button ( pushButtonText , Styles . HistoryToolbarButtonStyle ) ;
427
-
428
- if ( pushClicked &&
429
- EditorUtility . DisplayDialog ( PushConfirmTitle ,
430
- String . Format ( PushConfirmDescription , currentRemoteName ) ,
431
- PushConfirmYes ,
432
- PushConfirmCancel )
433
- )
434
- {
435
- Push ( ) ;
436
- }
437
- }
438
- EditorGUI . EndDisabledGroup ( ) ;
439
- }
440
- else
441
- {
442
- // Publishing a repo
443
- var publishedClicked = GUILayout . Button ( PublishButton , Styles . HistoryToolbarButtonStyle ) ;
444
- if ( publishedClicked )
445
- {
446
- PopupWindow . OpenWindow ( PopupWindow . PopupViewType . PublishView ) ;
447
- }
448
- }
449
- }
450
- GUILayout . EndHorizontal ( ) ;
451
-
452
367
var rect = GUILayoutUtility . GetLastRect ( ) ;
453
368
if ( historyControl != null )
454
369
{
@@ -569,11 +484,11 @@ private void RevertCommit()
569
484
}
570
485
}
571
486
572
- private void RepositoryTrackingOnStatusChanged ( CacheUpdateEvent cacheUpdateEvent )
487
+ private void RepositoryOnTrackingStatusChanged ( CacheUpdateEvent cacheUpdateEvent )
573
488
{
574
- if ( ! lastAheadBehindChangedEvent . Equals ( cacheUpdateEvent ) )
489
+ if ( ! lastTrackingStatusChangedEvent . Equals ( cacheUpdateEvent ) )
575
490
{
576
- lastAheadBehindChangedEvent = cacheUpdateEvent ;
491
+ lastTrackingStatusChangedEvent = cacheUpdateEvent ;
577
492
currentTrackingStatusHasUpdate = true ;
578
493
Redraw ( ) ;
579
494
}
@@ -589,26 +504,15 @@ private void RepositoryOnLogChanged(CacheUpdateEvent cacheUpdateEvent)
589
504
}
590
505
}
591
506
592
- private void RepositoryOnCurrentRemoteChanged ( CacheUpdateEvent cacheUpdateEvent )
593
- {
594
- if ( ! lastCurrentRemoteChangedEvent . Equals ( cacheUpdateEvent ) )
595
- {
596
- lastCurrentRemoteChangedEvent = cacheUpdateEvent ;
597
- currentRemoteHasUpdate = true ;
598
- Redraw ( ) ;
599
- }
600
- }
601
-
602
507
private void AttachHandlers ( IRepository repository )
603
508
{
604
509
if ( repository == null )
605
510
{
606
511
return ;
607
512
}
608
513
609
- repository . TrackingStatusChanged += RepositoryTrackingOnStatusChanged ;
514
+ repository . TrackingStatusChanged += RepositoryOnTrackingStatusChanged ;
610
515
repository . LogChanged += RepositoryOnLogChanged ;
611
- repository . CurrentRemoteChanged += RepositoryOnCurrentRemoteChanged ;
612
516
}
613
517
614
518
private void DetachHandlers ( IRepository repository )
@@ -618,16 +522,14 @@ private void DetachHandlers(IRepository repository)
618
522
return ;
619
523
}
620
524
621
- repository . TrackingStatusChanged -= RepositoryTrackingOnStatusChanged ;
525
+ repository . TrackingStatusChanged -= RepositoryOnTrackingStatusChanged ;
622
526
repository . LogChanged -= RepositoryOnLogChanged ;
623
- repository . CurrentRemoteChanged -= RepositoryOnCurrentRemoteChanged ;
624
527
}
625
528
626
529
private void ValidateCachedData ( IRepository repository )
627
530
{
628
531
repository . CheckAndRaiseEventsIfCacheNewer ( CacheType . GitLog , lastLogChangedEvent ) ;
629
- repository . CheckAndRaiseEventsIfCacheNewer ( CacheType . GitAheadBehind , lastAheadBehindChangedEvent ) ;
630
- repository . CheckAndRaiseEventsIfCacheNewer ( CacheType . RepositoryInfo , lastCurrentRemoteChangedEvent ) ;
532
+ repository . CheckAndRaiseEventsIfCacheNewer ( CacheType . GitAheadBehind , lastTrackingStatusChangedEvent ) ;
631
533
}
632
534
633
535
private void MaybeUpdateData ( )
@@ -637,25 +539,11 @@ private void MaybeUpdateData()
637
539
return ;
638
540
}
639
541
640
- if ( currentRemoteHasUpdate )
641
- {
642
- currentRemoteHasUpdate = false ;
643
-
644
- var currentRemote = Repository . CurrentRemote ;
645
- hasRemote = currentRemote . HasValue ;
646
- currentRemoteName = hasRemote ? currentRemote . Value . Name : "placeholder" ;
647
- }
648
-
649
542
if ( currentTrackingStatusHasUpdate )
650
543
{
651
544
currentTrackingStatusHasUpdate = false ;
652
545
653
546
statusAhead = Repository . CurrentAhead ;
654
- statusBehind = Repository . CurrentBehind ;
655
-
656
- var currentChanges = Repository . CurrentChanges ;
657
- hasItemsToCommit = currentChanges != null
658
- && currentChanges . Any ( entry => entry . Status != GitFileStatus . Ignored && ! entry . Staged ) ;
659
547
}
660
548
661
549
if ( currentLogHasUpdate )
@@ -683,75 +571,6 @@ private void BuildHistoryControl()
683
571
}
684
572
}
685
573
686
- private void Pull ( )
687
- {
688
- if ( hasItemsToCommit )
689
- {
690
- EditorUtility . DisplayDialog ( "Pull" , "You need to commit your changes before pulling." , "Cancel" ) ;
691
- }
692
- else
693
- {
694
- Repository
695
- . Pull ( )
696
- . FinallyInUI ( ( success , e ) => {
697
- if ( success )
698
- {
699
- TaskManager . Run ( UsageTracker . IncrementHistoryViewToolbarPull ) ;
700
-
701
- EditorUtility . DisplayDialog ( Localization . PullActionTitle ,
702
- String . Format ( Localization . PullSuccessDescription , currentRemoteName ) ,
703
- Localization . Ok ) ;
704
- }
705
- else
706
- {
707
- EditorUtility . DisplayDialog ( Localization . PullActionTitle ,
708
- Localization . PullFailureDescription ,
709
- Localization . Ok ) ;
710
- }
711
- } )
712
- . Start ( ) ;
713
- }
714
- }
715
-
716
- private void Push ( )
717
- {
718
- Repository
719
- . Push ( )
720
- . FinallyInUI ( ( success , e ) => {
721
- if ( success )
722
- {
723
- TaskManager . Run ( UsageTracker . IncrementHistoryViewToolbarPush ) ;
724
-
725
- EditorUtility . DisplayDialog ( Localization . PushActionTitle ,
726
- String . Format ( Localization . PushSuccessDescription , currentRemoteName ) ,
727
- Localization . Ok ) ;
728
- }
729
- else
730
- {
731
- EditorUtility . DisplayDialog ( Localization . PushActionTitle ,
732
- Localization . PushFailureDescription ,
733
- Localization . Ok ) ;
734
- }
735
- } )
736
- . Start ( ) ;
737
- }
738
-
739
- private void Fetch ( )
740
- {
741
- Repository
742
- . Fetch ( )
743
- . FinallyInUI ( ( success , e ) => {
744
- if ( ! success )
745
- {
746
- TaskManager . Run ( UsageTracker . IncrementHistoryViewToolbarFetch ) ;
747
-
748
- EditorUtility . DisplayDialog ( FetchActionTitle , FetchFailureDescription ,
749
- Localization . Ok ) ;
750
- }
751
- } )
752
- . Start ( ) ;
753
- }
754
-
755
574
private void BuildTree ( )
756
575
{
757
576
treeChanges . PathSeparator = Environment . FileSystem . DirectorySeparatorChar . ToString ( ) ;
0 commit comments