@@ -449,172 +449,29 @@ sealed class BranchesCache : ManagedCacheBase<BranchesCache>, IBranchCache
449449
450450 public BranchesCache ( ) : base ( CacheType . Branches )
451451 { }
452-
453- public GitBranch [ ] LocalBranches
454- {
455- get { return localBranches ; }
456- set
457- {
458- var now = DateTimeOffset . Now ;
459- var isUpdated = false ;
460-
461- Logger . Trace ( "Updating: {0} localBranches:{1}" , now , value . Length ) ;
462-
463- var localBranchesIsNull = localBranches == null ;
464- var valueIsNull = value == null ;
465-
466- if ( localBranchesIsNull != valueIsNull ||
467- ! localBranchesIsNull && ! localBranches . SequenceEqual ( value ) )
468- {
469- localBranches = value ;
470- isUpdated = true ;
471- }
472-
473- SaveData ( now , isUpdated ) ;
474- }
475- }
476-
477- public GitBranch [ ] RemoteBranches
478- {
479- get { return remoteBranches ; }
480- set
481- {
482- var now = DateTimeOffset . Now ;
483- var isUpdated = false ;
484-
485- Logger . Trace ( "Updating: {0} remoteBranches:{1}" , now , value . Length ) ;
486-
487- var remoteBranchesIsNull = remoteBranches == null ;
488- var valueIsNull = value == null ;
489-
490- if ( remoteBranchesIsNull != valueIsNull ||
491- ! remoteBranchesIsNull && ! remoteBranches . SequenceEqual ( value ) )
492- {
493- remoteBranches = value ;
494- isUpdated = true ;
495- }
496-
497- SaveData ( now , isUpdated ) ;
498- }
499- }
500-
501- public GitRemote [ ] Remotes
502- {
503- get { return remotes ; }
504- set
505- {
506- var now = DateTimeOffset . Now ;
507- var isUpdated = false ;
508-
509- Logger . Trace ( "Updating: {0} remotes:{1}" , now , value . Length ) ;
510-
511- var remotesIsNull = remotes == null ;
512- var valueIsNull = value == null ;
513-
514- if ( remotesIsNull != valueIsNull ||
515- ! remotesIsNull && ! remotes . SequenceEqual ( value ) )
516- {
517- remotes = value ;
518- isUpdated = true ;
519- }
520-
521- SaveData ( now , isUpdated ) ;
522- }
523- }
524-
525- public void RemoveLocalBranch ( string branch )
526- {
527- if ( LocalConfigBranches . ContainsKey ( branch ) )
528- {
529- var now = DateTimeOffset . Now ;
530- LocalConfigBranches . Remove ( branch ) ;
531- Logger . Trace ( "RemoveLocalBranch {0} branch:{1} " , now , branch ) ;
532- SaveData ( now , true ) ;
533- }
534- else
535- {
536- Logger . Warning ( "Branch {0} is not found" , branch ) ;
537- }
538- }
539-
540- public void AddLocalBranch ( string branch )
541- {
542- if ( ! LocalConfigBranches . ContainsKey ( branch ) )
543- {
544- var now = DateTimeOffset . Now ;
545- LocalConfigBranches . Add ( branch , new ConfigBranch ( branch ) ) ;
546- Logger . Trace ( "AddLocalBranch {0} branch:{1} " , now , branch ) ;
547- SaveData ( now , true ) ;
548- }
549- else
550- {
551- Logger . Warning ( "Branch {0} is already present" , branch ) ;
552- }
553- }
554-
555- public void AddRemoteBranch ( string remote , string branch )
556- {
557- Dictionary < string , ConfigBranch > branchList ;
558- if ( RemoteConfigBranches . TryGetValue ( remote , out branchList ) )
559- {
560- if ( ! branchList . ContainsKey ( branch ) )
561- {
562- var now = DateTimeOffset . Now ;
563- branchList . Add ( branch , new ConfigBranch ( branch , ConfigRemotes [ remote ] ) ) ;
564- Logger . Trace ( "AddRemoteBranch {0} remote:{1} branch:{2} " , now , remote , branch ) ;
565- SaveData ( now , true ) ;
566- }
567- else
568- {
569- Logger . Warning ( "Branch {0} is already present in Remote {1}" , branch , remote ) ;
570- }
571- }
572- else
573- {
574- Logger . Warning ( "Remote {0} is not found" , remote ) ;
575- }
576- }
577-
578- public void RemoveRemoteBranch ( string remote , string branch )
579- {
580- Dictionary < string , ConfigBranch > branchList ;
581- if ( RemoteConfigBranches . TryGetValue ( remote , out branchList ) )
582- {
583- if ( branchList . ContainsKey ( branch ) )
584- {
585- var now = DateTimeOffset . Now ;
586- branchList . Remove ( branch ) ;
587- Logger . Trace ( "RemoveRemoteBranch {0} remote:{1} branch:{2} " , now , remote , branch ) ;
588- SaveData ( now , true ) ;
589- }
590- else
591- {
592- Logger . Warning ( "Branch {0} is not found in Remote {1}" , branch , remote ) ;
593- }
594- }
595- else
596- {
597- Logger . Warning ( "Remote {0} is not found" , remote ) ;
598- }
599- }
600-
601- public void SetRemotes ( Dictionary < string , ConfigRemote > remoteConfigs , Dictionary < string , Dictionary < string , ConfigBranch > > remoteConfigBranches )
452+ public void SetRemotes ( Dictionary < string , ConfigRemote > remoteConfigs , Dictionary < string , Dictionary < string , ConfigBranch > > configBranches , GitRemote [ ] gitRemotes , GitBranch [ ] gitBranches )
602453 {
603454 var now = DateTimeOffset . Now ;
604455 configRemotes = new ConfigRemoteDictionary ( remoteConfigs ) ;
605- this . remoteConfigBranches = new RemoteConfigBranchDictionary ( remoteConfigBranches ) ;
456+ remoteConfigBranches = new RemoteConfigBranchDictionary ( remoteConfigBranches ) ;
457+ remotes = gitRemotes ;
458+ remoteBranches = gitBranches ;
606459 Logger . Trace ( "SetRemotes {0}" , now ) ;
607460 SaveData ( now , true ) ;
608461 }
609462
610463 public void SetLocals ( Dictionary < string , ConfigBranch > configBranches , GitBranch [ ] gitBranches )
611464 {
612465 var now = DateTimeOffset . Now ;
613- this . localConfigBranches = new LocalConfigBranchDictionary ( configBranches ) ;
614- Logger . Trace ( "SetRemotes {0}" , now ) ;
466+ localConfigBranches = new LocalConfigBranchDictionary ( configBranches ) ;
467+ localBranches = gitBranches ;
468+ Logger . Trace ( "SetLocals {0}" , now ) ;
615469 SaveData ( now , true ) ;
616470 }
617471
472+ public GitBranch [ ] LocalBranches { get { return localBranches ; } }
473+ public GitBranch [ ] RemoteBranches { get { return remoteBranches ; } }
474+ public GitRemote [ ] Remotes { get { return remotes ; } }
618475 public ILocalConfigBranchDictionary LocalConfigBranches { get { return localConfigBranches ; } }
619476 public IRemoteConfigBranchDictionary RemoteConfigBranches { get { return remoteConfigBranches ; } }
620477 public IConfigRemoteDictionary ConfigRemotes { get { return configRemotes ; } }
0 commit comments