chiark / gitweb /
Minor fix to remote functionality:
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 7052bf11d3fa402d9a9288c4ae69f5d874ad03ff..37a61111db92ea2bf3257cb6259b25e667f76348 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -248,14 +248,14 @@ sub responder_send_command ($) {
     my ($command) = @_;
     return unless $we_are_responder;
     # called even without $we_are_responder
-    printdebug "<< $command\n";
+    printdebug ">> $command\n";
     print PO $command, "\n" or die $!;
 }    
 
 sub responder_send_file ($$) {
     my ($keyword, $ourfn) = @_;
     return unless $we_are_responder;
-    printdebug "[[ $keyword $ourfn\n";
+    printdebug "]] $keyword $ourfn\n";
     responder_send_command "file $keyword";
     protocol_send_file \*PO, $ourfn;
 }
@@ -263,11 +263,12 @@ sub responder_send_file ($$) {
 sub responder_receive_files ($@) {
     my ($keyword, @ourfns) = @_;
     die unless $we_are_responder;
-    printdebug "]] $keyword @ourfns\n";
+    printdebug "[[ $keyword @ourfns\n";
     responder_send_command "want $keyword";
     foreach my $fn (@ourfns) {
        protocol_receive_file \*PI, $fn;
     }
+    printdebug "[[\$\n";
     protocol_expect { m/^files-end$/ } \*PI;
 }
 
@@ -1503,16 +1504,6 @@ sub cmd_rpush {
        };
        i_method "i_resp", $icmd, $iargs;
     }
-
-    my $pid = $i_child_pid;
-    $i_child_pid = undef; # prevents killing some other process with same pid
-    printdebug "waiting for remote child $pid...";
-    my $got = waitpid $pid, 0;
-    die $! unless $got == $pid;
-    die "remote child failed $?" if $?;
-
-    i_cleanup();
-    exit 0;
 }
 
 sub i_resp_progress ($) {
@@ -1522,7 +1513,15 @@ sub i_resp_progress ($) {
 }
 
 sub i_resp_complete {
+    my $pid = $i_child_pid;
+    $i_child_pid = undef; # prevents killing some other process with same pid
+    printdebug "waiting for remote child $pid...\n";
+    my $got = waitpid $pid, 0;
+    die $! unless $got == $pid;
+    die "remote child failed $?" if $?;
+
     i_cleanup();
+    printdebug "all done\n";
     exit 0;
 }
 
@@ -1532,6 +1531,7 @@ sub i_resp_file ($) {
     my $localpath = "$i_tmp/$localname";
     stat $localpath and badproto \*RO, "file $keyword ($localpath) twice";
     protocol_receive_file \*RO, $localpath;
+    i_method "i_file", $keyword;
 }
 
 our %i_param;
@@ -1547,28 +1547,42 @@ sub i_resp_want ($) {
     my ($keyword) = @_;
     die "$keyword ?" if $i_wanted{$keyword}++;
     my @localpaths = i_method "i_want", $keyword;
-    printdebug "]]  $keyword @localpaths\n";
+    printdebug "[[  $keyword @localpaths\n";
     foreach my $localpath (@localpaths) {
        protocol_send_file \*RI, $localpath;
     }
     print RI "files-end\n" or die $!;
 }
 
-our ($i_clogp, $i_version, $i_tag, $i_dscfn);
+our ($i_clogp, $i_version, $i_tag, $i_dscfn, $i_changesfn);
 
-sub i_localname_parsed_changelog { return "remote-changelog.822"; }
-sub i_localname_changes { return "remote.changes"; }
-sub i_localname_dsc {
+sub i_localname_parsed_changelog {
+    return "remote-changelog.822";
+}
+sub i_file_parsed_changelog {
     ($i_clogp, $i_version, $i_tag, $i_dscfn) =
        push_parse_changelog "$i_tmp/remote-changelog.822";
     die if $i_dscfn =~ m#/|^\W#;
+}
+
+sub i_localname_dsc {
+    defined $i_dscfn or badproto \*RO, "dsc (before parsed-changelog)";
     return $i_dscfn;
 }
+sub i_file_dsc { }
+
+sub i_localname_changes {
+    defined $i_dscfn or badproto \*RO, "dsc (before parsed-changelog)";
+    $i_changesfn = $i_dscfn;
+    $i_changesfn =~ s/\.dsc$/_dgit.changes/ or die;
+    return $i_changesfn;
+}
+sub i_file_changes { }
 
 sub i_want_signed_tag {
     printdebug Dumper(\%i_param, $i_dscfn);
     defined $i_param{'head'} && defined $i_dscfn && defined $i_clogp
-       or badproto \*RO, "sequencing error";
+       or badproto \*RO, "premature desire for signed-tag";
     my $head = $i_param{'head'};
     die if $head =~ m/[^0-9a-f]/ || $head !~ m/^../;
 
@@ -1577,7 +1591,7 @@ sub i_want_signed_tag {
     my $tagobjfn =
        push_mktag $head, $i_clogp, $i_tag,
            $i_dscfn,
-           'remote.changes', 'remote changes',
+           $i_changesfn, 'remote changes',
            sub { "tag$_[0]"; };
 
     return $tagobjfn;
@@ -1585,8 +1599,8 @@ sub i_want_signed_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');
+    sign_changes $i_changesfn;
+    return ($i_dscfn, $i_changesfn);
 }
 
 #---------- building etc. ----------