Fix for edge case Diff::LCS traversals. Also ensure re-edit state is
cleared in between attempts. FossilOrigin-Name: b5f423d47a752b8e4f68a622ef1afe984ccc1f2e130de0aae5aa110309ab16d3
This commit is contained in:
parent
5ada092f95
commit
cbbb816258
1 changed files with 18 additions and 4 deletions
22
shelldap
22
shelldap
|
|
@ -1511,6 +1511,7 @@ sub run_edit
|
||||||
if ( $hash_orig eq $self->chksum($self->{'ldif_fname'}) ) {
|
if ( $hash_orig eq $self->chksum($self->{'ldif_fname'}) ) {
|
||||||
print "Entry not modified.\n";
|
print "Entry not modified.\n";
|
||||||
unlink $self->{'ldif_fname'};
|
unlink $self->{'ldif_fname'};
|
||||||
|
$self->{'edit_again'} = undef;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1523,6 +1524,7 @@ sub run_edit
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unlink $self->{'ldif_fname'};
|
unlink $self->{'ldif_fname'};
|
||||||
|
$self->{'edit_again'} = undef;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1554,7 +1556,7 @@ sub run_edit
|
||||||
my $diff_bit = $diff->Diff();
|
my $diff_bit = $diff->Diff();
|
||||||
my %seen_attr;
|
my %seen_attr;
|
||||||
|
|
||||||
# attr removals
|
# attr removal hunk
|
||||||
#
|
#
|
||||||
if ( $diff_bit == 1 ) {
|
if ( $diff_bit == 1 ) {
|
||||||
foreach ( $diff->Items(1) ) {
|
foreach ( $diff->Items(1) ) {
|
||||||
|
|
@ -1564,7 +1566,7 @@ sub run_edit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# attr insertions
|
# attr insertion hunk
|
||||||
#
|
#
|
||||||
if ( $diff_bit == 2 ) {
|
if ( $diff_bit == 2 ) {
|
||||||
foreach ( $diff->Items(2) ) {
|
foreach ( $diff->Items(2) ) {
|
||||||
|
|
@ -1574,9 +1576,12 @@ sub run_edit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# attr change
|
# attr change hunk
|
||||||
#
|
#
|
||||||
if ( $diff_bit == 3 ) {
|
if ( $diff_bit == 3 ) {
|
||||||
|
|
||||||
|
# modification to existing line
|
||||||
|
#
|
||||||
foreach ( $diff->Items(2) ) {
|
foreach ( $diff->Items(2) ) {
|
||||||
my ( $attr, $val ) = $parse->( $_ ) or next;
|
my ( $attr, $val ) = $parse->( $_ ) or next;
|
||||||
$self->debug("MODIFY: $_");
|
$self->debug("MODIFY: $_");
|
||||||
|
|
@ -1608,6 +1613,15 @@ sub run_edit
|
||||||
$e->replace( $attr => \@new_vals );
|
$e->replace( $attr => \@new_vals );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# deletion within the same hunk
|
||||||
|
#
|
||||||
|
foreach ( $diff->Items(1) ) {
|
||||||
|
my ( $attr, $val ) = $parse->( $_ ) or next;
|
||||||
|
next if $seen_attr{ $attr };
|
||||||
|
$self->debug("DELETE: $_");
|
||||||
|
$e->delete( $attr => [ $val ] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2143,7 +2157,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
$0 = 'shelldap';
|
$0 = 'shelldap';
|
||||||
my $VERSION = '1.0.0';
|
my $VERSION = '1.0.1';
|
||||||
|
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use YAML::Syck;
|
use YAML::Syck;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue