[libconfig-model-dpkg-perl] 27/33: Copyright update: use dclone to avoid mixups :-/

dod at debian.org dod at debian.org
Mon Mar 30 17:41:45 UTC 2015


This is an automated email from the git hooks/post-receive script.

dod pushed a commit to branch master
in repository libconfig-model-dpkg-perl.

commit 9cbbbf3b2a63b3f87cb6770a894ea82d6450b1e0
Author: Dominique Dumont <dod at debian.org>
Date:   Sat Mar 28 17:46:46 2015 +0100

    Copyright update: use dclone to avoid mixups :-/
---
 lib/Config/Model/Dpkg/Copyright.pm | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/lib/Config/Model/Dpkg/Copyright.pm b/lib/Config/Model/Dpkg/Copyright.pm
index 7517785..ef2f71b 100644
--- a/lib/Config/Model/Dpkg/Copyright.pm
+++ b/lib/Config/Model/Dpkg/Copyright.pm
@@ -17,6 +17,7 @@ use Config::Model::DumpAsData;
 use Dpkg::Copyright::Scanner qw/scan_files __squash __pack_files __create_tree_leaf_from_paths/;
 use Software::LicenseUtils;
 use Scalar::Util qw/weaken/;
+use Storable qw/dclone/;
 
 my $join_path = "\n "; # used to group Files
 
@@ -64,21 +65,22 @@ sub update ($self, %args) {
     my %data_keys;
     foreach my $path ( keys $files->%* ) {
         my ($c, $l) = $copyrights_by_id->[ $files->{$path} ]->@*;
-        #say "load '@$paths' with '$c' ('$l')";
 
-        my $new_data = delete $old_split_files{$path} || {} ;
-        # clobber old data
-        $new_data->{Copyright} = $c if ($c ne 'no-info-found' or not $new_data->{Copyright});
+        my $new_data = dclone (delete $old_split_files{$path} || {} );
+        my $old_cop = $new_data->{Copyright};
         my $old_lic = $new_data->{License}{short_name};
+        # say "load '$path' with '$c' ('$l') old '$old_cop' ('$old_lic')";
+        # clobber old data
+        $new_data->{Copyright} = $c if ($c !~ /no-info-found|UNKNOWN/ or not $old_cop);
         $new_data->{License}{short_name} = $l if ($l ne 'UNKNOWN');
 
         # create an inventory of different file copyright and license data
-        my $dumper = Data::Dumper->new([$new_data])->Sortkeys(1);
+        my $dumper = Data::Dumper->new([$new_data])->Sortkeys(1)->Indent(0);
         my $datum_dump = $dumper->Dump;
-        my $d_key;
-        if (not $d_key = $data_keys{$datum_dump}) {
+        my $d_key = $data_keys{$datum_dump};
+        if (not defined $d_key) {
             push @data,$new_data;
-            $data_keys{$datum_dump} = $d_key = $#data;
+            $d_key = $data_keys{$datum_dump} = $#data;
         }
 
         # explode path in subpaths and store id pointing to copyright data in there
@@ -90,14 +92,15 @@ sub update ($self, %args) {
     # * %new_split_files contains a tree matching a directory tree where each leaf is an integer index referencing
     #   an entry in @data to get the correct  copyright/license data
     # * %old_split_files contains paths no longer present. Useful to trace deleted files
-
     # implode files entries with same data index
+
     __squash(\%new_split_files) ;
 
     # pack files by copyright id
     my @packed = __pack_files(\%new_split_files);
 
-    # delete existing data in config tree
+    # delete existing data in config tree. A more subtle solution to track which entry is
+    # deleted or altered (when individual files are removed, renamed) is too complex.
     $files_obj->clear;
 
     # load new data in config tree

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libconfig-model-dpkg-perl.git



More information about the Pkg-perl-cvs-commits mailing list