public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup 04/11] Rename 'Default' packagemeta action to 'NoChange' for clarity
Date: Thu, 01 Aug 2019 16:07:00 -0000	[thread overview]
Message-ID: <20190801160519.32745-5-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20190801160519.32745-1-jon.turney@dronecode.org.uk>

---
 PickCategoryLine.cc |  2 +-
 PickView.h          |  2 +-
 choose.cc           |  6 +++---
 package_meta.cc     | 19 +++++++++++--------
 package_meta.h      |  2 +-
 5 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/PickCategoryLine.cc b/PickCategoryLine.cc
index 7aa1f28..7c1d464 100644
--- a/PickCategoryLine.cc
+++ b/PickCategoryLine.cc
@@ -68,7 +68,7 @@ PickCategoryLine::get_actions(int col) const
   ActionList *al = new ActionList();
   packagemeta::_actions current_default = cat_tree->action();
 
-  al->add("Default", (int)packagemeta::Default_action, (current_default == packagemeta::Default_action), TRUE);
+  al->add("Default", (int)packagemeta::NoChange_action, (current_default == packagemeta::NoChange_action), TRUE);
   al->add("Install", (int)packagemeta::Install_action, (current_default == packagemeta::Install_action), TRUE);
   al->add(packagedb::task == PackageDB_Install ? "Reinstall" : "Retrieve",
           (int)packagemeta::Reinstall_action, (current_default == packagemeta::Reinstall_action), TRUE);
diff --git a/PickView.h b/PickView.h
index 9443a78..2db0562 100644
--- a/PickView.h
+++ b/PickView.h
@@ -97,7 +97,7 @@ public:
   CategoryTree(Category & cat, bool collapsed) :
     _cat (cat),
     _collapsed(collapsed),
-    _action (packagemeta::Default_action)
+    _action (packagemeta::NoChange_action)
   {
   }
 
diff --git a/choose.cc b/choose.cc
index c4b8773..277baba 100644
--- a/choose.cc
+++ b/choose.cc
@@ -305,11 +305,11 @@ ChooserPage::applyCommandLinePackageSelection()
       else if (uninstall)
 	pkg.set_action (packagemeta::Uninstall_action, packageversion ());
       else if (PruneInstallOption)
-	pkg.set_action (packagemeta::Default_action, pkg.curr);
+	pkg.set_action (packagemeta::NoChange_action, pkg.curr);
       else if (upgrade)
-	pkg.set_action (packagemeta::Default_action, pkg.trustp(true, TRUST_UNKNOWN));
+	pkg.set_action (packagemeta::NoChange_action, pkg.trustp(true, TRUST_UNKNOWN));
       else
-	pkg.set_action (packagemeta::Default_action, pkg.installed);
+	pkg.set_action (packagemeta::NoChange_action, pkg.installed);
     }
 }
 
diff --git a/package_meta.cc b/package_meta.cc
index a4f6c93..3224f1c 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -51,12 +51,13 @@ bool hasManualSelections = 0;
 
 /*****************/
 
+/* Return an appropriate category caption given the action */
 char const *
 packagemeta::action_caption (_actions _value)
 {
   switch (_value)
     {
-    case Default_action:
+    case NoChange_action:
       return "Default";
     case Install_action:
       return "Install";
@@ -454,7 +455,7 @@ packagemeta::select_action (int id, trusts const deftrust)
     }
   else
     {
-      if (id == packagemeta::Default_action)
+      if (id == packagemeta::NoChange_action)
         set_action((packagemeta::_actions)id, installed);
       else
         set_action((packagemeta::_actions)id, trustp (true, deftrust));
@@ -472,7 +473,7 @@ packagemeta::toggle_action ()
 {
   if (desired != installed)
     {
-      set_action(Default_action, installed);
+      set_action(NoChange_action, installed);
     }
   else
     {
@@ -495,11 +496,11 @@ packagemeta::list_actions(trusts const trust)
   if (!desired && installed)
     action = Uninstall_action;
   else if (!desired)
-    action = Default_action; // skip
+    action = NoChange_action; // skip
   else if (desired == installed && picked())
     action = Reinstall_action;
   else if (desired == installed)
-    action = Default_action; // keep
+    action = NoChange_action; // keep
   else
     action = Install_action;
 
@@ -507,14 +508,14 @@ packagemeta::list_actions(trusts const trust)
   ActionList *al = new ActionList();
 
   al->add("Uninstall", (int)Uninstall_action, (action == Uninstall_action), bool(installed));
-  al->add("Skip", (int)Default_action, (action == Default_action) && !installed, !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)Default_action, (action == Default_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);
         }
@@ -537,8 +538,9 @@ packagemeta::list_actions(trusts const trust)
 void
 packagemeta::set_action (_actions action, packageversion const &default_version)
 {
-  if (action == Default_action)
+  if (action == NoChange_action)
     {
+      // if installed, keep
       if (installed
 	  || categories.find ("Base") != categories.end ()
 	  || categories.find ("Orphaned") != categories.end ())
@@ -551,6 +553,7 @@ packagemeta::set_action (_actions action, packageversion const &default_version)
 	    }
 	}
       else
+        // else, if not installed, skip
 	desired = packageversion ();
       return;
     }
diff --git a/package_meta.h b/package_meta.h
index 2c40102..12f2de2 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -53,7 +53,7 @@ public:
 
   enum _actions
     {
-     Default_action = 1,
+     NoChange_action = 1,  // keep if installed, skip if not installed
      Install_action,
      Reinstall_action,
      Uninstall_action,
-- 
2.21.0

  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 01/11] Remove 'Bin?' column Jon Turney
2019-08-01 16:05 ` [PATCH setup 02/11] Remove unused packagemeta::key Jon Turney
2019-08-01 16:06 ` [PATCH setup 03/11] Make packagemeta::message private Jon Turney
2019-08-01 16:07 ` [PATCH setup 05/11] Store the requested action in packagemeta::set_action() Jon Turney
2019-08-01 16:07 ` Jon Turney [this message]
2019-08-01 16:07 ` [PATCH setup 06/11] Use packagemeta::set_action() to update action Jon Turney
2019-08-01 16:08 ` [PATCH setup 09/11] Use stored action in packagemeta::list_actions() 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 07/11] Use stored action in setting up solver 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-5-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).