From: Karl Hasselström Date: Sun, 25 Nov 2007 20:51:46 GMT Subject: [StGit PATCH 08/10] Let "stg clean" use the new transaction primitives Message-ID: <20071125205146.7823.47696.stgit@yoghurt> In-Reply-To: <20071125203717.7823.70046.stgit@yoghurt> Signed-off-by: Karl Hasselström --- 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):