From: Ian Jackson Date: Thu, 6 Jun 2019 12:54:48 +0000 (+0100) Subject: dgit: split brain reorg: Move some split brain code further out. X-Git-Tag: archive/debian/9.0~126 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0a65d9b91e6bb11ad6d842b3d5961320c154213b;p=dgit.git dgit: split brain reorg: Move some split brain code further out. 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 --- diff --git a/dgit b/dgit index 70f28dc6..a9025906 100755 --- 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,