From 219d507eed2b5958a6938423d244177b3fef8ae1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 9 Oct 2013 01:42:16 +0100 Subject: [PATCH] code motion and separators --- debian/changelog | 1 + dgit | 54 +++++++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/debian/changelog b/debian/changelog index 48201104..16119b95 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ dgit (0.16~experimental2) experimental; urgency=low * WIP remote functionality. Untested, do not use. + * Some code motion and cleanups. * push actually takes an optional suite, like it says in the synopsis. * Command execution reports from --dry-run go to stderr. diff --git a/dgit b/dgit index 66f08c1d..84823813 100755 --- a/dgit +++ b/dgit @@ -125,7 +125,7 @@ sub fetchspec () { return "+".rrref().":".lrref(); } -our $ua; +#---------- remote protocol support, common ---------- # remote push initiator/responder protocol: # < dgit-remote-push-ready [optional extra info ignored by old initiators] @@ -160,24 +160,6 @@ our $ua; # # > complete -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 { - if ($we_are_responder) { - my $m = join '', @_; - responder_send_command "progress ".length($m) or die $!; - print $m or die $!; - } else { - print @_, "\n"; - } -} - sub badproto ($$) { my ($fh, $m) = @_; fail "connection lost: $!" if $fh->error; @@ -222,6 +204,16 @@ sub protocol_receive_file ($$) { } } +#---------- remote protocol support, responder ---------- + +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 responder_send_file ($$) { my ($keyword, $ourfn) = @_; return unless $we_are_responder; @@ -239,6 +231,24 @@ sub responder_receive_files ($@) { protocol_expect \*STDIN, { m/^files-end$/ }; } +#---------- remote protocol support, initiator ---------- + + + +#---------- end remote code ---------- + +sub progress { + if ($we_are_responder) { + my $m = join '', @_; + responder_send_command "progress ".length($m) or die $!; + print $m or die $!; + } else { + print @_, "\n"; + } +} + +our $ua; + sub url_get { if (!$ua) { $ua = LWP::UserAgent->new(); @@ -1325,6 +1335,8 @@ sub cmd_push { dopush(); } +#---------- remote commands' implementation ---------- + sub cmd_remote_push_responder { my ($nrargs) = shift @ARGV; my (@rargs) = @ARGV[0..$nrargs-1]; @@ -1365,6 +1377,8 @@ sub cmd_rpush { } } +#---------- building etc. ---------- + our $version; our $sourcechanges; our $dscfn; @@ -1533,6 +1547,8 @@ sub cmd_quilt_fixup { build_maybe_quilt_fixup(); } +#---------- argument parsing and main program ---------- + sub cmd_version { print "dgit version $our_version\n" or die $!; exit 0; -- 2.30.2