summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2013-09-26 20:36:49 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2013-09-26 20:36:49 +0100
commit91f37f511e100757d329e0f0e9cfd54c749708c3 (patch)
tree2291fac3a69c100bccd1567cb79c9b36ba785a5c
parent20130eef1751401dbdf64149806b73a4a0b88764 (diff)
wip changes for remote push - implementation of remote push responder, not tested
-rwxr-xr-xdgit57
1 files changed, 46 insertions, 11 deletions
diff --git a/dgit b/dgit
index a47db91..c24a950 100755
--- a/dgit
+++ b/dgit
@@ -121,30 +121,53 @@ sub fetchspec () {
our $ua;
+sub responder_send_command ($) {
+ my ($command) = @_;
+ return unless $we_are_responder;
+ # called even without $we_are_responder
+ print DEBUG "<< $command\n";
+ print $command, "\n" or die $!;
+}
+
sub progress {
- print @_, "\n";
+ if ($we_are_responder) {
+ my $m = join '', @_;
+ responder_send_command "progress ".length($m) or die $!;
+ print $m or die $!;
+ } else {
+ print @_, "\n";
+ }
+}
+
+sub protocol_send_file ($) {
+ my ($fh, $cmdprefix, $ourfn) = @_;
+ open PF, "<", $ourfn or die "$ourfn: $!";
+ print $fh "$cmdprefix begin\n" or die $!;
+ for (;;) {
+ my $d;
+ my $got = read PF, $d, 65536;
+ die "$ourfn: $!" unless defined $got;
+ last if $got;
+ print $fh "$keyword block ".length($d)."\n" or die $!;
+ print $d or die $!;
+ }
+ print $fh "$keyword end\n" or die $!;
+ close PF;
}
sub responder_send_file ($$) {
my ($keyword, $ourfn) = @_;
return unless $we_are_responder;
- die "responder send file $keyword $ourfn\n";
+ print DEBUG "responder sending $keyword $ourfn\n";
+ protocol_send_file(\*STDOUT, "upload $keyword");
}
sub responder_receive_files ($@) {
my ($keyword, @ourfns) = @_;
die unless $we_are_responder;
- die 'nyi';
+
}
-sub responder_send_command ($) {
- my ($command) = @_;
- return unless $we_are_responder;
- # called even without $we_are_responder
- print DEBUG "responder command $command\n";
- die;
-}
-
sub url_get {
if (!$ua) {
$ua = LWP::UserAgent->new();
@@ -1220,6 +1243,18 @@ sub cmd_push {
dopush();
}
+sub cmd_remote_push_responder {
+ my ($nrargs) = shift @ARGV;
+ my (@rargs) = @ARGV[0..$nrargs-1];
+ @ARGV = @ARGV[$nrargs..$#ARGV];
+ die unless @rargs;
+ my ($dir) = @rargs;
+ chdir $dir or die "$dir: $!";
+ $we_are_remote = 1;
+ responder_send_command("dgit-remote-push-ready");
+ &cmd_push;
+}
+
our $version;
our $sourcechanges;
our $dscfn;