File tree Expand file tree Collapse file tree 5 files changed +74
-1
lines changed
Expand file tree Collapse file tree 5 files changed +74
-1
lines changed Original file line number Diff line number Diff line change 9898 "command" : " svn.patch" ,
9999 "title" : " Svn patch" ,
100100 "category" : " SVN"
101+ },
102+ {
103+ "command" : " svn.remove" ,
104+ "title" : " Remove Selected" ,
105+ "category" : " SVN"
101106 }
102107 ],
103108 "menus" : {
142147 "command" : " svn.revert" ,
143148 "when" : " scmProvider == svn && scmResourceGroup == changes" ,
144149 "group" : " 1_modification"
150+ },
151+ {
152+ "command" : " svn.remove" ,
153+ "when" : " scmProvider == svn && scmResourceGroup == changes" ,
154+ "group" : " 2_modification"
145155 }
146156 ],
147157 "editor/title" : []
Original file line number Diff line number Diff line change @@ -365,6 +365,41 @@ export class SvnCommands {
365365 }
366366 }
367367
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+
368403 private runByRepository < T > (
369404 resource : Uri ,
370405 fn : ( repository : Repository , resource : Uri ) => Promise < T >
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ export class Repository {
167167 const fileConfig = workspace . getConfiguration ( "files" ) ;
168168 const svnConfig = workspace . getConfiguration ( "svn" ) ;
169169
170- const filesToExclude = fileConfig . get < any > ( "exclude" , { } ) ;
170+ const filesToExclude = fileConfig . get < any > ( "exclude" , null ) ;
171171
172172 let excludeList : string [ ] = [ ] ;
173173 for ( const pattern in filesToExclude ) {
Original file line number Diff line number Diff line change @@ -271,4 +271,22 @@ export class Svn {
271271 patch ( root : string ) {
272272 return this . exec ( root , [ "diff" ] ) ;
273273 }
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+ }
274292}
Original file line number Diff line number Diff line change @@ -264,4 +264,14 @@ export class Repository {
264264 const message = result . stdout ;
265265 return message ;
266266 }
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+ }
267277}
You can’t perform that action at this time.
0 commit comments