chiark / gitweb /
git-debrebase convert-from-gbp: Make it ff of dgit view, if we can.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Jul 2018 17:37:34 +0000 (18:37 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Jul 2018 23:24:48 +0000 (00:24 +0100)
Look for dgit-generated tags so we can usually make the new branch ff
of the dgit view.

Specifically, we fish the most recent released version out of
debian/changelog and look for a DISTRO/VSN tag and a corresponding
archive/DISTRO/VSN tag.  If this all looks good, we declare ff of
archive/.

This should avoid the need for dgit push --overwrite in most cases.

We do not check the DISTRO name.  In principle dgit could find the
distro name from the suite name, but that makes the software layering
quite complicated.  (For example, we would have to provide a way to
tell gdr what program to run for dgit, for the benefit of the test
suite.)  I think the current approach is good enough; there are not
likely to be any tag pairs that look like the right kind of thing but
are in fact something else entirely, so we're not likely to
accidentally trash some wanted changes.

Closes:#903132.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
git-debrebase
git-debrebase.1.pod

index 96e495e2641c09bf3c63a98459c9441400ae8e7b..82f6acc69c850a771fcada51fcab06ccd6508eb3 100644 (file)
@@ -1,6 +1,7 @@
 dgit (5.9~) unstable; urgency=medium
 
-  * 
+  * git-debrebase convert-from-gbp: Look for dgit-generated tags so we can
+    usually make the new branch ff of the dgit view.  Closes:#903132.
 
  --
 
index fb6b79d92a905239f88b8bdeb0dd9c8c1a7f9424..7b2e4f311dfbdf64813d14cb2bac92184837a6ff 100755 (executable)
@@ -1623,6 +1623,41 @@ sub cmd_convert_from_gbp () {
            "upstream ($upstream) contains debian/ directory";
     }
 
+    my $previous_dgit_view = eval {
+       my @clogcmd = qw(dpkg-parsechangelog --format rfc822 -n2);
+       my ($lvsn, $suite);
+       parsechangelog_loop \@clogcmd, 'debian/changelog', sub {
+           my ($stz, $desc) = @_;
+           no warnings qw(exiting);
+           printdebug 'CHANGELOG ', Dumper($desc, $stz);
+           next unless $stz->{Date};
+           next unless $stz->{Distribution} ne 'UNRELEASED';
+           $lvsn = $stz->{Version};
+           $suite = $stz->{Distribution};
+           last;
+       };
+       die "neither of the first two changelog entries are released\n"
+           unless defined $lvsn;
+       print "last finished-looking changelog entry: ($lvsn) $suite\n";
+       my $mtag_pat = debiantag_maintview $lvsn, '*';
+       my $mtag = cmdoutput @git, qw(describe --always --abbrev=0 --match),
+           $mtag_pat;
+       die "could not find suitable maintainer view tag $mtag_pat\n"
+           unless $mtag_pat =~ m{/};
+       is_fast_fwd $mtag, 'HEAD' or
+           die "HEAD is not FF from maintainer tag $mtag!";
+       my $dtag = "archive/$mtag";
+       is_fast_fwd $mtag, $dtag or
+           die "dgit view tag $dtag is not FF from maintainer tag $mtag";
+       print "will stitch in dgit view, $dtag\n";
+       git_rev_parse $dtag;
+    };
+    if (!$previous_dgit_view) {
+       $@ =~ s/^\n+//;
+       chomp $@;
+       print STDERR "cannot stitch in dgit view: $@\n";
+    }
+
     snags_maybe_bail();
 
     my $work;
@@ -1652,6 +1687,13 @@ sub cmd_convert_from_gbp () {
        runcmd @git, qw(reset --quiet --hard patch-queue/gdr-internal);
        runcmd @git, qw(rebase --quiet --onto), $work, qw(gdr-internal);
        $work = git_rev_parse 'HEAD';
+
+       if ($previous_dgit_view) {
+           $work = make_commit [$work, $previous_dgit_view], [
+ 'git-debrebase import: declare ff from dgit archive view',
+ '[git-debrebase pseudomerge: import-from-gbp]',
+            ];
+       }
     };
 
     update_head_checkout $old_head, $work, 'convert-from-gbp';
index 4d1a67360d6a4ba9a4700cd08caac5cb840a57dd..d67e5570452d699851564860cc1a2e980d6ef718 100644 (file)
@@ -257,6 +257,11 @@ This check exists to detect certain likely user errors,
 but if this situation is true and expected,
 forcing it is fine.
 
+git-debrebase will try to look for the dgit archive view
+of the most recent release,
+and if it finds it will make a pseduomerge so that
+your new git-debrebase view is appropriately fast forward.
+
 The result is a well-formed git-debrebase interchange branch.
 The result is also fast-forward from the gbp branch.