git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGit PATCH 5/5] Convert "float" to the lib infrastructure

From
CMCatalin Marinas <catalin.marinas@arm.com>
Date
Mar 12, 2009, 12:09 UTC
Message-ID
<20090312120918.2992.82713.stgit@pc1117.cambridge.arm.com>
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)
Previous: Karl HasselströmNext: Karl Hasselström
Message 16 of 19 in “Various StGit patches”
  1. 0/5 Various StGit patchesCatalin Marinas, Mar 12, 2009
  2. 1/5 Check for local changes with "goto"Catalin Marinas, Mar 12, 2009
  3. Karl HasselströmMar 13, 2009
  4. Catalin MarinasMar 16, 2009
  5. Karl HasselströmMar 17, 2009
  6. Catalin MarinasMar 17, 2009
  7. Karl HasselströmMar 17, 2009
  8. 2/5 Add mergetool support to the classic StGit infrastructureCatalin Marinas, Mar 12, 2009
  9. Karl HasselströmMar 13, 2009
  10. 3/5 Add automatic git-mergetool invocation to the new infrastructureCatalin Marinas, Mar 12, 2009
  11. Karl HasselströmMar 13, 2009
  12. Catalin MarinasMar 16, 2009
  13. Karl HasselströmMar 17, 2009
  14. 4/5 Convert "sink" to the new infrastructureCatalin Marinas, Mar 12, 2009
  15. Karl HasselströmMar 13, 2009
  16. 5/5 Convert "float" to the lib infrastructureCatalin Marinas, Mar 12, 2009
  17. Karl HasselströmMar 13, 2009
  18. Catalin MarinasMar 16, 2009
  19. Karl HasselströmMar 17, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.