From 4cb3cfadef1dcff01526309c682646f1968dae96 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Mon, 16 Jun 2008 09:13:31 +0000 Subject: [PATCH] get_takeback_plan --- pisi/api.py | 10 ++++++++++ pisi/operations/history.py | 11 +++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pisi/api.py b/pisi/api.py index b2564209..28eb3b4f 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -347,6 +347,16 @@ def takeback(operation): pisi.operations.history.takeback(operation) +def get_takeback_plan(operation): + """ + Calculates and returns the plan of the takeback operation that contains information of which + packages are going to be removed and which packages are going to be installed + @param operation: number of the operation that the system will be taken back -> integer + """ + + beinstalled, beremoved, configs = pisi.operations.history.plan_takeback(operation) + return beinstalled, beremoved + def snapshot(): """ Takes snapshot of the system packages. The snapshot is only a record of which packages are currently diff --git a/pisi/operations/history.py b/pisi/operations/history.py index d71fb1e0..ebb19747 100644 --- a/pisi/operations/history.py +++ b/pisi/operations/history.py @@ -34,7 +34,7 @@ def __pkg_already_installed(name, pkginfo): return (ver, rel, build) == installdb.get_version(name) def __listactions(actions): - + beinstalled = [] beremoved = [] configs = [] @@ -108,15 +108,18 @@ def get_takeback_actions(operation): return actions -def takeback(operation): - +def plan_takeback(operation): op = historydb.get_operation(operation) if op.type == "snapshot": actions = get_snapshot_actions(op) else: actions = get_takeback_actions(operation) - beinstalled, beremoved, configs = __listactions(actions) + return __listactions(actions) + +def takeback(operation): + + beinstalled, beremoved, configs = plan_takeback(operation) if beinstalled: ctx.ui.info(_("Following packages will be installed:\n") + pisi.util.strlist(beinstalled))