our $split_brain = 0;
our $do_split_brain = 0;
+# Interactions between quilt mode and split brain
+# (currently, split brain only implemented iff
+# madformat_wantfixup && quiltmode_splitbrain)
+#
+# source format sane `3.0 (quilt)'
+# madformat_wantfixup()
+#
+# quilt mode normal quiltmode
+# (eg linear) _splitbrain
+#
+# ------------ ------------------------------------------------
+#
+# no split no q cache no q cache forbidden,
+# brain PM on master q fixup on master prevented
+# !$do_split_brain PM on master
+#
+# split brain no q cache q fixup cached, to dgit view
+# PM in dgit view PM in dgit view
+#
+# PM = pseudomerge to make ff, due to overwrite (or split view)
+# "no q cache" = do not record in cache on build, do not check cache
+# `3.0 (quilt)' with --quilt=nocheck is treated as sane format
+
END {
local ($@, $?);
return unless forkcheck_mainprocess();
push_parse_dsc($dscpath, $dscfn, $cversion);
my $format = getfield $dsc, 'Format';
- printdebug "format $format\n";
my $symref = git_get_symref();
my $actualhead = git_rev_parse('HEAD');
if (madformat_wantfixup($format)) {
# user might have not used dgit build, so maybe do this now:
- if (quiltmode_splitbrain()) {
- $do_split_brain = 1;
+ if ($do_split_brain) {
changedir $playground;
- quilt_need_fake_dsc($upstreamversion);
my $cachekey;
($dgithead, $cachekey) =
quilt_check_splitbrain_cache($actualhead, $upstreamversion);
my $r = system @diffcmd;
if ($r) {
if ($r==256) {
+ confess unless !!$split_brain == !!$do_split_brain;
my $referent = $split_brain ? $dgithead : 'HEAD';
my $diffs = cmdoutput @git, qw(diff --stat), $tree, $dgithead;
parseopts();
build_or_push_prep_early();
pushing();
+ build_or_push_prep_modes();
check_not_dirty();
my $specsuite;
if (@ARGV==0) {
local $ENV{GIT_AUTHOR_EMAIL} = $authline[1];
local $ENV{GIT_AUTHOR_DATE} = $authline[2];
- die unless $do_split_brain;
+ confess unless $do_split_brain;
my $fulldiffhint = sub {
my ($x,$y) = @_;
check_for_vendor_patches();
- $do_split_brain = 1 if quiltmode_splitbrain();
-
my $clogp = parsechangelog();
my $headref = git_rev_parse('HEAD');
my $symref = git_get_symref();
-
- if ($quilt_mode eq 'linear'
- && !$fopts->{'single-debian-patch'}
- && branch_is_gdr($headref)) {
- # This is much faster. It also makes patches that gdr
- # likes better for future updates without laundering.
- #
- # However, it can fail in some casses where we would
- # succeed: if there are existing patches, which correspond
- # to a prefix of the branch, but are not in gbp/gdr
- # format, gdr will fail (exiting status 7), but we might
- # be able to figure out where to start linearising. That
- # will be slower so hopefully there's not much to do.
- my @cmd = (@git_debrebase,
- qw(--noop-ok -funclean-mixed -funclean-ordering
- make-patches --quiet-would-amend));
- # We tolerate soe snags that gdr wouldn't, by default.
- if (act_local()) {
- debugcmd "+",@cmd;
- $!=0; $?=-1;
- failedcmd @cmd
- if system @cmd
- and not ($? == 7*256 or
- $? == -1 && $!==ENOENT);
- } else {
- dryrun_report @cmd;
- }
- $headref = git_rev_parse('HEAD');
- }
+ 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_
+ "quilt mode %s does not make sense (or is not supported) with single-debian-patch",
+ $quilt_mode
+ 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;
# must be run in the playground
# quilt_need_fake_dsc must have been called
+ quilt_need_fake_dsc($upstreamversion);
runcmd qw(sh -ec),
'exec dpkg-source --no-check --skip-patches -x fake.dsc >/dev/null';
# Computes the cache key and looks in the cache.
# Returns ($dgit_view_commitid, $cachekey) or (undef, $cachekey)
+ quilt_need_fake_dsc($upstreamversion);
+
my $splitbrain_cachekey;
progress f_
}
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;
# 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
+ # likes better for future updates without laundering.
+ #
+ # However, it can fail in some casses where we would
+ # succeed: if there are existing patches, which correspond
+ # to a prefix of the branch, but are not in gbp/gdr
+ # format, gdr will fail (exiting status 7), but we might
+ # be able to figure out where to start linearising. That
+ # will be slower so hopefully there's not much to do.
- quilt_need_fake_dsc($upstreamversion);
+ unpack_playtree_need_cd_work $headref;
- if (quiltmode_splitbrain()) {
- my $cachehit;
- ($cachehit, $splitbrain_cachekey) =
- quilt_check_splitbrain_cache($headref, $upstreamversion);
- return if $cachehit;
+ my @cmd = (@git_debrebase,
+ qw(--noop-ok -funclean-mixed -funclean-ordering
+ make-patches --quiet-would-amend));
+ # We tolerate soe snags that gdr wouldn't, by default.
+ if (act_local()) {
+ debugcmd "+",@cmd;
+ $!=0; $?=-1;
+ failedcmd @cmd
+ if system @cmd
+ and not ($? == 7*256 or
+ $? == -1 && $!==ENOENT);
+ } else {
+ dryrun_report @cmd;
+ }
+ $headref = git_rev_parse('HEAD');
+
+ chdir '..';
}
+
my $unapplied=quilt_fakedsc2unapplied($headref, $upstreamversion);
ensuredir '.pc';
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,
$dscfn = dscfn($version);
}
+sub build_or_push_prep_modes () {
+ my ($format,) = get_source_format();
+ printdebug "format $format, quilt mode $quilt_mode\n";
+ if (madformat_wantfixup($format) && quiltmode_splitbrain()) {
+ $do_split_brain = 1;
+ }
+ fail __ "dgit: --include-dirty is not supported in split view quilt mode"
+ if $do_split_brain && $includedirty;
+}
+
sub build_prep_early () {
build_or_push_prep_early();
notpushing();
+ build_or_push_prep_modes();
check_not_dirty();
}
# If we are in split brain, there is already a playtree with
# the thing we should package into a .dsc (thanks to quilt
# fixup). If not, make a playtree
+ confess unless !!$split_brain == !!$do_split_brain;
prep_ud() unless $split_brain;
changedir $playground;
unless ($split_brain) {
prep_ud();
changedir $playground;
my $uv = upstreamversion $version;
- quilt_need_fake_dsc($uv);
my $u = quilt_fakedsc2unapplied($headref, $uv);
print $u, "\n" or confess "$!";
}
$$vr = $v;
}
- fail __ "dgit: --include-dirty is not supported in split view quilt mode"
- if $split_brain && $includedirty;
-
if (!defined $cleanmode) {
local $access_forpush;
$cleanmode = access_cfg('clean-mode-newer', 'RETURN-UNDEF');