File tree 5 files changed +74
-1
lines changed
5 files changed +74
-1
lines changed Original file line number Diff line number Diff line change 98
98
"command" : " svn.patch" ,
99
99
"title" : " Svn patch" ,
100
100
"category" : " SVN"
101
+ },
102
+ {
103
+ "command" : " svn.remove" ,
104
+ "title" : " Remove Selected" ,
105
+ "category" : " SVN"
101
106
}
102
107
],
103
108
"menus" : {
142
147
"command" : " svn.revert" ,
143
148
"when" : " scmProvider == svn && scmResourceGroup == changes" ,
144
149
"group" : " 1_modification"
150
+ },
151
+ {
152
+ "command" : " svn.remove" ,
153
+ "when" : " scmProvider == svn && scmResourceGroup == changes" ,
154
+ "group" : " 2_modification"
145
155
}
146
156
],
147
157
"editor/title" : []
Original file line number Diff line number Diff line change @@ -365,6 +365,41 @@ export class SvnCommands {
365
365
}
366
366
}
367
367
368
+ @command ( "svn.remove" , { repository : true } )
369
+ async remove (
370
+ repository : Repository ,
371
+ ...resourceStates : Resource [ ]
372
+ ) : Promise < void > {
373
+ let keepLocal ;
374
+ const answer = await window . showWarningMessage (
375
+ "Would you like to keep a local copy of the files?." ,
376
+ "Yes" ,
377
+ "No"
378
+ ) ;
379
+
380
+ if ( ! answer ) {
381
+ return ;
382
+ }
383
+
384
+ if ( answer === "Yes" ) {
385
+ keepLocal = true ;
386
+ } else {
387
+ keepLocal = false ;
388
+ }
389
+
390
+ try {
391
+ const paths = resourceStates . map ( state => {
392
+ return state . resourceUri . fsPath ;
393
+ } ) ;
394
+
395
+ const result = await repository . repository . removeFiles ( paths , keepLocal ) ;
396
+ repository . update ( ) ;
397
+ } catch ( error ) {
398
+ console . error ( error ) ;
399
+ window . showErrorMessage ( "Unable to remove files" ) ;
400
+ }
401
+ }
402
+
368
403
private runByRepository < T > (
369
404
resource : Uri ,
370
405
fn : ( repository : Repository , resource : Uri ) => Promise < T >
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ export class Repository {
167
167
const fileConfig = workspace . getConfiguration ( "files" ) ;
168
168
const svnConfig = workspace . getConfiguration ( "svn" ) ;
169
169
170
- const filesToExclude = fileConfig . get < any > ( "exclude" , { } ) ;
170
+ const filesToExclude = fileConfig . get < any > ( "exclude" , null ) ;
171
171
172
172
let excludeList : string [ ] = [ ] ;
173
173
for ( const pattern in filesToExclude ) {
Original file line number Diff line number Diff line change @@ -271,4 +271,22 @@ export class Svn {
271
271
patch ( root : string ) {
272
272
return this . exec ( root , [ "diff" ] ) ;
273
273
}
274
+
275
+ remove ( files : any [ ] , keepLocal : boolean ) {
276
+ let args = [ "remove" ] ;
277
+
278
+ if ( keepLocal ) {
279
+ args . push ( "--keep-local" ) ;
280
+ }
281
+
282
+ for ( let file of files ) {
283
+ if ( file instanceof Uri ) {
284
+ args . push ( file . fsPath ) ;
285
+ } else {
286
+ args . push ( file ) ;
287
+ }
288
+ }
289
+
290
+ return this . exec ( "" , args ) ;
291
+ }
274
292
}
Original file line number Diff line number Diff line change @@ -264,4 +264,14 @@ export class Repository {
264
264
const message = result . stdout ;
265
265
return message ;
266
266
}
267
+
268
+ async removeFiles ( files : any [ ] , keepLocal : boolean ) {
269
+ const result = await this . svn . remove ( files , keepLocal ) ;
270
+
271
+ if ( result . exitCode !== 0 ) {
272
+ throw new Error ( result . stderr ) ;
273
+ }
274
+
275
+ return result . stdout ;
276
+ }
267
277
}
You can’t perform that action at this time.
0 commit comments