--- /dev/null
+stg-bury(1)
+===========
+Yann Dirson <ydirson@altern.org>
+v0.13, April 2007
+
+NAME
+----
+stg-bury - stgdesc:bury[]
+
+SYNOPSIS
+--------
+[verse]
+'stg' bury [--to=<target>] [--nopush] [<patches>]
+
+DESCRIPTION
+-----------
+
+This is the opposite operation of stglink:float[]: move the specified
+patches down the stack. It is for example useful to group stable
+patches near the bottom of the stack, where they are less likely to be
+impacted by the push of another patch, and from where they can be more
+easily committed or pushed.
+
+If no patch is specified on command-line, the current patch is buried.
+By default patches are buried at the bottom of the stack, but the
+'--to' option allows to bury under any applied patch.
+
+Buring internally involves popping all patches (or all patches
+including <target patch>), then pushing the patches to bury, and then
+(unless '--nopush' is also given) pushing back into place the
+formerly-applied patches.
+
+
+OPTIONS
+-------
+
+--to=<TARGET>::
+-t <TARGET>::
+ Specify a target patch to bury the patches below, instead of
+ buring at the bottom of the stack.
+
+--nopush::
+-n::
+ Do not push back on the stack the formerly-applied patches.
+ Only the patches to bury are pushed.
+
+StGIT
+-----
+Part of the StGIT suite - see gitlink:stg[1].
+++ /dev/null
-#!/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";
-}
--- /dev/null
+
+__copyright__ = """
+Copyright (C) 2007, Yann Dirson <ydirson@altern.org>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2 as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""
+
+import sys, os
+from optparse import OptionParser, make_option
+
+from stgit.commands.common import *
+from stgit.utils import *
+from stgit import stack, git
+
+
+help = 'bury patches down the stack'
+usage = """%prog [-t <target patch>] [-n] [<patches>]
+
+Pop all patches (or all patches including <target patch>), then
+push the specified <patches> (the current patch by default), and
+then push back into place the formerly-applied patches (unless -n
+is also given)."""
+
+options = [make_option('-n', '--nopush',
+ help = 'do not push the patches back after sinking',
+ action = 'store_true'),
+ make_option('-t', '--to', metavar = 'TARGET',
+ help = 'bury patches below TARGET patch')]
+
+def func(parser, options, args):
+ """Bury patches
+ """
+
+ check_local_changes()
+ check_conflicts()
+ check_head_top_equal()
+
+ oldapplied = crt_series.get_applied()
+ unapplied = crt_series.get_unapplied()
+ all = unapplied + oldapplied
+
+ if len(args) > 0:
+ patches = parse_patches(args, all)
+ else:
+ patches = [ crt_series.get_current() ]
+
+ crt_series.pop_patch(options.to or oldapplied[0])
+ push_patches(patches)
+
+ if not options.nopush:
+ newapplied = crt_series.get_applied()
+ def not_reapplied_yet(p):
+ return not p in newapplied
+ push_patches(filter(not_reapplied_yet, oldapplied))