- fix first column (i/v) of 'search' output
authorKlaus Kaempf <kkaempf@suse.de>
Mon, 20 Aug 2007 12:17:26 +0000 (12:17 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Mon, 20 Aug 2007 12:17:26 +0000 (12:17 +0000)
- r6759
- 0.8.14

VERSION.cmake
package/zypper.changes
src/zypper-search.cc
src/zypper-search.h

index 4488532..22a30db 100644 (file)
@@ -20,4 +20,4 @@
 
 SET(VERSION_MAJOR "0")
 SET(VERSION_MINOR "8")
-SET(VERSION_PATCH "13")
+SET(VERSION_PATCH "14")
index bd8205e..fddcf80 100644 (file)
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Mon Aug 20 14:16:20 CEST 2007 - kkaempf@suse.de
+
+- fix first column (i/v) of 'search' output
+- r6759
+- 0.8.14
+
+-------------------------------------------------------------------
 Mon Aug 20 13:55:53 CEST 2007 - kkaempf@suse.de
 
 - adapt to unified query API of libzypp-3.18.x
index 077d285..3fab189 100644 (file)
@@ -36,7 +36,8 @@ ZyppSearch::ZyppSearch (
     const vector<string> qstrings
     ) :
     _zypp(zypp), _options(options), _qstrings(qstrings), _query( _manager_options.repoCachePath ) {
-#if 0
+
+#if 0  // we don't search the pool but iterate on the cache directly, hence no repos needed
   // no repos warning
   if (gData.repos.empty()) {
     cerr << _("No repositories configured. Please add at least one"
@@ -45,9 +46,10 @@ ZyppSearch::ZyppSearch (
     exit(ZYPPER_EXIT_NO_REPOS); // TODO #define zypper error codes?
   }
 #endif
+
   setupRegexp();
   cacheInstalled();
-#if 0
+#if 0  // we iterate directly on the cache, no ResPool populate needed
   load_repo_resolvables(); // populates ResPool with resolvables from repos
 #endif
   // cache identification strings of source resolvables (used to check for
index ea05101..94bdcc4 100644 (file)
@@ -109,12 +109,21 @@ public:
       (_incl_kind_in_key ? pi.resolvable()->kind().asString() : "");
   }
 
+  std::string getKey( const zypp::data::ResObject_Ptr res ) const {
+    return res->name +
+      (_incl_kind_in_key ? res->kind.asString() : "");
+  }
+
   void addItem(const zypp::PoolItem & pi) { _items[getKey(pi)] = pi; }
 
   zypp::PoolItem & getItem(const zypp::PoolItem & pi) {
     return _items[getKey(pi)];
   }
   
+  zypp::PoolItem & getItem( const zypp::data::ResObject_Ptr res ) {
+    return _items[getKey( res )];
+  }
+  
   unsigned int size() {
     return _items.size();
   }
@@ -126,9 +135,8 @@ public:
   }
 
   /** defined for use as a functor for filling the hashmap in a for_each */ 
-  // FIXME: should be cache::ProcessResolvable
   bool operator()(const zypp::data::RecordId & id, const zypp::data::ResObject_Ptr res) {
-    // dummy
+    // dummy, since zypp::data::ResObject_Ptr is never 'installed'
     return true;
   }
 
@@ -152,12 +160,22 @@ public:
       pi.resolvable()->kind().asString() + pi.resolvable()->arch().asString();
   }
 
+  std::string getKey(const zypp::data::ResObject_Ptr res) const {
+    return res->name + res->edition.asString() +
+      res->kind.asString() + res->arch.asString();
+  }
+
   void addItem(const zypp::PoolItem & pi) { _items.insert(getKey(pi)); }
+  void addItem(const zypp::data::ResObject_Ptr res) { _items.insert(getKey(res)); }
 
   bool contains(const zypp::PoolItem & pi) {
     return _items.count(getKey(pi));
   }
 
+  bool contains(const zypp::data::ResObject_Ptr res) {
+    return _items.count(getKey(res));
+  }
+
   /** defined for use as a functor for filling the IdSet in a for_each */ 
   bool operator()(const zypp::PoolItem & pi) {
     addItem(pi);
@@ -165,9 +183,8 @@ public:
   }
 
   /** defined for use as a functor for filling the IdSet in a for_each */ 
-  // FIXME: should be cache::ProcessResolvable
   bool operator()(const zypp::data::RecordId & id, const zypp::data::ResObject_Ptr res) {
-    // dummy
+    addItem( res );
     return true;
   }
 
@@ -310,7 +327,7 @@ struct FillTable
     TableRow row;
 
     // add status to the result table
-    zypp::PoolItem inst_item; // = _icache->getItem(pool_item);
+    zypp::PoolItem inst_item = _icache->getItem( res );
     if (inst_item) {
       // check whether the pool item is installed...
       if (inst_item.resolvable()->edition() == res->edition &&