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

[StGit PATCH 05/10] Add utility function for reordering patches

From
Karl Hasselström <kha@treskal.com>
Date
Apr 20, 2008, 22:10 UTC
Message-ID
<20080420221050.5837.35826.stgit@yoghurt>
In-Reply-To
<20080420215625.5837.82896.stgit@yoghurt>
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/lib/transaction.py |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py
index 4fb37ce..4c3b448 100644
--- a/stgit/lib/transaction.py
+++ b/stgit/lib/transaction.py
@@ -1,3 +1,5 @@
+import itertools as it
+
 from stgit import exception, utils
 from stgit.utils import any, all
 from stgit.out import *
@@ -233,3 +235,15 @@ class StackTransaction(object):
             self.__allow_conflicts = lambda trans: True
 
             self.__halt('Merge conflict')
+
+    def reorder_patches(self, applied, unapplied, iw = None):
+        """Push and pop patches to attain the given ordering."""
+        common = len(list(it.takewhile(lambda (a, b): a == b,
+                                       zip(self.applied, applied))))
+        to_pop = set(self.applied[common:])
+        self.pop_patches(lambda pn: pn in to_pop)
+        for pn in applied[common:]:
+            self.push_patch(pn, iw)
+        assert self.applied == applied
+        assert set(self.unapplied) == set(unapplied)
+        self.unapplied = unapplied
Previous: Karl HasselströmNext: Karl Hasselström
Message 6 of 11 in “Updated "stg reset" series”
  1. 00/10 Updated "stg reset" seriesKarl Hasselström, Apr 20, 2008
  2. 01/10 Prevent most commands from running when there are conflictsKarl Hasselström, Apr 20, 2008
  3. 02/10 Add property with a list of all patch namesKarl Hasselström, Apr 20, 2008
  4. 03/10 Library functions for tree and blob manipulationKarl Hasselström, Apr 20, 2008
  5. 04/10 Write to a stack log when stack is modifiedKarl Hasselström, Apr 20, 2008
  6. 05/10 Add utility function for reordering patchesKarl Hasselström, Apr 20, 2008
  7. 06/10 New command: stg resetKarl Hasselström, Apr 20, 2008
  8. 07/10 Log conflicts separatelyKarl Hasselström, Apr 20, 2008
  9. 08/10 Log conflicts separately for all commandsKarl Hasselström, Apr 20, 2008
  10. 09/10 Add a --hard flag to stg resetKarl Hasselström, Apr 20, 2008
  11. 10/10 Don't write a log entry if there were no changesKarl Hasselström, Apr 20, 2008

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.