chiark / gitweb /
Split brain: Start work on determining split brain necessity
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 19 Nov 2015 00:32:00 +0000 (00:32 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jul 2016 15:47:47 +0000 (16:47 +0100)
`Split brain' means the situation where `dgit push' makes private
commits, to push to the dgit repos server, which are not left on the
user's actual branch.

Check whether the quilt mode and tree differences, taken together,
mean that we need split brain.

If we do need split brain, use gbp pq to apply the patch series.

.gitignore changes are mishandled, still.  And we don't actually
follow through much yet.

Also, fix a case where quilt mode `apply' hadn't been changed to
`unapplied'.

TODO.BRANCH [new file with mode: 0644]
dgit

diff --git a/TODO.BRANCH b/TODO.BRANCH
new file mode 100644 (file)
index 0000000..c152522
--- /dev/null
@@ -0,0 +1,2 @@
+Provide --gpbpq[=:] options
+Document --quilt=unapplied|gbp|dpm
diff --git a/dgit b/dgit
index 08d07bec9190b600fac461f8ccb3bde037a593f2..7b9aa52d2e39453924f6d2df84a90554e912e7f2 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -83,6 +83,7 @@ our (@dpkgbuildpackage) = qw(dpkg-buildpackage -i\.git/ -I.git);
 our (@dpkgsource) = qw(dpkg-source -i\.git/ -I.git);
 our (@dpkggenchanges) = qw(dpkg-genchanges);
 our (@mergechanges) = qw(mergechanges -f);
+our (@gbppq) = qw(gbp-pq);
 our (@changesopts) = ('');
 
 our %opts_opt_map = ('dget' => \@dget, # accept for compatibility
@@ -114,6 +115,7 @@ autoflush STDOUT 1;
 
 our $supplementary_message = '';
 our $need_split_build_invocation = 0;
+our $split_brain = 0;
 
 END {
     local ($@, $?);
@@ -2537,15 +2539,33 @@ sub quiltify_tree_sentinelfiles ($) {
         qw(-- debian/rules debian/control);
     $r =~ s/\n/,/g;
     return $r;
+                                }
+
+sub quiltify_splitbrain_needed () {
+    if (!$split_brain) {
+       progress "creating dgit view";
+       runcmd @git, qw(checkout -q -b dgit-view);
+       $split_brain = 1;
+    }
 }
 
 sub quiltify_splitbrain ($) {
     my ($diffbits) = @_;
-    # memoisation via git-reflog
-    my $may_apply = $quilt_mode =~ m/gbp|unapplied/;
-    die "xxx not yet implemented";
-#    if ($may_apply &&
-#      quiltify_trees_differ($userhead,)) {}
+    if ($quilt_mode !~ m/gbp|dpm/) {
+       # treat .gitignore just like any other upstream file
+       $diffbits = { %$diffbits };
+       $_ = !!$_ foreach values %$diffbits;
+    }
+    if ($quilt_mode =~ m/gbp|unapplied/ &&
+       ($diffbits->{O2A} & 01) && # some patches
+       !($diffbits->{H2O} & 01)) { # but HEAD is like orig
+       quiltify_splitbrain_needed();
+       runcmd @gbppq, qw(import);
+       die "SPLIT BRAIN";
+    }
+    die 'xxx gitignore';
+    die 'xxx memoisation via git-reflog';
+    die 'xxx fast forward';
 }
 
 sub quiltify ($$$$) {
@@ -3034,7 +3054,7 @@ END
     push @failsuggestion, "Maybe you need to specify one of".
         " --quilt=gbp --quilt=dpm --quilt=unapplied ?";
 
-    if ($quilt_mode =~ m/gbp|dpm|apply/) {
+    if ($quilt_mode =~ m/gbp|dpm|unapplied/) {
        quiltify_splitbrain($diffbits);
        return;
     }