From 9cda023c0c49449a1d5862483df8d785e062765b Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 8 Jul 2018 18:37:34 +0100 Subject: [PATCH] git-debrebase convert-from-gbp: Make it ff of dgit view, if we can. 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 --- debian/changelog | 3 ++- git-debrebase | 42 ++++++++++++++++++++++++++++++++++++++++++ git-debrebase.1.pod | 5 +++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 96e495e2..82f6acc6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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. -- diff --git a/git-debrebase b/git-debrebase index fb6b79d9..7b2e4f31 100755 --- a/git-debrebase +++ b/git-debrebase @@ -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'; diff --git a/git-debrebase.1.pod b/git-debrebase.1.pod index 4d1a6736..d67e5570 100644 --- a/git-debrebase.1.pod +++ b/git-debrebase.1.pod @@ -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. -- 2.30.2