| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.010; |
|
3
|
2
|
|
|
2
|
|
1786
|
use strict; |
|
|
2
|
|
|
|
|
7
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
53
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use utf8; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
58
|
|
|
6
|
2
|
|
|
2
|
|
9
|
use Moo; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
15
|
|
|
7
|
2
|
|
|
2
|
|
49
|
use Types::Standard qw(Int Str Bool HashRef); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
24
|
|
|
8
|
2
|
|
|
2
|
|
681
|
use List::Util qw(first); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
38
|
|
|
9
|
2
|
|
|
2
|
|
2228
|
use App::Sqitch::X qw(hurl); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
143
|
|
|
10
|
2
|
|
|
2
|
|
11
|
use Locale::TextDomain qw(App-Sqitch); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
22
|
|
|
11
|
2
|
|
|
2
|
|
571
|
use namespace::autoclean; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
23
|
|
|
12
|
2
|
|
|
2
|
|
356
|
|
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
18
|
|
|
13
|
|
|
|
|
|
|
extends 'App::Sqitch::Command'; |
|
14
|
|
|
|
|
|
|
with 'App::Sqitch::Role::ContextCommand'; |
|
15
|
|
|
|
|
|
|
with 'App::Sqitch::Role::ConnectingCommand'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = 'v1.3.0'; # VERSION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has target => ( |
|
20
|
|
|
|
|
|
|
is => 'ro', |
|
21
|
|
|
|
|
|
|
isa => Str, |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has to_change => ( |
|
25
|
|
|
|
|
|
|
is => 'ro', |
|
26
|
|
|
|
|
|
|
isa => Str, |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has modified => ( |
|
30
|
|
|
|
|
|
|
is => 'ro', |
|
31
|
|
|
|
|
|
|
isa => Bool, |
|
32
|
|
|
|
|
|
|
default => 0, |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has no_prompt => ( |
|
36
|
|
|
|
|
|
|
is => 'ro', |
|
37
|
|
|
|
|
|
|
isa => Bool |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has prompt_accept => ( |
|
41
|
|
|
|
|
|
|
is => 'ro', |
|
42
|
|
|
|
|
|
|
isa => Bool |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has log_only => ( |
|
46
|
|
|
|
|
|
|
is => 'ro', |
|
47
|
|
|
|
|
|
|
isa => Bool, |
|
48
|
|
|
|
|
|
|
default => 0, |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has lock_timeout => ( |
|
52
|
|
|
|
|
|
|
is => 'ro', |
|
53
|
|
|
|
|
|
|
isa => Int, |
|
54
|
|
|
|
|
|
|
lazy => 1, |
|
55
|
|
|
|
|
|
|
default => sub { App::Sqitch::Engine::default_lock_timeout() }, |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has variables => ( |
|
59
|
|
|
|
|
|
|
is => 'ro', |
|
60
|
|
|
|
|
|
|
isa => HashRef, |
|
61
|
|
|
|
|
|
|
lazy => 1, |
|
62
|
|
|
|
|
|
|
default => sub { {} }, |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return qw( |
|
66
|
|
|
|
|
|
|
target|t=s |
|
67
|
|
|
|
|
|
|
to-change|to|change=s |
|
68
|
|
|
|
|
|
|
set|s=s% |
|
69
|
|
|
|
|
|
|
log-only |
|
70
|
|
|
|
|
|
|
lock-timeout=i |
|
71
|
|
|
|
|
|
|
modified|m |
|
72
|
|
|
|
|
|
|
y |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my ( $class, $config, $opt ) = @_; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my %params = map { $_ => $opt->{$_} } grep { exists $opt->{$_} } qw( |
|
79
|
|
|
|
|
|
|
to_change |
|
80
|
|
|
|
|
|
|
log_only |
|
81
|
|
|
|
|
|
|
lock_timeout |
|
82
|
|
|
|
|
|
|
target |
|
83
|
|
|
|
|
|
|
modified |
|
84
|
|
|
|
|
|
|
); |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
if ( my $vars = $opt->{set} ) { |
|
87
|
|
|
|
|
|
|
$params{variables} = $vars |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$params{no_prompt} = delete $opt->{y} // $config->get( |
|
91
|
|
|
|
|
|
|
key => 'revert.no_prompt', |
|
92
|
|
|
|
|
|
|
as => 'bool', |
|
93
|
|
|
|
|
|
|
) // 0; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$params{prompt_accept} = $config->get( |
|
96
|
|
|
|
|
|
|
key => 'revert.prompt_accept', |
|
97
|
|
|
|
|
|
|
as => 'bool', |
|
98
|
|
|
|
|
|
|
) // 1; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
return \%params; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my ($self, $target) = @_; |
|
104
|
|
|
|
|
|
|
my $cfg = $self->sqitch->config; |
|
105
|
|
|
|
|
|
|
return ( |
|
106
|
|
|
|
|
|
|
%{ $cfg->get_section(section => 'core.variables') }, |
|
107
|
15
|
|
|
15
|
|
701
|
%{ $cfg->get_section(section => 'deploy.variables') }, |
|
108
|
15
|
|
|
|
|
290
|
%{ $cfg->get_section(section => 'revert.variables') }, |
|
109
|
|
|
|
|
|
|
%{ $target->variables }, # includes engine |
|
110
|
15
|
|
|
|
|
88
|
%{ $self->variables }, # --set |
|
111
|
15
|
|
|
|
|
55
|
); |
|
112
|
15
|
|
|
|
|
55
|
} |
|
113
|
15
|
|
|
|
|
306
|
|
|
114
|
15
|
|
|
|
|
117
|
my $self = shift; |
|
|
15
|
|
|
|
|
614
|
|
|
115
|
|
|
|
|
|
|
my ($targets, $changes) = $self->parse_args( |
|
116
|
|
|
|
|
|
|
target => $self->target, |
|
117
|
|
|
|
|
|
|
args => \@_, |
|
118
|
|
|
|
|
|
|
); |
|
119
|
10
|
|
|
10
|
1
|
25339
|
|
|
120
|
10
|
|
|
|
|
83
|
# Warn on multiple targets. |
|
121
|
|
|
|
|
|
|
my $target = shift @{ $targets }; |
|
122
|
|
|
|
|
|
|
$self->warn(__x( |
|
123
|
|
|
|
|
|
|
'Too many targets specified; connecting to {target}', |
|
124
|
|
|
|
|
|
|
target => $target->name, |
|
125
|
|
|
|
|
|
|
)) if @{ $targets }; |
|
126
|
8
|
|
|
|
|
584
|
|
|
|
8
|
|
|
|
|
26
|
|
|
127
|
|
|
|
|
|
|
# Warn on too many changes. |
|
128
|
|
|
|
|
|
|
my $engine = $target->engine; |
|
129
|
|
|
|
|
|
|
my $change = $self->modified |
|
130
|
8
|
100
|
|
|
|
16
|
? $engine->planned_deployed_common_ancestor_id |
|
|
8
|
|
|
|
|
50
|
|
|
131
|
|
|
|
|
|
|
: $self->to_change // shift @{ $changes }; |
|
132
|
|
|
|
|
|
|
$self->warn(__x( |
|
133
|
8
|
|
|
|
|
775
|
'Too many changes specified; reverting to "{change}"', |
|
134
|
|
|
|
|
|
|
change => $change, |
|
135
|
|
|
|
|
|
|
)) if @{ $changes }; |
|
136
|
8
|
100
|
100
|
|
|
1653
|
|
|
|
5
|
|
|
|
|
17
|
|
|
137
|
|
|
|
|
|
|
# Now get to work. |
|
138
|
|
|
|
|
|
|
$engine->no_prompt( $self->no_prompt ); |
|
139
|
|
|
|
|
|
|
$engine->prompt_accept( $self->prompt_accept ); |
|
140
|
8
|
100
|
|
|
|
23
|
$engine->log_only( $self->log_only ); |
|
|
8
|
|
|
|
|
31
|
|
|
141
|
|
|
|
|
|
|
$engine->lock_timeout( $self->lock_timeout ); |
|
142
|
|
|
|
|
|
|
$engine->set_variables( $self->_collect_vars($target) ); |
|
143
|
8
|
|
|
|
|
267
|
$engine->revert( $change ); |
|
144
|
8
|
|
|
|
|
346
|
return $self; |
|
145
|
8
|
|
|
|
|
323
|
} |
|
146
|
8
|
|
|
|
|
291
|
|
|
147
|
8
|
|
|
|
|
454
|
1; |
|
148
|
8
|
|
|
|
|
183
|
|
|
149
|
8
|
|
|
|
|
145
|
|
|
150
|
|
|
|
|
|
|
=head1 Name |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
App::Sqitch::Command::revert - Revert Sqitch changes from a database |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 Synopsis |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
my $cmd = App::Sqitch::Command::revert->new(%params); |
|
157
|
|
|
|
|
|
|
$cmd->execute; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 Description |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
If you want to know how to use the C<revert> command, you probably want to be |
|
162
|
|
|
|
|
|
|
reading C<sqitch-revert>. But if you really want to know how the C<revert> command |
|
163
|
|
|
|
|
|
|
works, read on. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 Interface |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 Class Methods |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head3 C<options> |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my @opts = App::Sqitch::Command::revert->options; |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Returns a list of L<Getopt::Long> option specifications for the command-line |
|
174
|
|
|
|
|
|
|
options for the C<revert> command. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 Attributes |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head3 C<log_only> |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Boolean indicating whether to log the deploy without running the scripts. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head3 C<lock_timeout> |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
The number of seconds to wait for an exclusive advisory lock on the target, |
|
185
|
|
|
|
|
|
|
for engines that support the feature. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head3 C<modified> |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Boolean to revert to the change prior to earliest change with a revised |
|
190
|
|
|
|
|
|
|
deploy script. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head3 C<no_prompt> |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Boolean indicating whether or not to prompt the user to really go through with |
|
195
|
|
|
|
|
|
|
the revert. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head3 C<prompt_accept> |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Boolean value to indicate whether or not the default value for the prompt, |
|
200
|
|
|
|
|
|
|
should the user hit C<return>, is to accept the prompt or deny it. |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head3 C<target> |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
The deployment target URI. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head3 C<to_change> |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Change to revert to. |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 Instance Methods |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head3 C<execute> |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
$revert->execute; |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Executes the revert command. |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 See Also |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=over |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item L<sqitch-revert> |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Documentation for the C<revert> command to the Sqitch command-line client. |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item L<sqitch> |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
The Sqitch command-line client. |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=back |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 Author |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
David E. Wheeler <david@justatheory.com> |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 License |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Copyright (c) 2012-2022 iovation Inc., David E. Wheeler |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
241
|
|
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal |
|
242
|
|
|
|
|
|
|
in the Software without restriction, including without limitation the rights |
|
243
|
|
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
244
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is |
|
245
|
|
|
|
|
|
|
furnished to do so, subject to the following conditions: |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all |
|
248
|
|
|
|
|
|
|
copies or substantial portions of the Software. |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
251
|
|
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
252
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
253
|
|
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
254
|
|
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
255
|
|
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
256
|
|
|
|
|
|
|
SOFTWARE. |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=cut |