@@ -26,6 +26,7 @@ import { IFileStatus } from "./statusParser";
2626export class Repository {
2727 public watcher : FileSystemWatcher ;
2828 public sourceControl : SourceControl ;
29+ public statusBar : SvnStatusBar ;
2930 public changes : SvnResourceGroup ;
3031 public unversioned : SvnResourceGroup ;
3132 public external : SvnResourceGroup ;
@@ -36,8 +37,10 @@ export class Repository {
3637 private disposables : Disposable [ ] = [ ] ;
3738 public currentBranch = "" ;
3839 public isSwitchingBranch : boolean = false ;
40+ public isUpdatingRevision : boolean = false ;
3941 public branches : any [ ] = [ ] ;
4042 public branchesTimer : NodeJS . Timer ;
43+ public newsCommit : number = 0 ;
4144
4245 private _onDidChangeRepository = new EventEmitter < Uri > ( ) ;
4346 readonly onDidChangeRepository : Event < Uri > = this . _onDidChangeRepository
@@ -49,6 +52,10 @@ export class Repository {
4952 private _onDidChangeBranch = new EventEmitter < void > ( ) ;
5053 readonly onDidChangeBranch : Event < void > = this . _onDidChangeBranch . event ;
5154
55+ private _onDidChangeNewsCommit = new EventEmitter < void > ( ) ;
56+ readonly onDidChangeNewsCommit : Event < void > = this . _onDidChangeNewsCommit
57+ . event ;
58+
5259 get root ( ) : string {
5360 return this . repository . root ;
5461 }
@@ -114,19 +121,20 @@ export class Repository {
114121 this . sourceControl . quickDiffProvider = this ;
115122 this . disposables . push ( this . sourceControl ) ;
116123
117- const statusBar = new SvnStatusBar ( this ) ;
118- this . disposables . push ( statusBar ) ;
119- statusBar . onDidChange (
120- ( ) => ( this . sourceControl . statusBarCommands = statusBar . commands ) ,
124+ this . statusBar = new SvnStatusBar ( this ) ;
125+ this . disposables . push ( this . statusBar ) ;
126+ this . statusBar . onDidChange (
127+ ( ) => ( this . sourceControl . statusBarCommands = this . statusBar . commands ) ,
121128 null ,
122129 this . disposables
123130 ) ;
124131
125- const updateBranchName = async ( ) => {
132+ const updateBranchInfo = async ( ) => {
126133 this . currentBranch = await this . getCurrentBranch ( ) ;
127- this . sourceControl . statusBarCommands = statusBar . commands ;
134+ this . sourceControl . statusBarCommands = this . statusBar . commands ;
128135 } ;
129- updateBranchName ( ) ;
136+ this . onDidChangeStatus ( updateBranchInfo ) ;
137+ updateBranchInfo ( ) ;
130138
131139 this . changes = this . sourceControl . createResourceGroup (
132140 "changes" ,
@@ -163,7 +171,15 @@ export class Repository {
163171 } , 1000 * 60 * updateFreq ) ;
164172 }
165173
174+ const updateFreqNews = svnConfig . get < number > ( "svn.newsCommits.update" ) ;
175+ if ( updateFreqNews ) {
176+ setInterval ( ( ) => {
177+ this . updateNewsCommits ( ) ;
178+ } , 1000 * 60 * updateFreqNews ) ;
179+ }
180+
166181 this . updateBranches ( ) ;
182+ this . updateNewsCommits ( ) ;
167183 this . update ( ) ;
168184 }
169185
@@ -176,6 +192,15 @@ export class Repository {
176192 }
177193 }
178194
195+ @debounce ( 1000 )
196+ async updateNewsCommits ( ) {
197+ const newsCommit = await this . repository . countNewsCommit ( ) ;
198+ if ( newsCommit !== this . newsCommit ) {
199+ this . newsCommit = newsCommit ;
200+ this . _onDidChangeNewsCommit . fire ( ) ;
201+ }
202+ }
203+
179204 @debounce ( 1000 )
180205 async update ( ) {
181206 let changes : any [ ] = [ ] ;
@@ -286,8 +311,6 @@ export class Repository {
286311 this . external . resourceStates = [ ] ;
287312 }
288313
289- this . currentBranch = await this . getCurrentBranch ( ) ;
290-
291314 this . _onDidChangeStatus . fire ( ) ;
292315
293316 return Promise . resolve ( ) ;
@@ -362,6 +385,7 @@ export class Repository {
362385 this . isSwitchingBranch = false ;
363386 this . updateBranches ( ) ;
364387 this . _onDidChangeBranch . fire ( ) ;
388+ this . updateNewsCommits ( )
365389 return response ;
366390 }
367391
@@ -386,9 +410,18 @@ export class Repository {
386410 this . isSwitchingBranch = false ;
387411 this . updateBranches ( ) ;
388412 this . _onDidChangeBranch . fire ( ) ;
413+ this . updateNewsCommits ( )
389414 }
390415 }
391416
417+ async updateRevision ( ) {
418+ this . isUpdatingRevision = true ;
419+ const response = await this . repository . update ( ) ;
420+ this . isUpdatingRevision = false ;
421+ this . updateNewsCommits ( ) ;
422+ return response ;
423+ }
424+
392425 async resolve ( file : string , action : string ) {
393426 try {
394427 const response = await this . repository . resolve ( file , action ) ;
0 commit comments