Signed-off-by: Karl Hasselström <kha@xxxxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html