#
# git-debrebase [<options> --] [<git-rebase options...>]
# git-debrebase [<options>] analyse
+# git-debrebase [<options>] breakwater # prints breakwater tip only
# git-debrebase [<options>] launder # prints breakwater tip etc.
# git-debrebase [<options>] stitch [--prose=<for commit message>]
# git-debrebase [<options>] downstream-rebase-launder-v0 # experimental
#
-# git-debrebase [<options>] convert-from-gbp <upstream-git-rev>
+# git-debrebase [<options>] convert-from-gbp [<upstream-git-rev>]
+# git-debrebase [<options>] convert-to-gbp
# problems / outstanding questions:
#
return $unknown->("complex merge");
}
+sub breakwater_of ($) {
+ my ($head) = @_; # must be laundered
+ my $breakwater;
+ my $unclean = sub {
+ my ($why) = @_;
+ fail "branch needs laundering (run git-debrebase): $why";
+ };
+ for (;;) {
+ my $cl = classify $head;
+ my $ty = $cl->{Type};
+ if ($ty eq 'Packaging' or
+ $ty eq 'Changelog') {
+ $breakwater //= $head;
+ } elsif ($ty eq 'BreakwaterUpstreamMerge' or
+ $ty eq 'BreakwaterStart') {
+ $breakwater //= $head;
+ last;
+ } elsif ($ty eq 'Upstream') {
+ $unclean->("packaging change ($breakwater)".
+ " follows upstream change (eg $head)")
+ if defined $breakwater;
+ } elsif ($ty eq 'Mixed') {
+ $unclean->('found mixed upstream/packaging commit ($head)');
+ } elsif ($ty eq 'Pseudomerge' or
+ $ty eq 'AddPatches') {
+ $unclean->("found interchange conversion commit ($ty, $head)");
+ } elsif ($ty eq 'DgitImportUnpatched') {
+ $unclean->("found dgit dsc import ($head)");
+ } else {
+ fail "found unprocessable commit, cannot cope: $head; $cl->{Why}";
+ }
+ $head = $cl->{Parents}[0]{CommitId};
+ }
+ return $breakwater;
+}
+
sub walk ($;$$);
sub walk ($;$$) {
my ($input,
}
}
+sub cmd_breakwater () {
+ badusage "no arguments allowed" if @ARGV;
+ my $bw = breakwater_of git_rev_parse 'HEAD';
+ print "$bw\n" or die $!;
+}
+
sub cmd_stitch () {
my $prose = '';
GetOptions('prose=s', \$prose) or die badusage("bad options to stitch");
update_head_checkout $old_head, $work, 'convert-from-gbp';
}
+sub cmd_convert_to_gbp () {
+ badusage "no arguments allowed" if @ARGV;
+ my $head = get_head();
+ my $ffq = (ffq_prev_branchinfo())[3];
+ my $bw = breakwater_of $head;
+ fresh_workarea();
+ my $out;
+ in_workarea sub {
+ runcmd @git, qw(checkout -q -b bw), $bw;
+ runcmd @git, qw(checkout -q -b patch-queue/bw), $head;
+ runcmd qw(gbp pq export);
+ runcmd @git, qw(add debian/patches);
+ $out = make_commit ['HEAD'], [
+ 'Commit patch queue (converted from git-debrebase format)',
+ '[git-debrebase convert-to-gbp: commit patches]',
+ ];
+ };
+ if (defined $ffq) {
+ runcmd @git, qw(update-ref -m),
+ "debrebase: converting corresponding main branch to gbp format",
+ $ffq, $git_null_obj;
+ }
+ update_head_checkout $head, $out, "convert to gbp (v0)";
+ print <<END or die $!;
+git-debrebase: converted to git-buildpackage branch format
+git-debrebase: WARNING: do not now run "git-debrebase" any more
+git-debrebase: WARNING: doing so would drop all upstream patches!
+END
+}
+
sub cmd_downstream_rebase_launder_v0 () {
badusage "needs 1 argument, the baseline" unless @ARGV==1;
my ($base) = @ARGV;