From: Catalin Marinas Date: Thu, 9 Apr 2009 20:40:59 +0000 (+0300) Subject: Use a default "hidden" argument in StackTransaction.reorder_patches X-Git-Tag: v0.15-rc1~28 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/d44708ef52f10a22ca3c87ff3c92bdd911bca672 Use a default "hidden" argument in StackTransaction.reorder_patches This argument is rarely used so adding a default value simplifies the calling code. Signed-off-by: Catalin Marinas Acked-by: Karl Hasselström --- diff --git a/stgit/commands/float.py b/stgit/commands/float.py index 8410675..e561c39 100644 --- a/stgit/commands/float.py +++ b/stgit/commands/float.py @@ -71,7 +71,6 @@ def func(parser, options, args): applied = [p for p in stack.patchorder.applied if p not in patches] + \ patches unapplied = [p for p in stack.patchorder.unapplied if not p in patches] - hidden = list(stack.patchorder.hidden) iw = stack.repository.default_iw clean_iw = (not options.keep and iw) or None @@ -79,7 +78,7 @@ def func(parser, options, args): check_clean_iw = clean_iw) try: - trans.reorder_patches(applied, unapplied, hidden, iw) + trans.reorder_patches(applied, unapplied, iw = iw) except transaction.TransactionHalted: pass return trans.run(iw) diff --git a/stgit/commands/sink.py b/stgit/commands/sink.py index b9b8c8a..4677a75 100644 --- a/stgit/commands/sink.py +++ b/stgit/commands/sink.py @@ -81,9 +81,7 @@ def func(parser, options, args): else: insert_idx = 0 applied = applied[:insert_idx] + patches + applied[insert_idx:] - 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 @@ -91,7 +89,7 @@ def func(parser, options, args): check_clean_iw = clean_iw) try: - trans.reorder_patches(applied, unapplied, hidden, iw) + trans.reorder_patches(applied, unapplied, iw = iw) except transaction.TransactionHalted: pass return trans.run(iw) diff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py index 4b5398a..b146648 100644 --- a/stgit/lib/transaction.py +++ b/stgit/lib/transaction.py @@ -365,8 +365,10 @@ class StackTransaction(object): # Update immediately. update() - def reorder_patches(self, applied, unapplied, hidden, iw = None): + def reorder_patches(self, applied, unapplied, hidden = None, iw = None): """Push and pop patches to attain the given ordering.""" + if hidden is None: + hidden = self.hidden common = len(list(it.takewhile(lambda (a, b): a == b, zip(self.applied, applied)))) to_pop = set(self.applied[common:])