Add an optional parameter to set_action(), to indicate the action is the
result of user action, and only set user_picked then.

Set that parameter when installing from the command line. All other user
actions come through select_action(), so also set that parameter there.
---
 choose.cc       |  2 +-
 package_meta.cc | 14 +++++++-------
 package_meta.h  |  3 ++-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/choose.cc b/choose.cc
index be08627..4fa0c74 100644
--- a/choose.cc
+++ b/choose.cc
@@ -299,7 +299,7 @@ ChooserPage::applyCommandLinePackageSelection()
       bool uninstall = (!(wanted  || base) && (deleted || PruneInstallOption))
                     || (orphaned && CleanOrphansOption);
       if (install)
-       pkg.set_action (packagemeta::Install_action, UpgradeAlsoOption ? 
packageversion () : pkg.curr);
+        pkg.set_action (packagemeta::Install_action, UpgradeAlsoOption ? 
packageversion () : pkg.curr, true);
       else if (reinstall)
        pkg.set_action (packagemeta::Reinstall_action, pkg.curr);
       else if (uninstall)
diff --git a/package_meta.cc b/package_meta.cc
index b417fb0..940f69a 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -462,12 +462,8 @@ packagemeta::select_action (int id, trusts const deftrust)
       if (id == packagemeta::NoChange_action)
         set_action((packagemeta::_actions)id, installed);
       else
-        set_action((packagemeta::_actions)id, trustp (true, deftrust));
+        set_action((packagemeta::_actions)id, trustp (true, deftrust), true);
     }
-
-  /* Memorize the fact that the user picked at least once. */
-  if (!installed)
-    user_picked = true;
 }
 
 // toggle between the currently installed version (or uninstalled, if not
@@ -526,7 +522,8 @@ packagemeta::list_actions(trusts const trust)
 
 // Set a particular type of action.
 void
-packagemeta::set_action (_actions action, packageversion const 
&default_version)
+packagemeta::set_action (_actions action, packageversion const 
&default_version,
+                         bool useraction)
 {
   if (action == NoChange_action)
     {
@@ -557,7 +554,10 @@ packagemeta::set_action (_actions action, packageversion 
const &default_version)
          if (desired != installed)
            if (desired.accessible ())
              {
-               user_picked = true;
+               /* Memorize the fact that the user picked to install this 
package at least once. */
+               if (useraction)
+                 user_picked = true;
+
                pick (true);
                srcpick (false);
              }
diff --git a/package_meta.h b/package_meta.h
index e2144ad..1f4f3be 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -60,7 +60,8 @@ public:
     };
   static const char *action_caption (_actions value);
 
-  void set_action (_actions, packageversion const & default_version);
+  void set_action (_actions, packageversion const & default_version,
+                   bool useraction = false);
   ActionList *list_actions(trusts const trust);
   void select_action (int id, trusts const deftrust);
   void toggle_action ();
-- 
2.21.0

Reply via email to