Fix computation of pattern status (bnc#864412)
authorMichael Andres <ma@suse.de>
Thu, 20 Feb 2014 22:42:59 +0000 (23:42 +0100)
committerMichael Andres <ma@suse.de>
Thu, 20 Feb 2014 22:42:59 +0000 (23:42 +0100)
src/info.cc
src/search.cc
tests/SolverRequester_test.cc

index f5d19a1..b850924 100644 (file)
@@ -343,7 +343,7 @@ void printPatternInfo(Zypper & zypper, const ui::Selectable & s)
 
   printNVA(pool_item.resolvable());
 
-  cout << _("Installed: ") << (pool_item.isSatisfied() ? _("Yes") : _("No")) << endl;
+  cout << _("Installed: ") << (s.hasInstalledObj() ? _("Yes") : _("No")) << endl;
   cout << _("Visible to User: ") << (pool_item.resolvable()->asKind<Pattern>()->userVisible() ? _("Yes") : _("No")) << endl;
 
   printSummaryDesc(pool_item.resolvable());
index 846660e..bc802a3 100644 (file)
@@ -443,18 +443,16 @@ static void list_patterns_xml(Zypper & zypper)
   bool installed_only = zypper.cOpts().count("installed-only");
   bool notinst_only = zypper.cOpts().count("uninstalled-only");
 
-  ResPool::byKind_iterator
-    it = God->pool().byKindBegin(ResKind::pattern),
-    e  = God->pool().byKindEnd(ResKind::pattern);
-  for (; it != e; ++it )
+  for_( it, God->pool().byKindBegin<Pattern>(), God->pool().byKindEnd<Pattern>() )
   {
-    if (it->isSatisfied() && notinst_only)
+    bool isInstalled = it->status().isInstalled();
+    if ( isInstalled && notinst_only && !installed_only )
       continue;
-    else if (!it->isSatisfied() && installed_only)
+    if ( !isInstalled && installed_only && !notinst_only )
       continue;
 
     Pattern::constPtr pattern = asKind<Pattern>(it->resolvable());
-    cout << asXML(*pattern, it->isSatisfied()) << endl;
+    cout << asXML(*pattern, isInstalled) << endl;
   }
 
   cout << "</pattern-list>" << endl;
@@ -477,14 +475,12 @@ static void list_pattern_table(Zypper & zypper)
   bool installed_only = zypper.cOpts().count("installed-only");
   bool notinst_only = zypper.cOpts().count("uninstalled-only");
 
-  ResPool::byKind_iterator
-    it = God->pool().byKindBegin(ResKind::pattern),
-    e  = God->pool().byKindEnd(ResKind::pattern);
-  for (; it != e; ++it )
+  for_( it, God->pool().byKindBegin<Pattern>(), God->pool().byKindEnd<Pattern>() )
   {
-    if (it->isSatisfied() && notinst_only)
+    bool isInstalled = it->status().isInstalled();
+    if ( isInstalled && notinst_only && !installed_only )
       continue;
-    else if (!it->isSatisfied() && installed_only)
+    else if ( !isInstalled && installed_only && !notinst_only )
       continue;
 
     Pattern::constPtr pattern = asKind<Pattern>(it->resolvable());
@@ -493,7 +489,7 @@ static void list_pattern_table(Zypper & zypper)
       continue;
 
     TableRow tr;
-    tr << (it->isSatisfied() ? "i" : "");
+    tr << (isInstalled ? "i" : "");
     tr << pattern->name () << pattern->edition().asString();
     if (!zypper.globalOpts().is_rug_compatible)
     {
index 8274017..a889e98 100644 (file)
@@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(setup)
   test.loadRepo(repo);
   //test.loadRepo(TESTS_SRC_DIR "/data/openSUSE-11.1_updates", "upd");
 
-  // resolve pool so that the satisfied status of patches/patterns becomes known
+  // resolve pool so that the satisfied status of pseudo-installed kinds becomes known
   zypp::getZYpp()->resolver()->resolvePool();
 }