chiark / gitweb /
Split brain: Start introducing gbp (split brain) quilt mode
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Jun 2016 14:25:23 +0000 (15:25 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jul 2016 15:47:47 +0000 (16:47 +0100)
* 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.

dgit

diff --git a/dgit b/dgit
index 0c8183dc2d614abe2cd27f91188d205752ad1bcd..99cb7fe29196830abc0f483bb703f169adf806d6 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -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 $!;