#
# BreakwaterUpstreamMerge
# has additional entry in classification result
-# OrigParents = [ subset of Parents ]
+# OrigParents = [ subset of Parents ] # singleton list
-sub classify ($) {
- my ($objid) = @_;
+sub parsecommit ($;$) {
+ my ($objid, $p_ref) = @_;
+ # => hash with CommitId Hdr Msg Tree Parents
+ # Parents entries have only Ix CommitId
+ # $p_ref, if provided, must be [] and is used as a base for Parents
+
+ $p_ref //= [];
+ die if @$p_ref;
my ($h,$m) = get_commit $objid;
my ($t) = $h =~ m/^tree (\w+)$/m or die $objid;
my (@ph) = $h =~ m/^parent (\w+)$/mg;
- my @p;
my $r = {
CommitId => $objid,
Hdr => $h,
Msg => $m,
Tree => $t,
- Parents => \@p,
+ Parents => $p_ref,
};
foreach my $ph (@ph) {
- push @p, {
- Ix => $#p,
+ push @$p_ref, {
+ Ix => $#$p_ref,
CommitId => $ph,
- Differs => (get_differs $ph, $t),
};
}
+ return $r;
+}
+
+sub classify ($) {
+ my ($objid) = @_;
+
+ my @p;
+ my $r = parsecommit($objid, \@p);
+ my $t = $r->{Tree};
+
+ foreach my $p (@p) {
+ $p->{Differs} => (get_differs $p->{CommitId}, $t),
+ }
+
printdebug "classify $objid \$t=$t \@p",
(map { sprintf " %s/%#x", $_->{CommitId}, $_->{Differs} } @p),
"\n";
($p->{IsDgitImport},) = $p_m =~ m/^\[dgit import ([0-9a-z]+) .*\]$/m;
}
my @orig_ps = grep { ($_->{IsDgitImport}//'X') eq 'orig' } @p;
- my $m2 = $m;
+ my $m2 = $r->{Msg};
if (!(grep { !$_->{IsOrigin} } @p) and
(@orig_ps >= @p - 1) and
$m2 =~ s{^\[(dgit import unpatched .*)\]$}{[was: $1]}m) {
} else {
confess "$method ?";
}
- $rewriting ||= $cl ne pop @processed;
+ if (!$rewriting) {
+ my $procd = (pop @processed) // 'UNDEF';
+ if ($cl ne $procd) {
+ $rewriting = 1;
+ printdebug "WALK REWRITING NOW cl=$cl procd=$procd\n";
+ }
+ }
my $newtree = cmdoutput @git, qw(write-tree);
my $ch = $cl->{Hdr};
$ch =~ s{^tree .*}{tree $newtree}m or confess "$ch ?";