Skip to content

Commit

Permalink
Merge pull request #11363 from mlschroe/master
Browse files Browse the repository at this point in the history
[backend] BSDispatcher::list2struct: add to arrays in leaf elements
  • Loading branch information
mlschroe committed Jul 23, 2021
2 parents 48b331b + 998876e commit c67d1a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/backend/BSDispatcher/Constraints.pm
Expand Up @@ -225,13 +225,15 @@ sub list2struct {
my @loc = split(':', shift @l);
my @how = @$dtd;
my $out = $top;
my $outref;
while (@loc) {
my $am = shift @how;
my $e = shift @loc;
my $addit;
my $delit;
my ($addit, $delit, $modit);
$addit = 1 if $e =~ s/\+$//;
$delit = 1 if !$addit && $e =~ s/=$//;
$modit = 1 if !$addit && !$delit && $e =~ s/!$//;
$modit = 1 if !$addit && !$delit && @loc; # default non-leaf elements
my %known = map {ref($_) ? (!@$_ ? () : (ref($_->[0]) ? $_->[0]->[0] : $_->[0] => $_)) : ($_=> $_)} @how;
my $ke = $known{$e};
die("unknown element: $e\n") unless $ke;
Expand All @@ -243,25 +245,28 @@ sub list2struct {
if (!ref($ke) || (@$ke == 1 && !ref($ke->[0]))) {
die("element '$e' has subelements\n") if @loc;
die("element '$e' contains attributes\n") if @l && $l[0] =~ /=/;
delete $out->{$e} unless $addit;
if (!ref($ke)) {
delete $out->{$e} unless $addit;
die("element '$e' must be singleton\n") if exists $out->{$e};
$out->{$e} = join(' ', @l);
} else {
delete $out->{$e} if $modit;
push @{$out->{$e}}, @l;
}
@how = ();
} else {
my $nout = {};
if (@$ke == 1) {
$nout = pop @{$out->{$e}} if exists $out->{$e} && !$addit;
$nout = pop @{$out->{$e}} if exists $out->{$e} && $modit;
push @{$out->{$e}}, $nout;
@how = @{$ke->[0]};
$outref = $out->{$e};
} else {
$nout = delete $out->{$e} if exists $out->{$e} && !$addit;
die("element '$e' must be singleton\n") if exists $out->{$e};
$out->{$e} = $nout;
@how = @$ke;
$outref = undef;
}
$out = $nout;
}
Expand All @@ -287,8 +292,10 @@ sub list2struct {
shift @l;
}
if (@l) {
die("element '$am' contains content\n") unless $known{'_content'};
$out->{'_content'} = join(' ', @l);
die("element '$am' contains content\n") unless $known{'_content'};
@l = ( join(' ', @l) ) unless $outref;
$out->{'_content'} = shift @l;
push @$outref, BSUtil::clone({ %$out, '_content' => $_ }) for @l;
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/backend/bs_repserver
Expand Up @@ -2684,7 +2684,7 @@ sub forwardevent {
$arch = 'publish' if $type eq 'publish';
if ($type eq 'suspendproject' || $type eq 'resumeproject') {
# those events stack - we must not overwrite them. randomize somewhat.
$evname = "type:::$$-".Digest::MD5::md5_hex("$$/$evname".time());
$evname = "${type}:::$$-".Digest::MD5::md5_hex("$$/$evname".time());
}
if ($arch) {
mkdir_p("$eventdir/$arch");
Expand Down

0 comments on commit c67d1a3

Please sign in to comment.