62
|
186 |
220 |
1 |
$cache->{'merge'}{$current_root} ||= do {
my(@seqs) = map({[@$_];} @$recurse_mergeout);
push @seqs, [@$current_parents] if @$current_parents;
foreach my $seq (@seqs) {
++$tails{$seq->[$_]} foreach (1 .. $#$seq);
};
my(@res) = $current_root;
while (1) {
my($cand, $winner);
foreach $_ (@seqs) {
next unless @$_;
if (not $winner) {
$cand = $_->[0];
next if $tails{$cand};
push @res, $winner = $cand;
shift @$_;
--$tails{$_->[0]} if @$_;
}
elsif ($_->[0] eq $winner) {
shift @$_;
--$tails{$_->[0]} if @$_;
};
};
last unless $cand;
die q[Inconsistent hierarchy found while merging '] . $current_root . "':\n\t" . "current merge results [\n\t\t" . join(",\n\t\t", @res) . "\n\t]\n\t" . "merging failed on '${cand}'\n" unless $winner;
};
\@res
} |