From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17729 invoked by alias); 7 Jun 2018 17:37:35 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 17589 invoked by uid 89); 7 Jun 2018 17:37:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=preparation, uninstall, refresh, spurious X-HELO: limerock03.mail.cornell.edu Received: from limerock03.mail.cornell.edu (HELO limerock03.mail.cornell.edu) (128.84.13.243) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Jun 2018 17:37:31 +0000 X-CornellRouted: This message has been Routed already. Received: from authusersmtp.mail.cornell.edu (granite4.serverfarm.cornell.edu [10.16.197.9]) by limerock03.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id w57HbTt1028544; Thu, 7 Jun 2018 13:37:29 -0400 Received: from nothing.nyroc.rr.com (mta-68-175-129-7.twcny.rr.com [68.175.129.7] (may be forged)) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id w57HbMLS004317 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 7 Jun 2018 13:37:29 -0400 From: Ken Brown To: cygwin-apps@cygwin.com Subject: [PATCH setup v2 1/2] Improve the preparation of the package database Date: Thu, 07 Jun 2018 17:37:00 -0000 Message-Id: <20180607173724.5972-2-kbrown@cornell.edu> In-Reply-To: <20180607173724.5972-1-kbrown@cornell.edu> References: <20180607173724.5972-1-kbrown@cornell.edu> X-PMX-Cornell-Gauge: Gauge=XXXXX X-PMX-CORNELL-AUTH-RESULTS: dkim-out=none; X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00006.txt.bz2 Introduce a new function packagedb::noChanges() to set the database to a "no changes requested" state. Call it the first time the chooser page is activated, before calling ChooserPage::applyCommandLinePackageSelection(). Also use it to simplify the code in two places. Remove code from ChooserPage::changeTrust() that was making changes to the database after ChooserPage::applyCommandLinePackageSelection() had already been called. --- choose.cc | 26 ++++++-------------------- libsolv.cc | 11 +++-------- package_db.cc | 12 ++++++++++++ package_db.h | 2 ++ 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/choose.cc b/choose.cc index 1249efa..51d2fb6 100644 --- a/choose.cc +++ b/choose.cc @@ -329,6 +329,7 @@ ChooserPage::OnActivate() { // Do things which should only happen once, but rely on packagedb being // ready to use, so OnInit() is too early + db.noChanges(); applyCommandLinePackageSelection(); initialUpdateState(); @@ -392,13 +393,7 @@ ChooserPage::keepClicked() { update_mode_id = IDC_CHOOSE_KEEP; packagedb db; - for (packagedb::packagecollection::iterator i = db.packages.begin (); - i != db.packages.end (); ++i) - { - packagemeta & pkg = *(i->second); - pkg.desired = pkg.installed; - pkg.pick(false); - } + db.noChanges(); chooser->refresh(); } @@ -431,20 +426,11 @@ ChooserPage::changeTrust(int button, bool test, bool initial) // usually we want to apply the solver to an empty task list to get the list // of packages to upgrade (if any) + // but initially we want a task list with any package changes caused by + // command line options if (initial) - { - // but initially we want a task list with any package changes caused by - // command line options - // (also note the installed version to avoid generating spurious taskKeep - // or taskSkip tasks) - for (packagedb::packagecollection::iterator p = db.packages.begin (); - p != db.packages.end (); ++p) - { - packagemeta *pkg = p->second; - pkg->default_version = pkg->installed; - } - q.setTasks(); - } + q.setTasks(); + db.defaultTrust(q, mode, test); // configure PickView so 'test' or 'curr' version is chosen when an diff --git a/libsolv.cc b/libsolv.cc index 2eb04e2..11394a2 100644 --- a/libsolv.cc +++ b/libsolv.cc @@ -658,14 +658,9 @@ void SolverSolution::trans2db() const { packagedb db; - // First reset all packages to the "no change" state - for (packagedb::packagecollection::iterator i = db.packages.begin(); - i != db.packages.end(); i++) - { - packagemeta *pkg = i->second; - pkg->desired = pkg->default_version = pkg->installed; - pkg->pick(false); - } + // First reset all packages to the "no changes" state + db.noChanges (); + // Now make changes according to trans. transErase requires some // care; it could either be a "plain" uninstall, or it could be // paired with a transInstall for an upgrade/downgrade or reinstall. diff --git a/package_db.cc b/package_db.cc index d12e841..9189e40 100644 --- a/package_db.cc +++ b/package_db.cc @@ -750,3 +750,15 @@ packagedb::prep() prepped = true; } + +void +packagedb::noChanges () +{ + for (packagecollection::iterator i = packages.begin(); + i != packages.end(); i++) + { + packagemeta *pkg = i->second; + pkg->desired = pkg->default_version = pkg->installed; + pkg->pick(false); + } +} diff --git a/package_db.h b/package_db.h index e500e4b..da73171 100644 --- a/package_db.h +++ b/package_db.h @@ -68,6 +68,8 @@ public: /* 0 on success */ int flush (); void prep(); + /* Set the database to a "no changes requested" state. */ + void noChanges (); packagemeta * findBinary (PackageSpecification const &) const; packageversion findBinaryVersion (PackageSpecification const &) const; -- 2.17.0