From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup 06/11] Use packagemeta::set_action() to update action
Date: Thu, 01 Aug 2019 16:07:00 -0000 [thread overview]
Message-ID: <20190801160519.32745-7-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20190801160519.32745-1-jon.turney@dronecode.org.uk>
Use packagemeta::set_action() to update the action for packagemeta
object in more (hopefully all) the places it gets changed.
(Future work: ideally we'd opaque packagemeta internals more by making
installed/curr/desired/etc. object private, rather than letting users
grovel around in those details)
---
libsolv.cc | 16 ++++++++++------
package_db.cc | 4 ++--
package_meta.cc | 7 +++++--
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/libsolv.cc b/libsolv.cc
index 9e3b066..bd8fa4c 100644
--- a/libsolv.cc
+++ b/libsolv.cc
@@ -740,16 +740,19 @@ SolverSolution::trans2db() const
case SolverTransaction::transInstall:
if (pv.Type() == package_binary)
{
- pkg->desired = pkg->default_version = pv;
- pkg->pick(true);
+ pkg->set_action(packagemeta::Install_action, pv);
+ pkg->default_version = pv;
}
else // source package
pkg->srcpick(true);
break;
case SolverTransaction::transErase:
// Only relevant if pkg is still in its "no change" state
- if (pkg->desired == pkg->installed && !pkg->picked())
- pkg->desired = pkg->default_version = packageversion();
+ if (pkg->get_action() == packagemeta::NoChange_action)
+ {
+ pkg->set_action(packagemeta::Uninstall_action, packageversion());
+ pkg->default_version = packageversion();
+ }
break;
default:
break;
@@ -767,13 +770,14 @@ SolverSolution::db2trans()
p != db.packages.end (); ++p)
{
packagemeta *pkg = p->second;
- if (pkg->desired && pkg->picked()) // install/upgrade/reinstall
+ if ((pkg->get_action() == packagemeta::Install_action) ||
+ (pkg->get_action() == packagemeta::Reinstall_action))
{
trans.push_back(SolverTransaction(pkg->desired, SolverTransaction::transInstall));
if (pkg->installed)
trans.push_back(SolverTransaction(pkg->installed, SolverTransaction::transErase));
}
- else if (!pkg->desired && pkg->installed) // uninstall
+ else if (pkg->get_action() == packagemeta::Uninstall_action)
trans.push_back(SolverTransaction(pkg->installed, SolverTransaction::transErase));
if (pkg->srcpicked())
diff --git a/package_db.cc b/package_db.cc
index 59c59ef..847f44e 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -758,7 +758,7 @@ packagedb::noChanges ()
i != packages.end(); i++)
{
packagemeta *pkg = i->second;
- pkg->desired = pkg->default_version = pkg->installed;
- pkg->pick(false);
+ pkg->set_action(packagemeta::NoChange_action, pkg->installed);
+ pkg->default_version = pkg->installed;
}
}
diff --git a/package_meta.cc b/package_meta.cc
index b731254..2564f95 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -553,8 +553,11 @@ packagemeta::set_action (_actions action, packageversion const &default_version)
}
}
else
- // else, if not installed, skip
- desired = packageversion ();
+ {
+ // else, if not installed, skip
+ desired = packageversion ();
+ pick(false);
+ }
}
else if (action == Install_action)
{
--
2.21.0
next prev parent reply other threads:[~2019-08-01 16:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 16:05 [PATCH setup 00/11] Improve handling of specifying an obsolete package to be installed on the command line Jon Turney
2019-08-01 16:05 ` [PATCH setup 02/11] Remove unused packagemeta::key Jon Turney
2019-08-01 16:05 ` [PATCH setup 01/11] Remove 'Bin?' column Jon Turney
2019-08-01 16:06 ` [PATCH setup 03/11] Make packagemeta::message private Jon Turney
2019-08-01 16:07 ` [PATCH setup 04/11] Rename 'Default' packagemeta action to 'NoChange' for clarity Jon Turney
2019-08-01 16:07 ` Jon Turney [this message]
2019-08-01 16:07 ` [PATCH setup 05/11] Store the requested action in packagemeta::set_action() Jon Turney
2019-08-01 16:08 ` [PATCH setup 07/11] Use stored action in setting up solver Jon Turney
2019-08-01 16:08 ` [PATCH setup 08/11] Allow better handling of an obsolete package specified on command line Jon Turney
2019-08-01 16:08 ` [PATCH setup 09/11] Use stored action in packagemeta::list_actions() Jon Turney
2019-08-01 16:09 ` [PATCH setup 10/11] Use stored action in packagemeta::action_caption() Jon Turney
2019-08-01 16:10 ` [PATCH setup 11/11] Ensure we only set user_picked when appropriate Jon Turney
2019-12-01 19:32 ` [PATCH setup 00/11] Improve handling of specifying an obsolete package to be installed on the command line Ken Brown
2019-12-03 20:44 ` Jon Turney
2019-12-03 21:16 ` Ken Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190801160519.32745-7-jon.turney@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=cygwin-apps@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).