chiark / gitweb /
wip changes for remote push - implement i_want
[dgit.git] / dgit
diff --git a/dgit b/dgit
index eb6f01de3deecef20da7707daf375e0f3d1015b8..6c1477cc1a2affccefb882dbda8550577096bae9 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -144,6 +144,8 @@ sub fetchspec () {
 #  > file begin changes
 #  [etc]
 #
+#  > param head HEAD
+#
 #  > want signed-tag
 #  [indicates that signed tag is wanted]
 #  < data-block NBYTES
@@ -152,11 +154,11 @@ sub fetchspec () {
 #  < data-end
 #  < files-end
 #
-#  > want signed-changes-dsc
-#  < data-block NBYTES    [transfer of signed changes]
-#  [etc]
+#  > want signed-dsc-changes
 #  < data-block NBYTES    [transfer of signed dsc]
 #  [etc]
+#  < data-block NBYTES    [transfer of signed changes]
+#  [etc]
 #  < files-end
 #
 #  > complete
@@ -1127,6 +1129,16 @@ END
     return ($tagobjfn);
 }
 
+sub sign_changes ($) {
+    my ($changesfile) = @_;
+    if ($sign) {
+       my @debsign_cmd = @debsign;
+       push @debsign_cmd, "-k$keyid" if defined $keyid;
+       push @debsign_cmd, $changesfile;
+       runcmd_ordryrun @debsign_cmd;
+    }
+}
+
 sub dopush () {
     print DEBUG "actually entering push\n";
     prep_ud();
@@ -1222,19 +1234,15 @@ sub dopush () {
        }
     }
 
-    if ($sign) {
-       if ($we_are_responder) {
-           my $dryrunsuffix = $dryrun ? ".tmp" : "";
-           responder_receive_files('signed-changes-dsc',
-                                   "$changesfile$dryrunsuffix",
-                                   "../$dscfn$dryrunsuffix");
-       } else {
-           my @debsign_cmd = @debsign;
-           push @debsign_cmd, "-k$keyid" if defined $keyid;
-           push @debsign_cmd, $changesfile;
-           runcmd_ordryrun @debsign_cmd;
-       }
+    if ($we_are_responder) {
+       my $dryrunsuffix = $dryrun ? ".tmp" : "";
+       responder_receive_files('signed-dsc-changes',
+                               "../$dscfn$dryrunsuffix",
+                               "$changesfile$dryrupnsuffix");
+    } else {
+       sign_changes $changesfile;
     }
+
     runcmd_ordryrun @git, qw(push),access_giturl(),"refs/tags/$tag";
     my $host = access_cfg('upload-host','RETURN-UNDEF');
     my @hostarg = defined($host) ? ($host,) : ();
@@ -1427,8 +1435,18 @@ sub i_resp_file ($) {
     protocol_receive_file \*RO, $localpath;
 }
 
+our %i_param;
+
+sub i_param ($) {
+    $_[0] =~ m/^(\S+) (.*)$/;
+    $i_param{$1} = $2;
+}
+
+our %i_wanted;
+
 sub i_resp_want ($) {
     my ($keyword) = @_;
+    die "$keyword ?" if $i_wanted{$keyword}++;
     my @localpaths = i_method "i_want_", $keyword;
     foreach my $localpath (@localpaths) {
        protocol_send_file \*RI, $localpath;
@@ -1436,6 +1454,39 @@ sub i_resp_want ($) {
     print RI "end-files\n" or die $!;
 }
 
+our ($i_clogp, $i_version, $i_tag, $i_dscfn);
+
+sub i_localname_parsed_changelog { return "remote-changelog.822"; }
+sub i_localname_changes { return "remote.changes"; }
+sub i_localname_dsc {
+    ($i_clogp, $i_version, $i_tag, $i_dscfn) =
+       push_parse_changelog 'remote-changelog.822';
+    die if $i_dscfn =~ m#/|^\W#;
+    return $dscfn;
+}
+
+sub i_want_signed_tag {
+    defined $i_param{'head'} && defined $dscfn
+       or badproto \*RO, "sequencing error";
+    my $head = $i_param{'head'};
+    die if $head =~ m/[^0-9a-f]/ || $head !~ m/^../;
+
+    push_parse_dsc $i_dscfn, 'remote dsc', 
+
+    push_mktag $head, $i_clogp, $i_tag,
+        $dsc, $i_dscfn,
+        'remote.changes', 'remote changes',
+        'tag.tag';
+
+    return 'tag.tag';
+}
+
+sub i_want_signed_dsc_changes {
+    rename "$i_dscfn.tmp","$i_dscfn" or die "$i_dscfn $!";
+    sign_changes 'remote.changes';
+    return ($i_dscfn, 'remote.changes');
+}
+
 #---------- building etc. ----------
 
 our $version;