chiark / gitweb /
git-debrebase: merge: Introduce $mwrecknote in walk analysis half
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 11 Aug 2018 15:23:22 +0000 (16:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 11 Aug 2018 16:05:56 +0000 (17:05 +0100)
We collect various git objects that we may want to present to the user
as wreckage.  Currently we dump them in $cl and print them out in
$nomerge.  We'll want to do better than that of course.

Also, we don't collect any wreckage for the actual series merge yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase

index 771410ef1350443ee703f45434e86fd8ae2c6e74..2a2d1ed2c81e0a83f987ccdeb8e2c6d2d426254b 100755 (executable)
@@ -1029,6 +1029,11 @@ sub walk ($;$$$) {
        fail "something useful about failed merge attempt @_ xxx".Dumper($cl);
     };
 
        fail "something useful about failed merge attempt @_ xxx".Dumper($cl);
     };
 
+    my $mwrecknote = sub {
+       my ($reftail, $commitish) = @_;
+       $cl->{MergeWreckNotes}{$reftail} = $commitish;
+    };
+
     my $last_anchor;
 
     for (;;) {
     my $last_anchor;
 
     for (;;) {
@@ -1178,6 +1183,8 @@ sub walk ($;$$$) {
 
            my $ps = $cl->{Parents};
 
 
            my $ps = $cl->{Parents};
 
+           $mwrecknote->('vanilla-merge', $cl->{CommitId});
+
            foreach my $p (@$ps) {
                $prline->(" VanillaMerge ".$p->{Ix});
                $prprdelim->();
            foreach my $p (@$ps) {
                $prline->(" VanillaMerge ".$p->{Ix});
                $prprdelim->();
@@ -1188,6 +1195,17 @@ sub walk ($;$$$) {
                $p->{Breakwater} = $p->{SeriesBase} = $pbw;
                $p->{Anchor} = $panchor;
 
                $p->{Breakwater} = $p->{SeriesBase} = $pbw;
                $p->{Anchor} = $panchor;
 
+               my $lr = $p->{LeftRight} = (qw(left right))[$p->{Ix}];
+               $mwrecknote->("$lr-input", $p->{CommitId});
+
+               my $mwrecknote_parent = sub {
+                   my ($which) = @_;
+                   $mwrecknote->("$lr-".(lc $which), $p->{$which});
+               };
+               $mwrecknote_parent->('Laundered');
+               $mwrecknote_parent->('Breakwater');
+               $mwrecknote_parent->('Anchor');
+
                $best_anchor = $panchor if
                    !defined $best_anchor or
                    is_fast_fwd $best_anchor, $panchor;
                $best_anchor = $panchor if
                    !defined $best_anchor or
                    is_fast_fwd $best_anchor, $panchor;
@@ -1196,6 +1214,8 @@ sub walk ($;$$$) {
                    " p=$panchor\n";
            }
 
                    " p=$panchor\n";
            }
 
+           $mwrecknote->('result-anchor', $best_anchor);
+
            foreach my $p (@$ps) {
                $prline->(" VanillaMerge ".$p->{Ix});
                if (!is_fast_fwd $p->{Anchor}, $best_anchor) {
            foreach my $p (@$ps) {
                $prline->(" VanillaMerge ".$p->{Ix});
                if (!is_fast_fwd $p->{Anchor}, $best_anchor) {
@@ -1242,20 +1262,32 @@ sub walk ($;$$$) {
             @ibs or confess 'internal error, expected anchor at least ?';
 
            my $ib;
             @ibs or confess 'internal error, expected anchor at least ?';
 
            my $ib;
+           my $ibleaf;
            foreach my $tibix (0..$#ibs) {
                my $tib = $ibs[$tibix];
                my $ff = is_fast_fwd $bwb, $tib;
            foreach my $tibix (0..$#ibs) {
                my $tib = $ibs[$tibix];
                my $ff = is_fast_fwd $bwb, $tib;
+               my $ok = !$ff ? 'rej' : $ib ? 'extra' : 'ok';
+               my $tibleaf = "interchange-mbcand-$ok-$tibix";
+               $mwrecknote->($tibleaf, $tib);
                next unless $ff;
                next if $ib;
                $ib = $tib;
                next unless $ff;
                next if $ib;
                $ib = $tib;
+               $ibleaf = $tibleaf;
            }
 
            $ib or $nomerge->("no suitable interchange merge base");
 
            $prline->("  VanillaMerge Base");
            $prprdelim->();
            }
 
            $ib or $nomerge->("no suitable interchange merge base");
 
            $prline->("  VanillaMerge Base");
            $prprdelim->();
-           my ($btip, $bbw, $banchor) =
+           my ($btip, $bbw, $banchor) = eval {
                walk $ib, 0, $report, $report_lprefix.'  ';
                walk $ib, 0, $report, $report_lprefix.'  ';
+           };
+           $nomerge->("walking interchange branch merge base ($ibleaf): ".
+                      $@) if length $@;
+
+           $mwrecknote->("mergebase-laundered", $btip);
+           $mwrecknote->("mergebase-breakwater", $bbw);
+           $mwrecknote->("mergebase-anchor", $banchor);
 
            my $ibinfo = { SeriesTip => $btip,
                           SeriesBase => $bbw,
 
            my $ibinfo = { SeriesTip => $btip,
                           SeriesBase => $bbw,