chiark / gitweb /
dgit: Move tag metadata calculation earlier
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 43d2286b95de11f8ea66dfa100bf4b2c7d65edf4..6bb1f488d6a01c8eee5cf130863dd7a8027f1faa 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -53,7 +53,7 @@ use Debian::Dgit;
 our $our_version = 'UNRELEASED'; ###substituted###
 our $absurdity = undef; ###substituted###
 
-our @rpushprotovsn_support = qw(5 4); # Reverse order!
+our @rpushprotovsn_support = qw(5 4); # Reverse order!
 our $protovsn;
 
 our $cmd;
@@ -104,7 +104,6 @@ our %forceopts = map { $_=>0 }
 
 our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
 
-our $suite_re = '[-+.0-9a-z]+';
 our $cleanmode_re = qr{(?: dpkg-source (?: -d )? (?: ,no-check | ,all-check )?
                      | (?: git | git-ff ) (?: ,always )?
                          | check (?: ,ignores )?
@@ -473,6 +472,7 @@ sub branch_is_gdr ($) {
 #  > param head DGIT-VIEW-HEAD
 #  > param csuite SUITE
 #  > param tagformat new              # $protovsn == 4
+#  > param splitbrain 0|1             # $protovsn >= 6
 #  > param maint-view MAINT-VIEW-HEAD
 #
 #  > param buildinfo-filename P_V_X.buildinfo   # zero or more times
@@ -4363,7 +4363,6 @@ sub push_mktags ($$ $$ $) {
     # We make the git tag by hand because (a) that makes it easier
     # to control the "tagger" (b) we can do remote signing
     my $authline = clogp_authline $clogp;
-    my @dtxinfo = @deliberatelies;
 
     my $mktag = sub {
        my ($tw) = @_;
@@ -4379,20 +4378,28 @@ tag $tag
 tagger $authline
 
 END
+
+       my @dtxinfo = @deliberatelies;
+       unshift @dtxinfo, "--quilt=$quilt_mode" if madformat($format);
+       unshift @dtxinfo, do_split_brain() ? "split" : "no-split"
+           # rpush protocol 5 and earlier don't tell us
+           unless $we_are_initiator && $protovsn < 6;
+       my $dtxinfo = join(" ", "",@dtxinfo);
+       my $tag_metadata = <<END;
+[dgit distro=$declaredistro$dtxinfo]
+END
+       foreach my $ref (sort keys %previously) {
+           $tag_metadata .= <<END or confess "$!";
+[dgit previously:$ref=$previously{$ref}]
+END
+       }
+
        if ($tw->{View} eq 'dgit') {
            print TO f_ <<ENDT, $package, $cversion, $clogsuite, $csuite
 %s release %s for %s (%s) [dgit]
 ENDT
                or confess "$!";
-           my $dtxinfo = join(" ", "",@dtxinfo);
-           print TO <<END or confess "$!";
-[dgit distro=$declaredistro$dtxinfo]
-END
-           foreach my $ref (sort keys %previously) {
-               print TO <<END or confess "$!";
-[dgit previously:$ref=$previously{$ref}]
-END
-           }
+           print TO $tag_metadata;
        } elsif ($tw->{View} eq 'maint') {
            print TO f_ <<END, $package, $cversion, $clogsuite, $csuite,
 %s release %s for %s (%s)
@@ -4681,6 +4688,7 @@ ENDT
     responder_send_command("param csuite $csuite");
     responder_send_command("param isuite $isuite");
     responder_send_command("param tagformat new"); # needed in $protovsn==4
+    responder_send_command("param splitbrain $do_split_brain");
     if (defined $maintviewhead) {
        responder_send_command("param maint-view $maintviewhead");
     }
@@ -5193,6 +5201,13 @@ sub i_resp_want ($) {
        pushing();
        rpush_handle_protovsn_bothends();
        push_parse_dsc $i_dscfn, 'remote dsc', $i_version;
+       if ($protovsn >= 6) {
+           determine_whether_split_brain getfield $dsc, 'Format';
+           $do_split_brain eq ($i_param{'splitbrain'} // '<unsent>')
+               or badproto \*RO,
+ "split brain mismatch, $do_split_brain != $i_param{'split_brain'}";
+           printdebug "rpush split brain $do_split_brain\n";
+       }
     }
 
     my @localpaths = i_method "i_want", $keyword;
@@ -6563,12 +6578,15 @@ sub WANTSRC_BUILDER () { 02; } # caller should run dpkg-buildpackage
 sub build_or_push_prep_early () {
     our $build_or_push_prep_early_done //= 0;
     return if $build_or_push_prep_early_done++;
-    badusage f_ "-p is not allowed with dgit %s", $subcommand
-       if defined $package;
     my $clogp = parsechangelog();
     $isuite = getfield $clogp, 'Distribution';
-    $package = getfield $clogp, 'Source';
+    my $gotpackage = getfield $clogp, 'Source';
     $version = getfield $clogp, 'Version';
+    $package //= $gotpackage;
+    if ($package ne $gotpackage) {
+       fail f_ "-p specified package %s, but changelog says %s",
+           $package, $gotpackage;
+    }
     $dscfn = dscfn($version);
 }