]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki.pm
Allow add_depends to take an arrayref
[git.ikiwiki.info.git] / IkiWiki.pm
index 734b167cf8b00287a62f33d95122823e7b3d01a6..35fee1aa742aab8fbffb405afa82a7f759df6b9e 100644 (file)
@@ -1508,10 +1508,12 @@ sub loadindex () {
                                $oldlinks{$page}=[@{$d->{links}}];
                        }
                        if (exists $d->{dependslist}) {
-                               $depends{$page}=$d->{dependslist};
+                               $depends{$page}={
+                                       map { $_ => 1 } @{$d->{dependslist}}
+                               };
                        }
                        elsif (exists $d->{depends}) {
-                               $depends{$page}=[$d->{depends}];
+                               $depends{$page}={$d->{depends} => 1};
                        }
                        if (exists $d->{state}) {
                                $pagestate{$page}=$d->{state};
@@ -1557,7 +1559,7 @@ sub saveindex () {
                };
 
                if (exists $depends{$page}) {
-                       $index{page}{$src}{dependslist} = $depends{$page};
+                       $index{page}{$src}{dependslist} = [ keys %{$depends{$page}} ];
                }
 
                if (exists $pagestate{$page}) {
@@ -1728,18 +1730,18 @@ sub add_depends ($$) {
        my $page=shift;
        my $pagespec=shift;
 
-       return unless pagespec_valid($pagespec);
-
-       if (! exists $depends{$page}) {
-               $depends{$page}=[$pagespec];
-       }
-       else {
-               foreach my $p (@{$depends{$page}}) {
-                       return 1 if $p eq $pagespec;
+       if (ref $pagespec eq 'ARRAY') {
+               foreach my $ps (@$pagespec) {
+                       if (pagespec_valid($ps)) {
+                               $depends{$page}{$ps} = 1;
+                       }
                }
-               push @{$depends{$page}}, $pagespec;
+               return;
        }
 
+       return unless pagespec_valid($pagespec);
+
+       $depends{$page}{$pagespec} = 1;
        return 1;
 }