1
1
import { SourceControlResourceGroup , window } from "vscode" ;
2
- import { SvnDepth } from "../common/types " ;
2
+ import { checkAndPromptDepth , confirmRevert } from "../input/revert " ;
3
3
import { Command } from "./command" ;
4
4
5
5
export class RevertAll extends Command {
@@ -10,33 +10,17 @@ export class RevertAll extends Command {
10
10
public async execute ( resourceGroup : SourceControlResourceGroup ) {
11
11
const resourceStates = resourceGroup . resourceStates ;
12
12
13
- if ( resourceStates . length === 0 ) {
13
+ if ( resourceStates . length === 0 || ! ( await confirmRevert ( ) ) ) {
14
14
return ;
15
15
}
16
16
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 ) ;
23
19
24
- if ( answer !== yes ) {
20
+ if ( ! depth ) {
25
21
return ;
26
22
}
27
23
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
-
40
24
await this . runByRepository ( uris , async ( repository , resources ) => {
41
25
if ( ! repository ) {
42
26
return ;
@@ -45,7 +29,7 @@ export class RevertAll extends Command {
45
29
const paths = resources . map ( resource => resource . fsPath ) ;
46
30
47
31
try {
48
- await repository . revert ( paths , pick . label ) ;
32
+ await repository . revert ( paths , depth ) ;
49
33
} catch ( error ) {
50
34
console . log ( error ) ;
51
35
window . showErrorMessage ( "Unable to revert" ) ;
0 commit comments