From: Yann Dirson Date: Thu, 01 Mar 2007 23:04:15 GMT Subject: [PATCH 8/8] Add contrib/stg-sink: sink a patch to given location (mirrors float). Message-ID: <20070301230415.32459.45545.stgit@gandelf.nowhere.earth> In-Reply-To: <20070301225651.32459.89156.stgit@gandelf.nowhere.earth> Signed-off-by: Yann Dirson --- contrib/stg-sink | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/contrib/stg-sink b/contrib/stg-sink new file mode 100755 index 0000000..e63eb93 --- /dev/null +++ b/contrib/stg-sink @@ -0,0 +1,44 @@ +#!/usr/bin/perl +use strict; +use warnings; + +sub _run { + print(' >> ', @_, "\n");# and 0; + system(@_); +} + +my $dopush=1; +my $pop='pop -a'; +while (@ARGV and $ARGV[0] =~ m/^-/) { + if ($ARGV[0] eq '-n') { + $dopush=0; + shift @ARGV; + } + if ($ARGV[0] eq '-t') { + shift @ARGV; + $pop = 'goto '.shift @ARGV; + } +} + +# default: sink current patch +if (@ARGV == 0) { + $ARGV[0] = `stg top`; +} + +my @oldapplied=`stg applied`; +chomp (@oldapplied); + +_run('stg '.$pop) && + die "cannot pop all patches"; +_run('stg push ' . join (' ', @ARGV)) && + die "error pushing patches"; + +if ($dopush) { + my @newapplied=`stg applied`; + chomp (@newapplied); + my @remaining=grep { my $check=$_; + not grep { $check eq $_ } @newapplied; + } @oldapplied; + _run('stg push ' . join (' ', @remaining)) && + die "error pushing remaining patches"; +}