--- Begin Message ---
Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock
Please unblock package libconfig-model-perl
this package has a bug where data is not saved in the configuration file
if hash key names are changed. For more details on what trigger the bug, see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=681353
I've cherry picked commits from upstream (aka me) to fix this issue (note that
the patches are more readble there than in the attached debdiff):
http://anonscm.debian.org/gitweb/?p=pkg-perl/packages/libconfig-model-perl.git;a=blob_plain;f=debian/patches/fix-unsaved-changes;hb=HEAD
This change uses a mechanism which is already provided to make sure that changed
data is saved.
The second patch test the fix:
http://anonscm.debian.org/gitweb/?p=pkg-perl/packages/libconfig-model-perl.git;a=blob_plain;f=debian/patches/test-fix-unsaved-changes;hb=HEAD
All the best
unblock libconfig-model-perl/2.021-3
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 3.2.0-1-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.utf8)
Shell: /bin/sh linked to /bin/dash
diff -Nru libconfig-model-perl-2.021/debian/changelog libconfig-model-perl-2.021/debian/changelog
--- libconfig-model-perl-2.021/debian/changelog 2012-06-29 14:14:48.000000000 +0200
+++ libconfig-model-perl-2.021/debian/changelog 2012-07-13 14:46:28.000000000 +0200
@@ -1,3 +1,15 @@
+libconfig-model-perl (2.021-3) unstable; urgency=low
+
+ * use patch from upstream to fix unsaved changes (Closes: #681353)
+ Config::Model saves back data only when they are changed. To keep
+ track of the changes, the notify_changes method must be called
+ whenever a data is changed, otherwise the modifications will be
+ lost. The patch fix-unsaved-change add calls to the notify_change
+ method where it was forgotten. The second patch
+ (test-fix-unsaved-changes) add the relevant test cases.
+
+ -- Dominique Dumont <dod@debian.org> Fri, 13 Jul 2012 14:22:05 +0200
+
libconfig-model-perl (2.021-2) unstable; urgency=low
* added a patch to fix a race condition between async calls to rmadison
diff -Nru libconfig-model-perl-2.021/debian/patches/fix-unsaved-changes libconfig-model-perl-2.021/debian/patches/fix-unsaved-changes
--- libconfig-model-perl-2.021/debian/patches/fix-unsaved-changes 1970-01-01 01:00:00.000000000 +0100
+++ libconfig-model-perl-2.021/debian/patches/fix-unsaved-changes 2012-07-13 14:46:28.000000000 +0200
@@ -0,0 +1,90 @@
+Description: Fix unsaved changes when changing hash keys
+ See description in debian bug.
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=681353
+Forwarded: yes
+Origin: upstream
+Applied-Upstream: yes
+--- a/lib/Config/Model/ListId.pm
++++ b/lib/Config/Model/ListId.pm
+@@ -234,6 +234,7 @@
+ if ($ok or $check eq 'no') {
+ $self->_store($to, $moved) ;
+ $moved->index_value($to) ;
++ $self->notify_change(note => "moved from index $from to $to") ;
+ my $imode = $self->instance->get_data_mode ;
+ $self->set_data_mode( $to, $imode ) ;
+ }
+@@ -304,8 +305,7 @@
+ $self->{data}[$ida] = $objb ;
+ $self->{data}[$idb] = $obja ;
+
+- $self->notify_change(index => $ida) ;
+- $self->notify_change(index => $idb) ;
++ $self->notify_change(note => "swapped index $ida and $idb") ;
+ }
+
+ #die "check index number after wap";
+--- a/lib/Config/Model/HashId.pm
++++ b/lib/Config/Model/HashId.pm
+@@ -280,6 +280,8 @@
+ delete $self->{warning_hash}{$from} ;
+ # update index_value attribute in moved objects
+ $self->{data}{$to}->index_value($to) ;
++
++ $self->notify_change(note => "rename key from $from to $to");
+
+ # data_mode is preset or layered or user. Actually only user
+ # mode makes sense here
+@@ -333,6 +335,7 @@
+
+ my $list = $self->{list} ;
+
++ my $msg ;
+ if (defined $ref_key) {
+ for (my $idx = 0; $idx <= $#$list; $idx ++ ) {
+ if ($list->[$idx] eq $ref_key) {
+@@ -340,9 +343,16 @@
+ last;
+ }
+ }
++
++ $msg = "moved key $key_to_move after $ref_key" ;
+ } else {
+ unshift @$list , $key_to_move ;
++ $msg = "moved key $key_to_move at beginning" ;
+ }
++
++
++ $self->notify_change( note => $msg ) ;
++
+ }
+
+
+@@ -363,9 +373,13 @@
+ if ($list->[$idx] eq $key) {
+ $list->[$idx] = $list->[$idx-1];
+ $list->[$idx-1] = $key ;
++ $self->notify_change(note => "moved up key $key") ;
+ last ;
+ }
+ }
++
++ # notify_change is placed in the loop so the notification
++ # is not sent if the user tries to move up idx 0
+ }
+
+
+@@ -386,9 +400,13 @@
+ if ($list->[$idx] eq $key) {
+ $list->[$idx] = $list->[$idx+1];
+ $list->[$idx+1] = $key ;
++ $self->notify_change(note => "moved down key $key") ;
+ last ;
+ }
+ }
++
++ # notify_change is placed in the loop so the notification
++ # is not sent if the user tries to move past last idx
+ }
+
+
diff -Nru libconfig-model-perl-2.021/debian/patches/series libconfig-model-perl-2.021/debian/patches/series
--- libconfig-model-perl-2.021/debian/patches/series 2012-06-29 14:14:48.000000000 +0200
+++ libconfig-model-perl-2.021/debian/patches/series 2012-07-13 14:46:28.000000000 +0200
@@ -1,2 +1,4 @@
fix-race-condition-dependency-check
add_dh_config
+fix-unsaved-changes
+test-fix-unsaved-changes
diff -Nru libconfig-model-perl-2.021/debian/patches/test-fix-unsaved-changes libconfig-model-perl-2.021/debian/patches/test-fix-unsaved-changes
--- libconfig-model-perl-2.021/debian/patches/test-fix-unsaved-changes 1970-01-01 01:00:00.000000000 +0100
+++ libconfig-model-perl-2.021/debian/patches/test-fix-unsaved-changes 2012-07-13 14:46:28.000000000 +0200
@@ -0,0 +1,117 @@
+Description: Test fix unsaved changes
+ test for the above patch
+Origin: upstream
+Applied-Upstream: yes
+--- a/t/hash_id_of_values.t
++++ b/t/hash_id_of_values.t
+@@ -3,7 +3,7 @@
+ use warnings FATAL => qw(all);
+
+ use ExtUtils::testlib;
+-use Test::More tests => 88;
++use Test::More tests => 94;
+ use Test::Memory::Cycle;
+ use Config::Model ;
+ use Test::Exception ;
+@@ -322,6 +322,7 @@
+ $inst->clear_changes ;
+
+ $oh ->swap(qw/z x/) ;
++is($inst->needs_save,1,"verify instance needs_save status after swap") ;
+ print scalar $inst->list_changes,"\n" if $trace ;
+ $inst->clear_changes ;
+
+@@ -333,12 +334,19 @@
+ eq_or_diff([$oh->fetch_all_indexes], [qw/x a z/],
+ "check index order of ordered_hash after swap(a z)") ;
+
++$inst->clear_changes ;
+ $oh ->move_up(qw/a/) ;
++is($inst->needs_save,1,"verify instance needs_save status after move_up") ;
++print scalar $inst->list_changes,"\n" if $trace ;
++$inst->clear_changes ;
+
+ eq_or_diff([$oh->fetch_all_indexes], [qw/a x z/],
+ "check index order of ordered_hash after move_up(a)") ;
+
+ $oh ->move_down(qw/x/) ;
++is($inst->needs_save,1,"verify instance needs_save status after move_down") ;
++print scalar $inst->list_changes,"\n" if $trace ;
++$inst->clear_changes ;
+
+ eq_or_diff([$oh->fetch_all_indexes], [qw/a z x/],
+ "check index order of ordered_hash after move_down(x)") ;
+@@ -346,6 +354,10 @@
+ is($oh->fetch_with_id('x')->fetch, '2x',"Check copied value") ;
+
+ $oh->copy(qw/x d/) ;
++is($inst->needs_save,1,"verify instance needs_save status after copy") ;
++print scalar $inst->list_changes,"\n" if $trace ;
++$inst->clear_changes ;
++
+ eq_or_diff([$oh->fetch_all_indexes], [qw/a z x d/],
+ "check index order of ordered_hash after copy(x d)") ;
+ is($oh->fetch_with_id('d')->fetch, '2x',"Check copied value") ;
+@@ -355,13 +367,20 @@
+ "check index order of ordered_hash after copy(a e)") ;
+ is($oh->fetch_with_id('e')->fetch, '3a',"Check copied value") ;
+
++$inst->clear_changes ;
+ $oh->move_after('d') ;
+ eq_or_diff([$oh->fetch_all_indexes], [qw/d a z x e/],
+ "check index order of ordered_hash after move_after(d)") ;
++is($inst->needs_save,1,"verify instance needs_save status after move_after") ;
++print scalar $inst->list_changes,"\n" if $trace ;
++$inst->clear_changes ;
+
+ $oh->move_after('d','z') ;
+ eq_or_diff([$oh->fetch_all_indexes], [qw/a z d x e/],
+ "check index order of ordered_hash after move_after(d z)") ;
++is($inst->needs_save,1,"verify instance needs_save status after move_after") ;
++print scalar $inst->list_changes,"\n" if $trace ;
++$inst->clear_changes ;
+
+ $oh->move_after('d','e') ;
+ eq_or_diff([$oh->fetch_all_indexes], [qw/a z x e d/],
+--- a/t/array_id.t
++++ b/t/array_id.t
+@@ -12,7 +12,7 @@
+ use Config::Model::AnyId;
+ use Log::Log4perl qw(:easy :levels) ;
+
+-BEGIN { plan tests => 105; }
++BEGIN { plan tests => 107; }
+
+ use strict;
+
+@@ -246,7 +246,13 @@
+ $ol->fetch_with_id( $i++ )->fetch_element($e)->store($v);
+ }
+
++$inst->clear_changes ;
++
+ $ol->move( 3, 4 );
++is($inst->needs_save,1,"verify instance needs_save status after move") ;
++print scalar $inst->list_changes,"\n" if $trace ;
++$inst->clear_changes ;
++
+ is( $ol->fetch_with_id(3)->fetch_element('Z')->fetch,
+ undef, "check after move idx 3 in 4" );
+ is( $ol->fetch_with_id(4)->fetch_element('Z')->fetch,
+@@ -256,6 +262,10 @@
+ } ( 0 .. 4 );
+
+ $ol->swap( 0, 2 );
++is($inst->needs_save,1,"verify instance needs_save status after move") ;
++print scalar $inst->list_changes,"\n" if $trace ;
++$inst->clear_changes ;
++
+ is( $ol->fetch_with_id(0)->fetch_element('X')->fetch,
+ undef, "check after move idx 0 in 2" );
+ is( $ol->fetch_with_id(0)->fetch_element('Y')->fetch, 'Av',
+@@ -401,4 +411,4 @@
+ eq_or_diff( [ $pl->fetch_all_indexes ], [0] ,"check that only layered stuff was cleared");
+ is($pl->fetch_with_id(0)->fetch,'bar',"check that bar was moved from 1 to 0");
+ $pl->clear ;
+-memory_cycle_ok($model);
++memory_cycle_ok($model,"memory cycles");
--- End Message ---