diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-06-04 15:25:23 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-07-16 16:47:47 +0100 |
commit | e5b0f5ddd4130e408391839bc9512eac55e38808 (patch) | |
tree | 9d37d1eee88d5f37008d633410862456725bb1d5 | |
parent | 71350fe30f7449b24dc2884b42cc5ff50a2bf84e (diff) |
Split brain: Start introducing gbp (split brain) quilt mode
* Replace quilt_could_gbp with new calculation based on three calls to
quiltify_trees_differ.
* Reworked messages about quilt differences.
* Start to provide the `gbp', `apply' and `dpm' quilt modes.
Currently we crash with a die if any of these are used.
Nevertheless, we allow `gbp' and `apply' to be specified.
-rwxr-xr-x | dgit | 60 |
1 files changed, 46 insertions, 14 deletions
@@ -61,7 +61,7 @@ our $cleanmode; our $changes_since_version; our $rmchanges; our $quilt_mode; -our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck'; +our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|apply'; our $we_are_responder; our $initiator_tempdir; @@ -2538,15 +2538,16 @@ sub quiltify_tree_sentinelfiles ($) { return $r; } -sub quilt_could_gbp ($$$) { - my ($userhead,$unapplied,$applied) = @_; - return - !(quiltify_trees_differ($userhead,$unapplied,1) & 01) && - (quiltify_trees_differ($userhead,$applied,1) & 01); +sub quiltify_splitbrain () { + # memoisation via git-reflog + my $may_apply = $quilt_mode =~ m/gbp|apply/; + die "xxx not yet implemented"; +# if ($may_apply && +# quiltify_trees_differ($userhead,)) {} } sub quiltify ($$$$) { - my ($clogp,$target,$unapplied,$oldtiptree) = @_; + my ($clogp,$target,$oldtiptree,$failsuggestion) = @_; # Quilt patchification algorithm # @@ -2684,12 +2685,7 @@ sub quiltify ($$$$) { foreach my $notp (@nots) { print STDERR "$us: ", $reportnot->($notp), "\n"; } - if (quilt_could_gbp($target,$unapplied,$oldtiptree)) { - print STDERR <<END; -$us: Tree looks like a patches-unapplied git branch. -$us: Maybe you forgot --quilt=gbp (or --quilt=apply) ? -END - } + print STDERR "$us: $_\n" foreach @$failsuggestion; fail "quilt fixup naive history linearisation failed.\n". "Use dpkg-source --commit by hand; or, --quilt=smash for one ugly patch"; } elsif ($quilt_mode eq 'smash') { @@ -3000,7 +2996,43 @@ END my $oldtiptree=git_write_tree(); changedir '../work'; - quiltify($clogp,$headref,$unapplied,$oldtiptree); + + # We calculate some guesswork now about what kind of tree this might + # be. This is mostly for error reporting. + + my $user2unapplied = quiltify_trees_differ($headref, $unapplied, 1); + my $user2applied = quiltify_trees_differ($headref, $oldtiptree,1); + my $applied2unapplied = quiltify_trees_differ($oldtiptree,$unapplied, 1); + + my @dl; + foreach my $b (qw(01 02)) { + foreach my $v ($user2unapplied, $applied2unapplied, $user2applied) { + push @dl, ($v & $b) ? '##' : '=='; + } + } + printdebug "differences \@dl @dl.\n"; + + progress sprintf +"$us: quilt differences: src: %s orig %s gitignores: %s orig %s\n". +"$us: quilt differences: HEAD %s o+d/p HEAD %s o+d/p", + $dl[0], $dl[1], $dl[3], $dl[4], + $dl[2], $dl[5]; + + my @failsuggestion; + if (!($user2unapplied & $applied2unapplied)) { + push @failsuggestion, "This might be a patches-unapplied branch."; + } elsif (!($user2applied & $applied2unapplied)) { + push @failsuggestion, "This might be a patches-applied branch."; + } + push @failsuggestion, + "Maybe you need to specify one of --quilt=apply --quilt=gbp --quilt=dpm ?"; + + if ($quilt_mode =~ m/gbp|dpm|apply/) { + quiltify_splitbrain(); + return; + } + + quiltify($clogp,$headref,$oldtiptree,\@failsuggestion); if (!open P, '>>', ".pc/applied-patches") { $!==&ENOENT or die $!; |