X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=0dea96c8f1a678ad9c6d223197caa66e57cb2c0c;hb=a840640baebaa11079b64be2ae5f89a111648985;hp=cb6a17787a3152ec3326ab32c81bffb667949de0;hpb=79ba42b874cdff4f0cb2bf188a4c1940fbad3a62;p=dgit.git diff --git a/dgit b/dgit index cb6a1778..0dea96c8 100755 --- a/dgit +++ b/dgit @@ -534,11 +534,16 @@ our %defcfg = ('dgit.default.distro' => 'debian', 'dgit.default.archive-query' => 'madison:', 'dgit.default.sshpsql-dbname' => 'service=projectb', 'dgit.default.dgit-tag-format' => 'old,new,maint', + # old means "repo server accepts pushes with old dgit tags" + # new means "repo server accepts pushes with new dgit tags" + # maint means "repo server accepts split brain pushes" + # hist means "repo server may have old pushes without new tag" + # ("hist" is implied by "old") 'dgit-distro.debian.archive-query' => 'ftpmasterapi:', 'dgit-distro.debian.git-check' => 'url', 'dgit-distro.debian.git-check-suffix' => '/info/refs', 'dgit-distro.debian.new-private-pushers' => 't', - 'dgit-distro.debian.dgit-tag-format' => 'old', + 'dgit-distro.debian.dgit-tag-format' => 'new', 'dgit-distro.debian/push.git-url' => '', 'dgit-distro.debian/push.git-host' => 'push.dgit.debian.org', 'dgit-distro.debian/push.git-user-force' => 'dgit', @@ -1194,7 +1199,7 @@ sub select_tagformat () { die 'bug' if $tagformatfn && $tagformat_want; # ... $tagformat_want assigned after previous select_tagformat - my (@supported) = grep { $_ ne 'maint' } access_cfg_tagformats(); + my (@supported) = grep { $_ =~ m/^(?:old|new)$/ } access_cfg_tagformats(); printdebug "select_tagformat supported @supported\n"; $tagformat_want //= [ $supported[0], "distro access configuration", 0 ]; @@ -2367,15 +2372,22 @@ END }; sub infopair_lrf_tag_lookup ($$) { - my ($tagname, $what) = @_; - printdebug "infopair_lrfetchref_tag_lookup $what\n"; - my $lrefname = lrfetchrefs."/tags/$tagname"; - my $tagobj = $lrfetchrefs_f{$lrefname}; - defined $tagobj or fail <[1] ($anc->[0]) .. $desc->[1] ($desc->[0]) is not fast forward END }; +sub pseudomerge_version_check ($$) { + my ($clogp, $archive_hash) = @_; + + my $arch_clogp = commit_getclogp $archive_hash; + my $i_arch_v = [ (getfield $arch_clogp, 'Version'), + 'version currently in archive' ]; + if (defined $overwrite_version) { + infopair_cond_equal([ $overwrite_version, '--overwrite= version' ], + $i_arch_v); + } + + printdebug "pseudomerge_version_check i_arch_v @$i_arch_v\n"; + return $i_arch_v; +} + +sub pseudomerge_make_commit ($$$$ $$) { + my ($clogp, $dgitview, $archive_hash, $i_arch_v, + $msg_cmd, $msg_msg) = @_; + progress "Declaring that HEAD inciudes all changes in $i_arch_v->[0]..."; + + my $tree = cmdoutput qw(git rev-parse), "${dgitview}:"; + my $authline = clogp_authline $clogp; + + chomp $msg_msg; + $msg_cmd .= + !defined $overwrite_version ? "" + : " --overwrite=".$overwrite_version; + + mkpath '.git/dgit'; + my $pmf = ".git/dgit/pseudomerge"; + open MC, ">", $pmf or die "$pmf $!"; + print MC < $merged_dgitview @@ -2401,20 +2460,13 @@ sub splitbrain_pseudomerge ($$$$) { # this: $dgitview' # - my $arch_clogp = commit_getclogp $archive_hash; - my $i_arch_v = [ (getfield $arch_clogp, 'Version'), - 'version currently in archive' ]; - - printdebug "splitbrain_pseudomerge i_arch_v @$i_arch_v\n"; + printdebug "splitbrain_pseudomerge...\n"; + + my $i_arch_v = pseudomerge_version_check($clogp, $archive_hash); return $dgitview unless defined $archive_hash; - if (defined $overwrite_version) { - progress "Declaring that HEAD inciudes all changes in archive..."; - progress "Checking that $overwrite_version does so..."; - infopair_cond_equal([ $overwrite_version, '--overwrite= version' ], - $i_arch_v); - } else { + if (!defined $overwrite_version) { progress "Checking that HEAD inciudes all changes in archive..."; } @@ -2432,38 +2484,49 @@ sub splitbrain_pseudomerge ($$$$) { infopair_cond_ff($i_dep14, $i_dgit); $overwrite_version // infopair_cond_ff($i_dep14, [ $maintview, 'HEAD' ]); - my $tree = cmdoutput qw(git rev-parse), "${dgitview}:"; - my $authline = clogp_authline $clogp; + my $r = pseudomerge_make_commit + $clogp, $dgitview, $archive_hash, $i_arch_v, + "dgit --quilt=$quilt_mode", + (defined $overwrite_version ? <[0] +END_MAKEFF - mkpath '.git/dgit'; - my $pmf = ".git/dgit/pseudomerge"; - open MC, ">", $pmf or die "$pmf $!"; - print MC <[0] into dgit view."; + return $r; +} -END - if (defined $overwrite_version) { - print MC <[0] + printdebug "plain_overwrite_pseudomerge..."; -[dgit --quilt=$quilt_mode] -END - } - close MC or die $!; + my $i_arch_v = pseudomerge_version_check($clogp, $archive_hash); - progress "Making pseudo-merge of $i_arch_v->[0] into dgit view."; - return make_commit($pmf); -} + my @tagformats = access_cfg_tagformats(); + my @t_overwr = + map { $_->($overwrite_version, access_basedistro) } + (grep { m/^(?:old|hist)$/ } @tagformats) + ? \&debiantags : \&debiantag_new; + my $i_overwr = infopair_lrf_tag_lookup \@t_overwr, "previous version tag"; + my $i_archive = [ $archive_hash, "current archive contents" ]; + + infopair_cond_equal($i_overwr, $i_archive); + + return $head if is_fast_fwd $archive_hash, $head; + + my $m = "Declare fast forward from $overwrite_version"; + + my $r = pseudomerge_make_commit + $clogp, $head, $archive_hash, $i_arch_v, + "dgit", $m; + + runcmd @git, qw(update-ref -m), $m, 'HEAD', $r, $head; + + progress "Make pseudo-merge of $i_arch_v->[0] into your HEAD."; + return $r; +} sub push_parse_changelog ($) { my ($clogpfn) = @_; @@ -2692,6 +2755,12 @@ END } } + if (defined $overwrite_version && !defined $maintviewhead) { + $dgithead = plain_overwrite_pseudomerge($clogp, + $dgithead, + $archive_hash); + } + check_not_dirty(); my $forceflag = ''; @@ -2703,10 +2772,10 @@ END } else { fail "dgit push: HEAD is not a descendant". " of the archive's version.\n". - "dgit: To overwrite its contents,". - " use git merge -s ours ".lrref().".\n". - "dgit: To rewind history, if permitted by the archive,". - " use --deliberately-not-fast-forward"; + "To overwrite the archive's contents,". + " pass --overwrite[=VERSION].\n". + "To rewind history, if permitted by the archive,". + " use --deliberately-not-fast-forward."; } } @@ -4495,6 +4564,9 @@ sub parseopts () { } elsif (m/^--no-rm-on-error$/s) { push @ropts, $_; $rmonerror = 0; + } elsif (m/^--overwrite=(.*)$/s) { + push @ropts, $_; + $overwrite_version = $1; } elsif (m/^--(no-)?rm-old-changes$/s) { push @ropts, $_; $rmchanges = !$1;