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';
foreach my $ph (@ph) {
push @$p_ref, {
- Ix => $#$p_ref,
+ Ix => scalar @$p_ref,
CommitId => $ph,
};
}
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;
};
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] ]);
}
sub walk ($;$$) {
my ($input,
$nogenerate,$report) = @_;
- # => ($tip, $breakwater_tip)
+ # => ($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
no warnings qw(exiting); last;
};
+ my $last_upstream_update;
+
for (;;) {
$cl = classify $cur;
my $ty = $cl->{Type};
$cur = $p0;
next;
} elsif ($ty eq 'BreakwaterStart') {
+ $last_upstream_update = $cur;
$build_start->('FirstPackaging', $cur);
} elsif ($ty eq 'Upstream') {
push @upp_cl, $cl;
$cur = $contrib;
next;
} elsif ($ty eq 'BreakwaterUpstreamMerge') {
+ $last_upstream_update = $cur;
$build_start->("PreviousBreakwater", $cur);
} elsif ($ty eq 'DgitImportUnpatched') {
my $pm = $pseudomerges[-1];
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};
}
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
my $read_tree_debian = sub {
my ($treeish) = @_;
read_tree_subdir 'debian', "$treeish:debian";
+ rm_subdir_cached 'debian/patches';
};
my $read_tree_upstream = sub {
my ($treeish) = @_;
my $newcommit = cmdoutput @cmd;
confess "$ch ?" unless $rewriting or $newcommit eq $cl->{CommitId};
$build = $newcommit;
+ if (grep { $method eq $_ } qw(DgitImportUpstreamUpdate)) {
+ $last_upstream_update = $cur;
+ }
}
};
die sprintf "internal error %#x %s %s", $final_check, $build, $input
if $final_check & ~D_PAT_ADD;
- return ($build, $breakwater);
+ my @r = ($build, $breakwater, $last_upstream_update);
+ printdebug "*** WALK RETURN @r\n";
+ return @r
}
sub get_head () { return git_rev_parse qw(HEAD); }
sub cmd_launder () {
badusage "no arguments to launder allowed" if @ARGV;
my $old = get_head();
- my ($tip,$breakwater) = walk $old;
+ my ($tip,$breakwater,$last_upstream_merge) = walk $old;
update_head $old, $tip, 'launder';
# no tree changes except debian/patches
runcmd @git, qw(rm --quiet --ignore-unmatch -rf debian/patches);
printf "# breakwater tip\n%s\n", $breakwater;
printf "# working tip\n%s\n", $tip;
+ printf "# last upstream merge\n%s\n", $last_upstream_merge;
}
sub cmd_analyse () {
# now we need to investigate the branch this generates the
# laundered version but we don't switch to it yet
my $old_head = get_head();
- my ($old_laundered_tip,$old_bw) = walk $old_head;
+ my ($old_laundered_tip,$old_bw,$old_upstream_update) = walk $old_head;
my $old_bw_cl = classify $old_bw;
- my $old_upstream = parsecommit $old_bw_cl->{OrigParents}[0]{CommitId};
+ my $old_upstream_update_cl = classify $old_upstream_update;
+ confess unless $old_upstream_update_cl->{OrigParents};
+ my $old_upstream = parsecommit
+ $old_upstream_update_cl->{OrigParents}[0]{CommitId};
my $problems = 0;
my $problem = sub {
print STDERR "preflight check failed: $msg\n";
};
- $piece->('', Old => $old_upstream);
+ $piece->('', Old => $old_upstream->{CommitId});
if ($old_upstream->{Msg} =~ m{^\[git-debrebase }m) {
if ($old_upstream->{Msg} =~