[PATCH setup 09/11] Use stored action in packagemeta::list_actions()
Jon Turney
jon.turney@dronecode.org.uk
Thu Aug 1 16:08:00 GMT 2019
Use the stored action in packagemeta::list_actions(), rather than
working backwards from desired/installed/picked.
---
package_meta.cc | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/package_meta.cc b/package_meta.cc
index 2564f95..8fad50d 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -490,34 +490,20 @@ packagemeta::toggle_action ()
ActionList *
packagemeta::list_actions(trusts const trust)
{
- // first work out the current action, so we can indicate that
- _actions action;
-
- if (!desired && installed)
- action = Uninstall_action;
- else if (!desired)
- action = NoChange_action; // skip
- else if (desired == installed && picked())
- action = Reinstall_action;
- else if (desired == installed)
- action = NoChange_action; // keep
- else
- action = Install_action;
-
- // now build the list of possible actions
+ // build the list of possible actions
ActionList *al = new ActionList();
- al->add("Uninstall", (int)Uninstall_action, (action == Uninstall_action), bool(installed));
- al->add("Skip", (int)NoChange_action, (action == NoChange_action) && !installed, !installed);
+ al->add("Uninstall", (int)Uninstall_action, (_action == Uninstall_action), bool(installed));
+ al->add("Skip", (int)NoChange_action, (_action == NoChange_action) && !installed, !installed);
std::set<packageversion>::iterator i;
for (i = versions.begin (); i != versions.end (); ++i)
{
if (*i == installed)
{
- al->add("Keep", (int)NoChange_action, (action == NoChange_action), TRUE);
+ al->add("Keep", (int)NoChange_action, (_action == NoChange_action), TRUE);
al->add(packagedb::task == PackageDB_Install ? "Reinstall" : "Retrieve",
- (int)Reinstall_action, (action == Reinstall_action), TRUE);
+ (int)Reinstall_action, (_action == Reinstall_action), TRUE);
}
else
{
@@ -526,7 +512,7 @@ packagemeta::list_actions(trusts const trust)
label += " (Test)";
al->add(label,
-std::distance(versions.begin (), i),
- (action == Install_action) && (*i == desired),
+ (_action == Install_action) && (*i == desired),
TRUE);
}
}
--
2.21.0
More information about the Cygwin-apps
mailing list