Command to move a patch to the top
PATCH 1/1 Command to move a patch to the top
In reply to a message not in the archiveFrom: Robin Rosenberg <[email protected]>
---
stgit/commands/float.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++ stgit/main.py | 3 ++ t/t1500-float.sh | 56 ++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 0 deletions(-)
stgit/commands/float.py new file +78 -0
@@ -0,0 +1,78 @@ + +__copyright__ = """ +Copyright (C) 2006, Robin Rosenberg <[email protected]> + +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 = 'push a patch to the top, even if applied' +usage = """%prog [options] + +Push a patch to the top even if applied. The necessary +pop and push operations will be performed to accomplish +this. """ + +#options = [make_option('-b', '--branch', +# help = 'use BRANCH instead of the default one')]. + +options = [make_option('-a', '--all', + help = 'push all the unapplied patches', + action = 'store_true'), + make_option('--keep', + help = 'keep the current working directory', + action = 'store_true'), + make_option('-m', '--merged', + help = 'check for patches merged upstream', + action = 'store_true') ] + +def func(parser, options, args): + """Pops and pushed to make the named patch the topmost patch + """ + + if not options.keep: + check_local_changes() + check_conflicts() + check_head_top_equal() + + unapplied = crt_series.get_unapplied() + applied = crt_series.get_applied() + all = [] + all.extend(unapplied) + all.extend(applied) + + patches = parse_patches(args, all) + + topush=[] + topop=[] + + for p in patches: + while p in applied: + top = applied[-1] + print applied + if not top in patches: + topush.insert(0,top) + topop.append(top) + x = applied.pop() + for p in patches: + topush.append(p) + + pop_patches(topop, options.keep) + push_patches(topush, options.merged)
stgit/main.py +3 -0
@@ -38,6 +38,7 @@ import stgit.commands.clone import stgit.commands.commit import stgit.commands.export import stgit.commands.files +import stgit.commands.float import stgit.commands.fold import stgit.commands.goto import stgit.commands.id
@@ -77,6 +78,7 @@ commands = { 'commit': stgit.commands.commit, 'export': stgit.commands.export, 'files': stgit.commands.files, + 'float': stgit.commands.float, 'fold': stgit.commands.fold, 'goto': stgit.commands.goto, 'id': stgit.commands.id,
@@ -113,6 +115,7 @@ stackcommands = ( 'applied', 'clean', 'commit', + 'float', 'goto', 'init', 'pop',
t/t1500-float.sh new file +56 -0
56 lines not on this page · raw message