chiark / gitweb /
dgit: split brain reorg: Move some split brain code further out.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 6 Jun 2019 12:54:48 +0000 (13:54 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 28 Jun 2019 11:45:38 +0000 (12:45 +0100)
We are going to want this in other quilt modes.  Logically, it should
occur in build_maybe_quilt_fixup.  Specifically, move:
 * the quilt cache check
 * the splitting of the dgit-view branch and setting $split_brain
out of quilt_fixup_multipatch.  quilt_fixup_multipatch now gets
$upstreamversion as a parameter.

Right now this logic in build_maybe_quilt_fixup is a bit flabby and
confusing.  We hope to tidy it up a bit later.

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dgit

diff --git a/dgit b/dgit
index 70f28dc6f9023ed280778e8d0e9de9dc4b1be11c..a9025906fe8c8b65827c8cc942f9f50d978d8b3f 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -5817,11 +5817,34 @@ sub build_maybe_quilt_fixup () {
     my $clogp = parsechangelog();
     my $headref = git_rev_parse('HEAD');
     my $symref = git_get_symref();
+    my $upstreamversion = upstreamversion $version;
 
     prep_ud();
     changedir $playground;
 
-    my $upstreamversion = upstreamversion $version;
+    my $splitbrain_cachekey;
+
+    if ($do_split_brain) {
+       my $cachehit;
+       ($cachehit, $splitbrain_cachekey) =
+           quilt_check_splitbrain_cache($headref, $upstreamversion);
+       if ($cachehit) {
+           changedir $maindir;
+           return;
+       }
+    }
+
+    unpack_playtree_need_cd_work($headref);
+    if ($do_split_brain) {
+       runcmd @git, qw(checkout -q -b dgit-view);
+       # so long as work is not deleted, its current branch will
+       # remain dgit-view, rather than master, so subsequent calls to
+       #  unpack_playtree_need_cd_work
+       # will DTRT, resetting dgit-view.
+       die if $split_brain;
+       $split_brain = 1;
+    }
+    chdir '..';
 
     if ($fopts->{'single-debian-patch'}) {
        fail f_
@@ -5830,7 +5853,8 @@ sub build_maybe_quilt_fixup () {
            if quiltmode_splitbrain();
        quilt_fixup_singlepatch($clogp, $headref, $upstreamversion);
     } else {
-       quilt_fixup_multipatch($clogp, $headref, $upstreamversion);
+       quilt_fixup_multipatch($clogp, $headref, $upstreamversion,
+                             $splitbrain_cachekey);
     }
 
     changedir $maindir;
@@ -6056,7 +6080,7 @@ sub quilt_check_splitbrain_cache ($$) {
 }
 
 sub quilt_fixup_multipatch ($$$) {
-    my ($clogp, $headref, $upstreamversion) = @_;
+    my ($clogp, $headref, $upstreamversion, $splitbrain_cachekey) = @_;
 
     progress f_ "examining quilt state (multiple patches, %s mode)",
                $quilt_mode;
@@ -6130,8 +6154,6 @@ sub quilt_fixup_multipatch ($$$) {
     # afterwards with dpkg-source --before-build.  That lets us save a
     # tree object corresponding to .origs.
 
-    my $splitbrain_cachekey;
-
     if ($quilt_mode eq 'linear'
        && branch_is_gdr($headref)) {
        # This is much faster.  It also makes patches that gdr
@@ -6165,12 +6187,6 @@ sub quilt_fixup_multipatch ($$$) {
        chdir '..';
     }
 
-    if ($do_split_brain) {
-       my $cachehit;
-       ($cachehit, $splitbrain_cachekey) =
-           quilt_check_splitbrain_cache($headref, $upstreamversion);
-       return if $cachehit;
-    }
     my $unapplied=quilt_fakedsc2unapplied($headref, $upstreamversion);
 
     ensuredir '.pc';
@@ -6266,11 +6282,6 @@ END
     push @failsuggestion, [ 'origs', __
  "Maybe orig tarball(s) are not identical to git representation?" ];
 
-    if ($do_split_brain) {
-       runcmd @git, qw(checkout -q -b dgit-view);
-       die if $split_brain;
-       $split_brain = 1;
-    }
     if (quiltmode_splitbrain()) {
        quiltify_splitbrain($clogp, $unapplied, $headref, $oldtiptree,
                             $diffbits, \%editedignores,