@@ -19,6 +19,7 @@ import { dispose, anyEvent, filterEvent, toDisposable } from "./util";
1919import * as path from "path" ;
2020import * as micromatch from "micromatch" ;
2121import { setInterval , clearInterval } from "timers" ;
22+ import { toSvnUri } from "./uri" ;
2223
2324export class Repository {
2425 public watcher : FileSystemWatcher ;
@@ -38,6 +39,9 @@ export class Repository {
3839 private _onDidChangeStatus = new EventEmitter < void > ( ) ;
3940 readonly onDidChangeStatus : Event < void > = this . _onDidChangeStatus . event ;
4041
42+ private _onDidChangeBranch = new EventEmitter < void > ( ) ;
43+ readonly onDidChangeBranch : Event < void > = this . _onDidChangeBranch . event ;
44+
4145 get root ( ) : string {
4246 return this . repository . root ;
4347 }
@@ -59,25 +63,37 @@ export class Repository {
5963 fsWatcher . onDidCreate ,
6064 fsWatcher . onDidDelete
6165 ) ;
66+
6267 const onRepositoryChange = filterEvent (
6368 onWorkspaceChange ,
6469 uri => ! / ^ \. \. / . test ( path . relative ( repository . root , uri . fsPath ) )
6570 ) ;
6671 const onRelevantRepositoryChange = filterEvent (
6772 onRepositoryChange ,
68- uri => ! / \/ \. s v n \/ t m p / . test ( uri . path )
73+ uri => ! / [ \\ \/ ] \. s v n [ \\ \/ ] t m p / . test ( uri . path )
6974 ) ;
7075 onRelevantRepositoryChange ( this . update , this , this . disposables ) ;
7176
7277 const onRelevantSvnChange = filterEvent ( onRelevantRepositoryChange , uri =>
73- / \/ \. s v n \/ / . test ( uri . path )
78+ / [ \\ \/ ] \. s v n [ \\ \/ ] / . test ( uri . path )
7479 ) ;
80+
7581 onRelevantSvnChange (
7682 this . _onDidChangeRepository . fire ,
7783 this . _onDidChangeRepository ,
7884 this . disposables
7985 ) ;
8086
87+ this . onDidChangeRepository (
88+ async ( ) => {
89+ if ( ! this . isSwitchingBranch ) {
90+ this . currentBranch = await this . getCurrentBranch ( ) ;
91+ }
92+ } ,
93+ null ,
94+ this . disposables
95+ ) ;
96+
8197 this . sourceControl = scm . createSourceControl (
8298 "svn" ,
8399 "SVN" ,
@@ -98,12 +114,12 @@ export class Repository {
98114 null ,
99115 this . disposables
100116 ) ;
101- this . onDidChangeRepository (
102- ( ) => ( this . sourceControl . statusBarCommands = statusBar . commands ) ,
103- null ,
104- this . disposables
105- ) ;
106- this . sourceControl . statusBarCommands = statusBar . commands ;
117+
118+ const updateBranchName = async ( ) => {
119+ this . currentBranch = await this . getCurrentBranch ( ) ;
120+ this . sourceControl . statusBarCommands = statusBar . commands ;
121+ } ;
122+ updateBranchName ( ) ;
107123
108124 this . changes = this . sourceControl . createResourceGroup ( "changes" , "Changes" ) ;
109125 this . notTracked = this . sourceControl . createResourceGroup (
@@ -196,8 +212,6 @@ export class Repository {
196212 this . changes . resourceStates = changes ;
197213 this . notTracked . resourceStates = notTracked ;
198214
199- this . currentBranch = await this . getCurrentBranch ( ) ;
200-
201215 this . _onDidChangeStatus . fire ( ) ;
202216
203217 return Promise . resolve ( ) ;
@@ -208,7 +222,7 @@ export class Repository {
208222 return ;
209223 }
210224
211- return uri . with ( { scheme : "svn" , query : uri . path , path : uri . path } ) ;
225+ return toSvnUri ( uri , "" ) ;
212226 }
213227
214228 show ( filePath : string , revision ?: string ) : Promise < string > {
@@ -229,17 +243,17 @@ export class Repository {
229243
230244 async branch ( name : string ) {
231245 this . isSwitchingBranch = true ;
232- this . _onDidChangeRepository . fire ( ) ;
246+ this . _onDidChangeBranch . fire ( ) ;
233247 const response = await this . repository . branch ( name ) ;
234248 this . isSwitchingBranch = false ;
235249 this . updateBranches ( ) ;
236- this . _onDidChangeRepository . fire ( ) ;
250+ this . _onDidChangeBranch . fire ( ) ;
237251 return response ;
238252 }
239253
240254 async switchBranch ( name : string ) {
241255 this . isSwitchingBranch = true ;
242- this . _onDidChangeRepository . fire ( ) ;
256+ this . _onDidChangeBranch . fire ( ) ;
243257
244258 try {
245259 const response = await this . repository . switchBranch ( name ) ;
@@ -257,7 +271,7 @@ export class Repository {
257271 } finally {
258272 this . isSwitchingBranch = false ;
259273 this . updateBranches ( ) ;
260- this . _onDidChangeRepository . fire ( ) ;
274+ this . _onDidChangeBranch . fire ( ) ;
261275 }
262276 }
263277}
0 commit comments