From: Catalin Marinas <catalin.marinas@arm.com>
To: git@vger.kernel.org, "Karl Hasselström" <kha@treskal.com>
Subject: [StGit PATCH 5/5] Convert "float" to the lib infrastructure
Date: Thu, 12 Mar 2009 12:09:18 +0000 [thread overview]
Message-ID: <20090312120918.2992.82713.stgit@pc1117.cambridge.arm.com> (raw)
In-Reply-To: <20090312120426.2992.35213.stgit@pc1117.cambridge.arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
---
stgit/commands/float.py | 75 ++++++++++++++++++-----------------------------
1 files changed, 29 insertions(+), 46 deletions(-)
diff --git a/stgit/commands/float.py b/stgit/commands/float.py
index 7c3dcdf..f94de88 100644
--- a/stgit/commands/float.py
+++ b/stgit/commands/float.py
@@ -16,11 +16,11 @@ 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
+import sys
from stgit.argparse import opt
-from stgit.commands.common import *
-from stgit.utils import *
-from stgit import argparse, stack, git
+from stgit.commands import common
+from stgit.lib import transaction
+from stgit import argparse
help = 'Push patches to the top, even if applied'
kind = 'stack'
@@ -36,25 +36,20 @@ args = [argparse.patch_range(argparse.applied_patches,
argparse.unapplied_patches)]
options = [
opt('-s', '--series', action = 'store_true',
- short = 'Rearrange according to a series file')]
+ short = 'Rearrange according to a series file')
+ ] + argparse.keep_option()
-directory = DirectoryGotoToplevel(log = True)
+directory = common.DirectoryHasRepositoryLib()
def func(parser, options, args):
- """Pops and pushed to make the named patch the topmost patch
+ """Reorder patches to make the named patch the topmost one.
"""
args_nr = len(args)
if (options.series and args_nr > 1) \
or (not options.series and args_nr == 0):
parser.error('incorrect number of arguments')
- check_local_changes()
- check_conflicts()
- check_head_top_equal(crt_series)
-
- unapplied = crt_series.get_unapplied()
- applied = crt_series.get_applied()
- all = unapplied + applied
+ stack = directory.repository.current_stack
if options.series:
if args_nr:
@@ -68,35 +63,23 @@ def func(parser, options, args):
if patch:
patches.append(patch)
else:
- patches = parse_patches(args, all)
-
- # working with "topush" patches in reverse order might be a bit
- # more efficient for large series but the main reason is for the
- # "topop != topush" comparison to work
- patches.reverse()
-
- topush = []
- topop = []
-
- for p in patches:
- while p in applied:
- top = applied.pop()
- if not top in patches:
- topush.append(top)
- topop.append(top)
- topush = patches + topush
-
- # remove common patches to avoid unnecessary pop/push
- while topush and topop:
- if topush[-1] != topop[-1]:
- break
- topush.pop()
- topop.pop()
-
- # check whether the operation is really needed
- if topop != topush:
- if topop:
- pop_patches(crt_series, topop)
- if topush:
- topush.reverse()
- push_patches(crt_series, topush)
+ patches = common.parse_patches(args, stack.patchorder.all)
+
+ if not patches:
+ raise common.CmdException('No patches to float')
+
+ applied = [p for p in stack.patchorder.applied if p not in patches] + \
+ patches
+ unapplied = [p for p in stack.patchorder.unapplied if p not in patches]
+ hidden = list(stack.patchorder.hidden)
+
+ iw = stack.repository.default_iw
+ clean_iw = not options.keep and iw or None
+ trans = transaction.StackTransaction(stack, 'sink',
+ check_clean_iw = clean_iw)
+
+ try:
+ trans.reorder_patches(applied, unapplied, hidden, iw)
+ except transaction.TransactionHalted:
+ pass
+ return trans.run(iw)
next prev parent reply other threads:[~2009-03-12 12:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-12 12:08 [StGit PATCH 0/5] Various StGit patches Catalin Marinas
2009-03-12 12:08 ` [StGit PATCH 1/5] Check for local changes with "goto" Catalin Marinas
2009-03-13 1:57 ` Karl Hasselström
2009-03-16 14:56 ` Catalin Marinas
2009-03-17 7:06 ` Karl Hasselström
2009-03-17 10:51 ` Catalin Marinas
2009-03-17 13:36 ` Karl Hasselström
2009-03-12 12:09 ` [StGit PATCH 2/5] Add mergetool support to the classic StGit infrastructure Catalin Marinas
2009-03-13 2:02 ` Karl Hasselström
2009-03-12 12:09 ` [StGit PATCH 3/5] Add automatic git-mergetool invocation to the new infrastructure Catalin Marinas
2009-03-13 2:17 ` Karl Hasselström
2009-03-16 15:03 ` Catalin Marinas
2009-03-17 7:12 ` Karl Hasselström
2009-03-12 12:09 ` [StGit PATCH 4/5] Convert "sink" " Catalin Marinas
2009-03-13 2:27 ` Karl Hasselström
2009-03-12 12:09 ` Catalin Marinas [this message]
2009-03-13 2:41 ` [StGit PATCH 5/5] Convert "float" to the lib infrastructure Karl Hasselström
2009-03-16 16:36 ` Catalin Marinas
2009-03-17 7:16 ` Karl Hasselström
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090312120918.2992.82713.stgit@pc1117.cambridge.arm.com \
--to=catalin.marinas@arm.com \
--cc=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
--cc=kha@treskal.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).