summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2016-07-24 18:56:14 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2016-07-31 22:55:01 +0100
commitc0c60b37bea5eb9fda9ee390d49bf5a42137c3ef (patch)
treee5937ef8a25b62d2b2fa6d7da7a6b35212ebffc2 /dgit
parenteb43be543543dda00d48455b40f347765ab9fbfe (diff)
Tag change: Calculate desired tag format
Introduce machinery for deciding what format tag to make, during push. The computation is slightly ad-hoc. Currently it always returns `old' and does as before, so no overall functional change with existing configs and existing command lines. Reserve protocol version 4 for new tag support. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit54
1 files changed, 51 insertions, 3 deletions
diff --git a/dgit b/dgit
index ba3a2e4..352e5b1 100755
--- a/dgit
+++ b/dgit
@@ -39,7 +39,7 @@ use Debian::Dgit;
our $our_version = 'UNRELEASED'; ###substituted###
-our @rpushprotovsn_support = qw(3 2);
+our @rpushprotovsn_support = qw(3 2); # 4 is new tag format
our $protovsn;
our $isuite = 'unstable';
@@ -65,6 +65,8 @@ our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|unapplied';
our $we_are_responder;
our $initiator_tempdir;
our $patches_applied_dirtily = 00;
+our $tagformat;
+our $tagformatfn;
our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
@@ -134,7 +136,7 @@ our $instead_distro;
sub debiantag ($$) {
my ($v,$distro) = @_;
- return debiantag_old $v, $distro;
+ return $tagformatfn->($v, $distro);
}
sub lbranch () { return "$branchprefix/$csuite"; }
@@ -501,10 +503,12 @@ our %defcfg = ('dgit.default.distro' => 'debian',
'dgit.default.ssh' => 'ssh',
'dgit.default.archive-query' => 'madison:',
'dgit.default.sshpsql-dbname' => 'service=projectb',
+ 'dgit.default.dgit-tag-format' => 'old,new',
'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/push.git-url' => '',
'dgit-distro.debian/push.git-host' => 'push.dgit.debian.org',
'dgit-distro.debian/push.git-user-force' => 'dgit',
@@ -1235,6 +1239,32 @@ sub create_remote_git_repo () {
}
}
+sub select_tagformat () {
+ # sets $tagformatfn
+ return if $tagformatfn && !$tagformat;
+ die 'bug' if $tagformatfn && $tagformat;
+ # ... $tagformat assigned after previous select_tagformat
+
+ my (@supported) = split /\,/, access_cfg('dgit-tag-format');
+ printdebug "select_tagformat supported @supported\n";
+
+ $tagformat //= [ $supported[0], "distro access configuration", 0 ];
+ printdebug "select_tagformat specified @$tagformat\n";
+
+ my ($fmt,$why,$override) = @$tagformat;
+
+ fail "target distro supports tag formats @supported".
+ " but have to use $fmt ($why)"
+ unless $override
+ or grep { $_ eq $fmt } @supported;
+
+ $tagformat = undef;
+ $tagformatfn = ${*::}{"debiantag_$fmt"};
+
+ fail "trying to use unknown tag format \`$fmt' ($why) !"
+ unless $tagformatfn;
+}
+
our ($dsc_hash,$lastpush_hash);
our $ud = '.git/dgit/unpack';
@@ -1993,6 +2023,7 @@ END
prep_ud();
access_giturl(); # check that success is vaguely likely
+ select_tagformat();
my $clogpfn = ".git/dgit/changelog.822.tmp";
runcmd shell_cmd "exec >$clogpfn", qw(dpkg-parsechangelog);
@@ -2338,7 +2369,7 @@ sub cmd_remote_push_build_host {
unless defined $protovsn;
responder_send_command("dgit-remote-push-ready $protovsn");
-
+ rpush_handle_protovsn_bothends();
changedir $dir;
&cmd_push;
}
@@ -2347,6 +2378,17 @@ sub cmd_remote_push_responder { cmd_remote_push_build_host(); }
# ... for compatibility with proto vsn.1 dgit (just so that user gets
# a good error message)
+sub rpush_handle_protovsn_bothends () {
+ if ($protovsn < 4) {
+ fail "rpush negotiated protocol version $protovsn".
+ " which supports old tag format only".
+ " but trying to use new format (".$tagformat->[1].")"
+ if $tagformat && $tagformat->[0] ne 'old';
+ $tagformat = ['old', "rpush negotiated protocol $protovsn", 0];
+ }
+ select_tagformat();
+}
+
our $i_tmp;
sub i_cleanup {
@@ -2405,6 +2447,7 @@ sub cmd_rpush {
($protovsn) = initiator_expect { m/^dgit-remote-push-ready (\S+)/ };
die "$protovsn ?" unless grep { $_ eq $protovsn } @rpushprotovsn_support;
$supplementary_message = '' unless $protovsn >= 3;
+ rpush_handle_protovsn_bothends();
for (;;) {
my ($icmd,$iargs) = initiator_expect {
m/^(\S+)(?: (.*))?$/;
@@ -3797,6 +3840,11 @@ sub parseopts () {
} elsif (m/^--deliberately-($deliberately_re)$/s) {
push @ropts, $_;
push @deliberatelies, $&;
+ } elsif (m/^--dgit-tag-format=(old|new)$/s) {
+ # undocumented, for testing
+ push @ropts, $_;
+ $tagformat = [ $1, 'command line', 1 ];
+ # 1 menas overrides distro configuration
} elsif (m/^--always-split-source-build$/s) {
# undocumented, for testing
push @ropts, $_;