chiark / gitweb /
dgit: push_mktags: Provide $format
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 73b88ad593616e086fda2736b1e9e96bde0a0fcc..6d9a8045412d349dad14a383efeed4012f1a6a9c 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -82,7 +82,7 @@ our $quilt_mode;
 our $quilt_upstream_commitish;
 our $quilt_upstream_commitish_used;
 our $quilt_upstream_commitish_message;
-our $quilt_options_re = 'gbp|dpm|baredebian';
+our $quilt_options_re = 'gbp|dpm|baredebian(?:\+tarball|\+git)?';
 our $quilt_modes_re = "linear|smash|auto|nofix|nocheck|unapplied|$quilt_options_re";
 our $splitview_mode;
 our $splitview_modes_re = qr{auto|always|never};
@@ -300,6 +300,10 @@ sub deliberately_not_fast_forward () {
 sub quiltmode_splitting () {
     $quilt_mode =~ m/gbp|dpm|unapplied|baredebian/;
 }
+sub format_quiltmode_splitting ($) {
+    my ($format) = @_;
+    return madformat_wantfixup($format) && quiltmode_splitting();
+}
 
 sub do_split_brain () { !!($do_split_brain // confess) }
 
@@ -985,7 +989,7 @@ sub determine_whether_split_brain () {
 
     printdebug "format $format, quilt mode $quilt_mode\n";
 
-    if (madformat_wantfixup($format) && quiltmode_splitting()) {
+    if (format_quiltmode_splitting $format) {
        $splitview_mode ne 'never' or
            fail f_ "dgit: quilt mode \`%s' (for format \`%s')".
                    " implies split view, but split-view set to \`%s'",
@@ -2443,9 +2447,10 @@ sub import_tarball_commits ($$) {
     $changes =~ s/^\n//; # Changes: \n
     my $cversion = getfield $clogp, 'Version';
 
+    my $r1authline;
     if (@$tartrees) {
        $r1clogp //= $clogp; # maybe there's only one entry;
-       my $r1authline = clogp_authline $r1clogp;
+        $r1authline = clogp_authline $r1clogp;
        # Strictly, r1authline might now be wrong if it's going to be
        # unused because !$any_orig.  Whatever.
 
@@ -2455,7 +2460,8 @@ sub import_tarball_commits ($$) {
        foreach my $tt (@$tartrees) {
            printdebug "import tartree $tt->{F} $tt->{Tree}\n";
 
-           my $mbody = f_ "Import %s", $tt->{F};
+           # untranslated so that different people's imports are identical
+           my $mbody = sprintf "Import %s", $tt->{F};
            $tt->{Commit} = hash_commit_text($tt->{Orig} ? <<END_O : <<END_T);
 tree $tt->{Tree}
 author $r1authline
@@ -2476,7 +2482,7 @@ END_T
        }
     }
 
-    return ($authline, $clogp, $changes);
+    return ($authline, $r1authline, $clogp, $changes);
 }
 
 sub generate_commits_from_dsc () {
@@ -2569,7 +2575,7 @@ sub generate_commits_from_dsc () {
        $dappliedtree = git_add_write_tree();
     }
 
-    my ($authline, $clogp, $changes) =
+    my ($authline, $r1authline, $clogp, $changes) =
        import_tarball_commits(\@tartrees, $upstreamv);
 
     my $cversion = getfield $clogp, 'Version';
@@ -2693,7 +2699,10 @@ END
        if ($vcmp < 0) {
            @output = ($rawimport_mergeinput, $lastpush_mergeinput,
                { ReverseParents => 1,
-                 Message => (f_ <<END, $package, $cversion, $csuite) });
+                 # untranslated so that different people's pseudomerges
+                 # are not needlessly different (although they will
+                 # still differ if the series of pulls is different)
+                 Message => (sprintf <<END, $package, $cversion, $csuite) });
 Record %s (%s) in archive suite %s
 END
        } elsif ($vcmp > 0) {
@@ -4352,11 +4361,12 @@ sub push_mktags ($$ $$ $) {
 
     my $cversion = getfield $clogp, 'Version';
     my $clogsuite = getfield $clogp, 'Distribution';
+    my $format = getfield $dsc, 'Format';
 
     # 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 $delibs = join(" ", "",@deliberatelies);
+    my @dtxinfo = @deliberatelies;
 
     my $mktag = sub {
        my ($tw) = @_;
@@ -4377,8 +4387,9 @@ END
 %s release %s for %s (%s) [dgit]
 ENDT
                or confess "$!";
+           my $dtxinfo = join(" ", "",@dtxinfo);
            print TO <<END or confess "$!";
-[dgit distro=$declaredistro$delibs]
+[dgit distro=$declaredistro$dtxinfo]
 END
            foreach my $ref (sort keys %previously) {
                print TO <<END or confess "$!";
@@ -6066,6 +6077,30 @@ sub quilt_check_splitbrain_cache ($$) {
     return (undef, $splitbrain_cachekey);
 }
 
+sub baredebian_origtarballs_scan ($$$) {
+    my ($fakedfi, $upstreamversion, $dir) = @_;
+    if (!opendir OD, $dir) {
+       return if $! == ENOENT;
+       fail "opendir $dir (origs): $!";
+    }
+
+    while ($!=0, defined(my $leaf = readdir OD)) {
+       {
+           local ($debuglevel) = $debuglevel-1;
+           printdebug "BDOS $dir $leaf ?\n";
+       }
+       next unless is_orig_file_of_vsn $leaf, $upstreamversion;
+       next if grep { $_->{Filename} eq $leaf } @$fakedfi;
+       push @$fakedfi, {
+            Filename => $leaf,
+            Path => "$dir/$leaf",
+                       };
+    }
+
+    die "$dir; $!" if $!;
+    closedir OD;
+}
+
 sub quilt_fixup_multipatch ($$$) {
     my ($clogp, $headref, $upstreamversion, $splitbrain_cachekey) = @_;
 
@@ -6219,7 +6254,74 @@ END
     my $uheadref = $headref;
     my $uhead_whatshort = 'HEAD';
 
-    if ($quilt_mode =~ m/baredebian/) {
+    if ($quilt_mode =~ m/baredebian\+tarball/) {
+       # We need to make a tarball import.  Yuk.
+       # We want to do this here so that we have a $uheadref value
+
+       my @fakedfi;
+       baredebian_origtarballs_scan \@fakedfi, $upstreamversion, bpd_abs();
+       baredebian_origtarballs_scan \@fakedfi, $upstreamversion,
+           "$maindir/.." unless $buildproductsdir eq '..';
+       changedir '..';
+
+       my @tartrees = import_tarball_tartrees $upstreamversion, \@fakedfi;
+
+       fail __ "baredebian quilt fixup: could not find any origs"
+           unless @tartrees;
+
+       changedir 'work';
+       my ($authline, $r1authline, $clogp,) =
+           import_tarball_commits \@tartrees, $upstreamversion;
+
+       if (@tartrees == 1) {
+           $uheadref = $tartrees[0]{Commit};
+           # TRANSLATORS: this translation must fit in the ASCII art
+           # quilt differences display.  The untranslated display
+           # says %9.9s, so with that display it must be at most 9
+           # characters.
+           $uhead_whatshort = __ 'tarball';
+       } else {
+           # on .dsc import we do not make a separate commit, but
+           # here we need to do so
+           rm_subdir_cached '.';
+           my $parents;
+           foreach my $ti (@tartrees) {
+               my $c = $ti->{Commit};
+               if ($ti->{OrigPart} eq 'orig') {
+                   runcmd qw(git read-tree), $c;
+               } elsif ($ti->{OrigPart} =~ m/orig-/) {
+                   read_tree_subdir $', $c;
+               } else {
+                   confess "$ti->OrigPart} ?"
+               }
+               $parents .= "parent $c\n";
+           }
+           my $tree = git_write_tree();
+           my $mbody = f_ 'Combine orig tarballs for %s %s',
+               $package, $upstreamversion;
+           $uheadref = hash_commit_text <<END;
+tree $tree
+${parents}author $r1authline
+committer $r1authline
+
+$mbody
+
+[dgit import tarballs combine $package $upstreamversion]
+END
+           # TRANSLATORS: this translation must fit in the ASCII art
+           # quilt differences display.  The untranslated display
+           # says %9.9s, so with that display it must be at most 9
+           # characters.  This fragmentt is referring to multiple
+           # orig tarballs in a source package.
+           $uhead_whatshort = __ 'tarballs';
+
+           runcmd @git, qw(reset -q);
+       }
+       $quilt_upstream_commitish = $uheadref;
+       $quilt_upstream_commitish_used = '*orig*';
+       $quilt_upstream_commitish_message = '';
+    }
+    if ($quilt_mode =~ m/baredebian$/) {
        $uheadref = $quilt_upstream_commitish;
        # TRANSLATORS: this translation must fit in the ASCII art
        # quilt differences display.  The untranslated display
@@ -6254,9 +6356,10 @@ END
     # TRANSLATORS: Try to keep this ascii-art layout right.  The 0s in
     # %9.00009s will be ignored and are there to make the format the
     # same length (9 characters) as the output it generates.  If you
-    # change the value 9, your translation of "upstream" must fit into
-    # the new length, and you should change the number of 0s.  Do
-    # not reduce it below 4 as HEAD has to fit too.
+    # change the value 9, your translations of "upstream" and
+    # 'tarball' must fit into the new length, and you should change
+    # the number of 0s.  Do not reduce it below 4 as HEAD has to fit
+    # too.
     progress f_
 "%s: quilt differences: src:  %s orig %s     gitignores:  %s orig %s\n".
 "%s: quilt differences: %9.00009s %s o+d/p          %9.00009s %s o+d/p",
@@ -7619,6 +7722,7 @@ sub parseopts_late_defaults () {
            or badcfg f_ "unknown quilt-mode \`%s'", $quilt_mode;
        $quilt_mode = $1;
     }
+    $quilt_mode =~ s/^(baredebian)\+git$/$1/;
 
     foreach my $moc (@modeopt_cfgs) {
        local $access_forpush;