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

[StGit PATCH 08/10] Let "stg clean" use the new transaction primitives

From
Karl Hasselström <kha@treskal.com>
Date
Nov 25, 2007, 20:51 UTC
Message-ID
<20071125205146.7823.47696.stgit@yoghurt>
In-Reply-To
<20071125203717.7823.70046.stgit@yoghurt>
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/commands/clean.py |   33 +++++++--------------------------
 1 files changed, 7 insertions(+), 26 deletions(-)
diff --git a/stgit/commands/clean.py b/stgit/commands/clean.py
index e2d1678..cfcc004 100644
--- a/stgit/commands/clean.py
+++ b/stgit/commands/clean.py
@@ -37,33 +37,14 @@ options = [make_option('-a', '--applied',
 
 
 def _clean(stack, clean_applied, clean_unapplied):
-    def deleting(pn):
-        out.info('Deleting empty patch %s' % pn)
     trans = transaction.StackTransaction(stack, 'clean')
-    if clean_unapplied:
-        trans.unapplied = []
-        for pn in stack.patchorder.unapplied:
-            p = stack.patches.get(pn)
-            if p.commit.data.is_empty():
-                trans.patches[pn] = None
-                deleting(pn)
-            else:
-                trans.unapplied.append(pn)
-    if clean_applied:
-        trans.applied = []
-        parent = stack.base
-        for pn in stack.patchorder.applied:
-            p = stack.patches.get(pn)
-            if p.commit.data.is_empty():
-                trans.patches[pn] = None
-                deleting(pn)
-            else:
-                if parent != p.commit.data.parent:
-                    parent = trans.patches[pn] = stack.repository.commit(
-                        p.commit.data.set_parent(parent))
-                else:
-                    parent = p.commit
-                trans.applied.append(pn)
+    def del_patch(pn):
+        if pn in stack.patchorder.applied:
+            return clean_applied and trans.patches[pn].data.is_empty()
+        elif pn in stack.patchorder.unapplied:
+            return clean_unapplied and trans.patches[pn].data.is_empty()
+    for pn in trans.delete_patches(del_patch):
+        trans.push_patch(pn)
     trans.run()
 
 def func(parser, options, args):
Previous: Karl HasselströmNext: Karl Hasselström
Message 12 of 14 in “Infrastructure rewrite series”
  1. 00/10 Infrastructure rewrite seriesKarl Hasselström, Nov 25, 2007
  2. 01/10 New StGit core infrastructure: repository operationsKarl Hasselström, Nov 25, 2007
  3. 02/10 Write metadata files used by the old infrastructureKarl Hasselström, Nov 25, 2007
  4. 03/10 Upgrade older stacks to newest versionKarl Hasselström, Nov 25, 2007
  5. 04/10 Let "stg clean" use the new infrastructureKarl Hasselström, Nov 25, 2007
  6. 05/10 Add "stg coalesce"Karl Hasselström, Nov 25, 2007
  7. 06/10 Let "stg applied" and "stg unapplied" use the new infrastructureKarl Hasselström, Nov 25, 2007
  8. 07/10 Teach the new infrastructure about the index and worktreeKarl Hasselström, Nov 25, 2007
  9. Karl HasselströmNov 26, 2007
  10. David KågedalNov 26, 2007
  11. Karl HasselströmNov 26, 2007
  12. 08/10 Let "stg clean" use the new transaction primitivesKarl Hasselström, Nov 25, 2007
  13. 09/10 Let "stg goto" use the new infrastructureKarl Hasselström, Nov 25, 2007
  14. 10/10 Convert "stg uncommit" to the new infrastructureKarl Hasselström, Nov 25, 2007

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.