use Memoize;
use Carp;
+use POSIX;
use Data::Dumper;
use Debian::Dgit qw(:DEFAULT $wa);
}
sub walk ($;$$);
-sub walk {
+sub walk ($;$$) {
my ($input,
$nogenerate,$report) = @_;
# => ($tip, $breakwater_tip)
push @brw_cl, $sp_cl;
push @processed, $sp_cl;
};
-
my $cur = $input;
my $prdelim = "";
die "commit $cur: Cannot cope with this commit";
};
+ my $build;
+ my $breakwater;
+
+ my $build_start = sub {
+ my ($msg, $parent) = @_;
+ $prline->(" $msg");
+ $build = $parent;
+ no warnings qw(exiting); last;
+ };
+
for (;;) {
- if (!defined $cur) {
- push @brw_cl, { ExactlyParents => [] };
- $prline->("Origin");
- last;
- }
$cl = classify $cur;
my $ty = $cl->{Type};
my $st = $cl->{SubType};
$cur = $p0;
next;
} elsif ($ty eq 'BreakwaterStart') {
- push @brw_cl, { ExactlyParents => [$cur] };
- last;
+ $build_start->('FirstPackaging', $cur);
} elsif ($ty eq 'Upstream') {
push @upp_cl, $cl;
$cur = $p0;
$cur = $ty->{Contributor};
next;
} elsif ($ty eq 'BreakwaterUpstreamMerge') {
- push @brw_cl, { ExactlyParents => [$cur] };
- $prline->("PreviousBreakwater");
- last;
+ $build_start->("PreviousBreakwater", $cur);
} elsif ($ty eq 'DgitImportUnpatched') {
my $pm = $pseudomerges[-1];
if (defined $pm) {
}
$prline->(" Import");
$rewrite_from_here->();
- $upp_limit //= $#upp; # further, deeper, patches discarded
+ $upp_limit //= $#upp_cl; # further, deeper, patches discarded
$cur = $ovwr;
next;
} else {
# is already in valid breakwater format, with the
# patches as commits.
printf $report " NoPM" if $report;
- $prline->(" ImportOrigin");
# last thing we processed will have been the first patch,
# if there is one; which is fine, so no need to rewrite
# on account of this import
- push @brw_cl, { ExactlyParents => [$cur] };
- last;
+ $build_start->("ImportOrigin", $cur);
}
die "$ty ?";
} else {
my $rewriting = 0;
- my $build = $basis;
-
my $rm_tree_cached = sub {
my ($subdir) = @_;
runcmd @git, qw(rm --quiet -rf --cached), $subdir;
$rewriting = 1;
next;
} elsif ($method eq 'RecordBreakwaterTip') {
- last if $wantbrwonly;
$breakwater = $build;
next;
} elsif ($method eq 'DgitImportDebianUpdate') {
}
};
- runcmd @git, qw(diff-tree --quiet),
- map { $wantdebonly ? "$_:debian" : $_ }
- $input, $build;
+ runcmd @git, qw(diff-tree --quiet), $input, $build;
return ($build, $breakwater);
}
sub get_head () { return git_rev_parse qw(HEAD); }
-sub update_head ($$) {
+sub update_head ($$$) {
my ($old, $new, $mrest) = @_;
runcmd @git, qw(update-ref -m), "git-debrebase $mrest", $new, $old;
}
STDOUT->error and die $!;
}
-my $toplevel = runcmd @git, qw(rev-parse --show-toplevel);
+my $toplevel = cmdoutput @git, qw(rev-parse --show-toplevel);
chdir $toplevel or die "chdir $toplevel: $!";
my $cmd = shift @ARGV;