runcmd @git, qw(read-tree), "--prefix=$subdir/", $new_tree_object;
}
+sub read_tree_debian ($) {
+ my ($treeish) = @_;
+ read_tree_subdir 'debian', "$treeish:debian";
+ rm_subdir_cached 'debian/patches';
+}
+
+sub read_tree_upstream ($) {
+ my ($treeish) = @_;
+ my $save = cmdoutput @git, qw(write-tree --prefix=debian/);
+ runcmd @git, qw(read-tree), $treeish;
+ read_tree_subdir 'debian', $save;
+ rm_subdir_cached 'debian/patches';
+};
+
sub make_commit ($$) {
my ($parents, $message_paras) = @_;
my $tree = cmdoutput @git, qw(write-tree);
return $snags_forced || $snags_tripped;
}
+sub gbp_pq_export ($$$) {
+ my ($bname, $base, $tip) = @_;
+ # must be run in a workarea. $bname and patch-queue/$bname
+ # ought not to exist. Leaves you on patch-queue/$bname with
+ # the patches staged but not committed.
+ runcmd @git, qw(checkout -q -b), $bname, $base;
+ runcmd @git, qw(checkout -q -b), "patch-queue/$bname", $tip;
+ my @gbp_cmd = (qw(gbp pq export));
+ my $r = system shell_cmd 'exec >../gbp-pq-err 2>&1', @gbp_cmd;
+ if ($r) {
+ { local ($!,$?); copy('../gbp-pq-err', \*STDERR); }
+ failedcmd @gbp_cmd;
+ }
+ runcmd @git, qw(add -f debian/patches);
+}
+
# classify returns an info hash like this
# CommitId => $objid
# Hdr => # commit headers, including 1 final newline
return ($anchor, $breakwater);
}
-sub walk ($;$$);
-sub walk ($;$$) {
+sub walk ($;$$$);
+sub walk ($;$$$) {
my ($input,
- $nogenerate,$report) = @_;
+ $nogenerate,$report, $report_lprefix) = @_;
# => ($tip, $breakwater_tip, $last_anchor)
# (or nothing, if $nogenerate)
printdebug "*** WALK $input ".($nogenerate//0)." ".($report//'-')."\n";
+ $report_lprefix //= '';
# go through commits backwards
# we generate two lists of commits to apply:
my $prline = sub {
return unless $report;
- print $report $prdelim, @_;
+ print $report $prdelim, $report_lprefix, @_;
$prdelim = "\n";
};
my $rewriting = 0;
- 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) = @_;
- runcmd @git, qw(read-tree), $treeish;
- $read_tree_debian->($build);
- };
-
$#upp_cl = $upp_limit if defined $upp_limit;
my $committer_authline = calculate_committer_authline();
printdebug "WALK BUILD ".($cltree//'undef').
" $method (rewriting=$rewriting)\n";
if ($method eq 'Debian') {
- $read_tree_debian->($cltree);
+ read_tree_debian($cltree);
} elsif ($method eq 'Upstream') {
- $read_tree_upstream->($cltree);
+ read_tree_upstream($cltree);
} elsif ($method eq 'StartRewrite') {
$rewriting = 1;
next;
$breakwater = $build;
next;
} elsif ($method eq 'DgitImportDebianUpdate') {
- $read_tree_debian->($cltree);
+ read_tree_debian($cltree);
} elsif ($method eq 'DgitImportUpstreamUpdate') {
confess unless $rewriting;
my $differs = (get_differs $build, $cltree);
next unless $differs & D_UPS;
- $read_tree_upstream->($cltree);
+ read_tree_upstream($cltree);
push @parents, map { $_->{CommitId} } @{ $cl->{OrigParents} };
} else {
confess "$method ?";
my ($secret_head, $secret_bw, $last_anchor) = walk $head;
fresh_workarea();
in_workarea sub {
- runcmd @git, qw(checkout -q -b bw), $secret_bw;
- runcmd @git, qw(checkout -q -b patch-queue/bw), $secret_head;
- my @gbp_cmd = (qw(gbp pq export));
- my $r = system shell_cmd 'exec >../gbp-pq-err 2>&1', @gbp_cmd;
- if ($r) {
- { local ($!,$?); copy('../gbp-pq-err', \*STDERR); }
- failedcmd @gbp_cmd;
- }
- runcmd @git, qw(add -f debian/patches);
+ gbp_pq_export 'bw', $secret_bw, $secret_head;
};
}