From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28393 invoked by alias); 18 Feb 2015 15:28:05 -0000 Mailing-List: contact cygwin-apps-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-apps-cvs-owner@sourceware.org Received: (qmail 28375 invoked by uid 9078); 18 Feb 2015 15:28:05 -0000 Date: Wed, 18 Feb 2015 15:28:00 -0000 Message-ID: <20150218152805.28348.qmail@sourceware.org> From: corinna@sourceware.org To: cygwin-apps-cvs@sourceware.org Subject: [setup] branch master, updated. release_2.869-14-g10cac83 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 8f6b9284c332c2d1a9bcf2229ca790103f4494d5 X-Git-Newrev: 10cac838040424571f64442a46268a410fd4ebc7 X-SW-Source: 2015-q1/txt/msg00033.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=cygwin-setup.git;h=10cac838040424571f64442a46268a410fd4ebc7 commit 10cac838040424571f64442a46268a410fd4ebc7 Author: Corinna Vinschen Date: Wed Feb 18 16:26:13 2015 +0100 Choose curr package when user picks not yet installed package for the first time * PickPackageLine.cc (PickPackageLine::click): Call packagemeta::set_action with current trust level as argument. * package_meta.cc (packagemeta::set_action): Take trust level as argument. When the user picks a package for the first time (from "Skip"), pick the version matching the current trust level. Improve comments. * package_meta.h (class packagemeta): Add member user_picked. (packagemeta::packagemeta): Initialize user_picked to false. (packagemeta::set_action): Align prototype to above change. Diff: --- ChangeLog | 12 ++++++++++++ PickPackageLine.cc | 2 +- package_meta.cc | 29 +++++++++++++++++++++-------- package_meta.h | 14 ++++++++------ 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index bbc1def..bc6dd6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2015-02-18 Corinna Vinschen + + * PickPackageLine.cc (PickPackageLine::click): Call + packagemeta::set_action with current trust level as argument. + * package_meta.cc (packagemeta::set_action): Take trust level as + argument. When the user picks a package for the first time (from + "Skip"), pick the version matching the current trust level. Improve + comments. + * package_meta.h (class packagemeta): Add member user_picked. + (packagemeta::packagemeta): Initialize user_picked to false. + (packagemeta::set_action): Align prototype to above change. + 2015-02-16 Achim Gratz > * README: Adapt the documentation to the recent changes and some diff --git a/PickPackageLine.cc b/PickPackageLine.cc index 48c502e..60ece7f 100644 --- a/PickPackageLine.cc +++ b/PickPackageLine.cc @@ -126,7 +126,7 @@ PickPackageLine::click (int const myrow, int const ClickedRow, int const x) if (x >= theView.headers[theView.new_col].x - HMARGIN / 2 && x <= theView.headers[theView.new_col + 1].x - HMARGIN / 2) { - pkg.set_action (); + pkg.set_action (theView.deftrust); return 0; } if (x >= theView.headers[theView.bintick_col].x - HMARGIN / 2 diff --git a/package_meta.cc b/package_meta.cc index da5f3cb..c2e94eb 100644 --- a/package_meta.cc +++ b/package_meta.cc @@ -404,13 +404,15 @@ packagemeta::action_caption () const /* Set the next action given a current action. */ void -packagemeta::set_action () +packagemeta::set_action (trusts const trust) { + set::iterator i; + /* Keep the picked settings of the former desired version, if any, and make sure at least one of them is picked. If both are unpicked, pick the binary version. */ - bool source_picked = desired && desired.sourcePackage().picked(); - bool binary_picked = !desired || desired.picked() || !source_picked; + bool source_picked = desired && desired.sourcePackage().picked (); + bool binary_picked = !desired || desired.picked () || !source_picked; /* If we're on "Keep" on the installed version, and the version is available, switch to "Reinstall". */ @@ -421,14 +423,23 @@ packagemeta::set_action () return; } - set::iterator i; - /* From "Uninstall" switch to the first version. Otherwise switch to the - next version. */ if (!desired) - i = versions.begin(); + { + /* From "Uninstall" switch to the first version. From "Skip" switch to + the first version as well, unless the user picks for the first time. + In that case switch to the trustp version immediately. */ + if (installed || user_picked) + i = versions.begin (); + else + for (i = versions.begin (); + i != versions.end () && *i != trustp (false, trust); + ++i) + ; + } else { - for (i = versions.begin(); i != versions.end() && *i != desired; ++i) + /* Otherwise switch to the next version. */ + for (i = versions.begin (); i != versions.end () && *i != desired; ++i) ; ++i; } @@ -446,6 +457,8 @@ packagemeta::set_action () } else desired = packageversion (); + /* Memorize the fact that the user picked at least once. */ + user_picked = true; } int diff --git a/package_meta.h b/package_meta.h index 696e9dd..b24d4fc 100644 --- a/package_meta.h +++ b/package_meta.h @@ -34,15 +34,15 @@ class packagemeta public: static void ScanDownloadedFiles (bool); packagemeta (packagemeta const &); - packagemeta (const std::string& pkgname):name (pkgname), key(pkgname), installed_from (), + packagemeta (const std::string& pkgname) + : name (pkgname), key(pkgname), installed_from (), user_picked (false), architecture (), priority(), visited_(false) { } - packagemeta (const std::string& pkgname, - const std::string& installedfrom):name (pkgname), key(pkgname), - installed_from (installedfrom), - architecture (), priority(), visited_(false) + packagemeta (const std::string& pkgname, const std::string& installedfrom) + : name (pkgname), key(pkgname), installed_from (installedfrom), + user_picked (false), architecture (), priority(), visited_(false) { } @@ -77,7 +77,7 @@ public: static const _actions Install_action; static const _actions Reinstall_action; static const _actions Uninstall_action; - void set_action (); + void set_action (trusts const t); void set_action (_actions, packageversion const & default_version); void uninstall (); int set_requirements (trusts deftrust, size_t depth); @@ -135,6 +135,8 @@ public: const std::string getReadableCategoryList () const; std::set versions; + /* Did the user already pick a version at least once? */ + bool user_picked; /* which one is installed. */ packageversion installed; /* which one is listed as "prev" in our available packages db */