]> 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 43ffb1fd8362802dc19f06074437e1f0a4c87f27..35fee1aa742aab8fbffb405afa82a7f759df6b9e 100644 (file)
@@ -1507,8 +1507,13 @@ sub loadindex () {
                                $links{$page}=$d->{links};
                                $oldlinks{$page}=[@{$d->{links}}];
                        }
-                       if (exists $d->{depends}) {
-                               $depends{$page}=$d->{depends};
+                       if (exists $d->{dependslist}) {
+                               $depends{$page}={
+                                       map { $_ => 1 } @{$d->{dependslist}}
+                               };
+                       }
+                       elsif (exists $d->{depends}) {
+                               $depends{$page}={$d->{depends} => 1};
                        }
                        if (exists $d->{state}) {
                                $pagestate{$page}=$d->{state};
@@ -1554,7 +1559,7 @@ sub saveindex () {
                };
 
                if (exists $depends{$page}) {
-                       $index{page}{$src}{depends} = $depends{$page};
+                       $index{page}{$src}{dependslist} = [ keys %{$depends{$page}} ];
                }
 
                if (exists $pagestate{$page}) {
@@ -1724,16 +1729,19 @@ sub rcs_receive () {
 sub add_depends ($$) {
        my $page=shift;
        my $pagespec=shift;
-       
-       return unless pagespec_valid($pagespec);
 
-       if (! exists $depends{$page}) {
-               $depends{$page}=$pagespec;
-       }
-       else {
-               $depends{$page}=pagespec_merge($depends{$page}, $pagespec);
+       if (ref $pagespec eq 'ARRAY') {
+               foreach my $ps (@$pagespec) {
+                       if (pagespec_valid($ps)) {
+                               $depends{$page}{$ps} = 1;
+                       }
+               }
+               return;
        }
 
+       return unless pagespec_valid($pagespec);
+
+       $depends{$page}{$pagespec} = 1;
        return 1;
 }