From: Yann Dirson Date: Fri, 2 Mar 2007 21:34:29 +0000 (+0000) Subject: Add contrib/stg-sink: sink a patch to given location (mirrors float). X-Git-Tag: v0.13~130 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/cefdc327bc4a35eb7b1399d7c1673b223936f23c?ds=sidebyside Add contrib/stg-sink: sink a patch to given location (mirrors float). Signed-off-by: Yann Dirson --- 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"; +}