11import { SourceControlResourceGroup , window } from "vscode" ;
2- import { SvnDepth } from "../common/types " ;
2+ import { checkAndPromptDepth , confirmRevert } from "../input/revert " ;
33import { Command } from "./command" ;
44
55export class RevertAll extends Command {
@@ -10,33 +10,17 @@ export class RevertAll extends Command {
1010 public async execute ( resourceGroup : SourceControlResourceGroup ) {
1111 const resourceStates = resourceGroup . resourceStates ;
1212
13- if ( resourceStates . length === 0 ) {
13+ if ( resourceStates . length === 0 || ! ( await confirmRevert ( ) ) ) {
1414 return ;
1515 }
1616
17- const yes = "Yes I'm sure" ;
18- const answer = await window . showWarningMessage (
19- "Are you sure? This will wipe all local changes." ,
20- { modal : true } ,
21- yes
22- ) ;
17+ const uris = resourceStates . map ( resource => resource . resourceUri ) ;
18+ const depth = await checkAndPromptDepth ( uris ) ;
2319
24- if ( answer !== yes ) {
20+ if ( ! depth ) {
2521 return ;
2622 }
2723
28- const picks : any [ ] = [ ] ;
29-
30- for ( const depth in SvnDepth ) {
31- if ( SvnDepth . hasOwnProperty ( depth ) ) {
32- picks . push ( { label : depth , description : SvnDepth [ depth ] } ) ;
33- }
34- }
35-
36- const placeHolder = "Select revert depth" ;
37- const pick = await window . showQuickPick ( picks , { placeHolder } ) ;
38- const uris = resourceStates . map ( resource => resource . resourceUri ) ;
39-
4024 await this . runByRepository ( uris , async ( repository , resources ) => {
4125 if ( ! repository ) {
4226 return ;
@@ -45,7 +29,7 @@ export class RevertAll extends Command {
4529 const paths = resources . map ( resource => resource . fsPath ) ;
4630
4731 try {
48- await repository . revert ( paths , pick . label ) ;
32+ await repository . revert ( paths , depth ) ;
4933 } catch ( error ) {
5034 console . log ( error ) ;
5135 window . showErrorMessage ( "Unable to revert" ) ;
0 commit comments