X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=git-debrebase;h=aaf7f9338e3f143a804fd096d7973034be238168;hp=f254ddc9ae91ad77cb71158f80522c7c2617b064;hb=a68dd524881ea9e1345e1b67320c56601bd6ee04;hpb=29d1c96dcbf327e6bf78e689642a6fafd8ab1571 diff --git a/git-debrebase b/git-debrebase index f254ddc9..aaf7f933 100755 --- a/git-debrebase +++ b/git-debrebase @@ -137,6 +137,13 @@ sub cfg ($) { memoize('cfg'); +sub dd ($) { + my ($v) = @_; + my $dd = new Data::Dumper [ $v ]; + Terse $dd 1; Indent $dd 0; Useqq $dd 1; + return Dump $dd; +} + sub get_commit ($) { my ($objid) = @_; my $data = git_cat_file $objid, 'commit'; @@ -327,7 +334,7 @@ sub parsecommit ($;$) { foreach my $ph (@ph) { push @$p_ref, { - Ix => $#$p_ref, + Ix => scalar @$p_ref, CommitId => $ph, }; } @@ -354,9 +361,7 @@ sub classify ($) { my ($type, @rest) = @_; $r = { %$r, Type => $type, @rest }; if ($debuglevel) { - my $dd = new Data::Dumper [ $r ]; - Terse $dd 1; Indent $dd 0; Useqq $dd 1; - printdebug " = $type ".(Dump $dd)."\n"; + printdebug " = $type ".(dd $r)."\n"; } return $r; }; @@ -456,8 +461,8 @@ sub classify ($) { if (@p == 2 && !$haspatches && !$p[$prevbrw]{IsOrigin} && # breakwater never starts with an origin - !($p[$prevbrw]{Differs} & ~DS_DEB) && - !($p[!$prevbrw]{Differs} & ~D_UPS)) { + !($p[!$prevbrw]{Differs} & ~DS_DEB) && # no non-debian changess + !($p[$prevbrw]{Differs} & ~D_UPS)) { # no non-upstream changes return $classify->(qw(BreakwaterUpstreamMerge), OrigParents => [ $p[!$prevbrw] ]); } @@ -476,6 +481,8 @@ sub walk ($;$$) { # => ($tip, $breakwater_tip, $last_upstream_merge_in_breakwater) # (or nothing, if $nogenerate) + printdebug "*** WALK $input ".($nogenerate//0)." ".($report//'-')."\n"; + # go through commits backwards # we generate two lists of commits to apply: # breakwater branch and upstream patches @@ -590,6 +597,7 @@ sub walk ($;$$) { printf $report " PM=%s \@Overwr:%d", $pm, (scalar @$ovwrs) if $report; if (@$ovwrs != 1) { + printdebug "*** WALK BOMB DgitImportUnpatched\n"; return $bomb->(); } my $ovwr = $ovwrs->[0]{CommitId}; @@ -642,10 +650,15 @@ sub walk ($;$$) { } die "$ty ?"; } else { + printdebug "*** WALK BOMB unrecognised\n"; return $bomb->(); } } $prprdelim->(); + + printdebug "*** WALK prep done cur=$cur". + " brw $#brw_cl upp $#upp_cl proc $#processed pm $#pseudomerges\n"; + return if $nogenerate; # Now we build it back up again @@ -744,7 +757,9 @@ sub walk ($;$$) { die sprintf "internal error %#x %s %s", $final_check, $build, $input if $final_check & ~D_PAT_ADD; - return ($build, $breakwater, $last_upstream_update); + my @r = ($build, $breakwater, $last_upstream_update); + printdebug "*** WALK RETURN @r\n"; + return @r } sub get_head () { return git_rev_parse qw(HEAD); } @@ -807,9 +822,10 @@ sub cmd_new_upstream_v0 () { my ($n, @x) = @_; # may be '' my $pc = $pieces{$n} //= { Name => $n, - Desc => ($n ? "upstream piece $n" : "upstream (main piece"), + Desc => ($n ? "upstream piece \`$n'" : "upstream (main piece"), }; while (my $k = shift @x) { $pc->{$k} = shift @x; } + $pc; }; my @newpieces; @@ -868,14 +884,17 @@ sub cmd_new_upstream_v0 () { foreach my $pc (values %pieces) { if (!$pc->{Old}) { - $problem->("introducing upstream piece $pc->{Name}"); + $problem->("introducing upstream piece \`$pc->{Name}'"); } elsif (!$pc->{New}) { - $problem->("dropping upstream piece $pc->{Name}"); + $problem->("dropping upstream piece \`$pc->{Name}'"); } elsif (!is_fast_fwd $pc->{Old}, $pc->{New}) { $problem->("not fast forward: $pc->{Name} $pc->{Old}..$pc->{New}"); } } + printdebug "%pieces = ", (dd \%pieces), "\n"; + printdebug "\@newpieces = ", (dd \@newpieces), "\n"; + if ($problems) { if ($opt_force) { printf STDERR @@ -930,19 +949,19 @@ sub cmd_new_upstream_v0 () { # index now contains the breakwater merge contents - my $bw_tree = cmdoutput @git, qw(write_tree); + my $bw_tree = cmdoutput @git, qw(write-tree); my @cmd = (@git, qw(commit-tree), $bw_tree); push @cmd, qw(-p), $old_bw, qw(-p), $new_upstream; push @cmd, qw(-m), "Update to upstream $new_upstream_version"; push @cmd, qw(-m), "[git-debrebase new-upstream breakwater $new_upstream_version]"; - $new_bw = cmdoutput @git; + $new_bw = cmdoutput @cmd; # Now we have to add a changelog stanza so the Debian version # is right. die if unlink "debian"; - die unless $!==ENOTEMPTY; + die $! unless $!==ENOTEMPTY; unlink "debian/changelog" or die $!; open CN, ">", "debian/changelog" or die $!; my $oldclog = git_cat_file ":debian/changelog"; @@ -962,14 +981,14 @@ END # Now we have the final new breakwater branch in the index - $bw_tree = cmdoutput @git, qw(write_tree); + $bw_tree = cmdoutput @git, qw(write-tree); @cmd = (@git, qw(commit-tree), $bw_tree); push @cmd, qw(-p), $new_bw; push @cmd, qw(-m), "Update changelog for new upstream $new_upstream_version"; push @cmd, qw(-m), "[git-debrebase new-upstream changelog $new_upstream_version]"; - $new_bw = cmdoutput @git; + $new_bw = cmdoutput @cmd; }; # we have constructed the new breakwater. we now need to commit to