[Aptitude-devel] r3173 - in branches/aptitude-0.3/aptitude: . src/generic src/generic/problemresolver

Daniel Burrows dburrows@costa.debian.org
Thu, 28 Apr 2005 13:03:07 +0000


Author: dburrows
Date: Thu Apr 28 13:03:03 2005
New Revision: 3173

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/aptcache.cc
   branches/aptitude-0.3/aptitude/src/generic/aptcache.h
   branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
Log:
Allow package scores to be adjusted before the resolver is started.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Thu Apr 28 13:03:03 2005
@@ -1,3 +1,10 @@
+2005-04-28  Daniel Burrows  <dburrows@debian.org>
+
+	* src/generic/aptcache.cc, src/generic/aptcache.h, src/generic/problemresolver/problemresolver.h:
+
+	  Add provisions for adjusting package scores before running the
+	  resolver.
+
 2005-04-27  Daniel Burrows  <dburrows@debian.org>
 
 	* src/main.cc:

Modified: branches/aptitude-0.3/aptitude/src/generic/aptcache.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/aptcache.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/aptcache.cc	Thu Apr 28 13:03:03 2005
@@ -1491,6 +1491,17 @@
   return *solutions[selected_solution];
 }
 
+void aptitudeDepCache::tweak_score(const pkgCache::PkgIterator &pkg,
+				   const pkgCache::VerIterator &ver,
+				   int score)
+{
+  assert(resolver_exists());
+  assert(resolver->fresh());
+
+  resolver->add_version_score(aptitude_resolver_version(pkg, ver),
+			      score);
+}
+
 //////////////////// END PROBLEM RESOLVER INTERFACE ////////////////////
 
 aptitudeCacheFile::aptitudeCacheFile()

Modified: branches/aptitude-0.3/aptitude/src/generic/aptcache.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/aptcache.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/aptcache.h	Thu Apr 28 13:03:03 2005
@@ -449,6 +449,19 @@
    */
   const generic_solution<aptitude_universe> &previous_solution();
 
+  /** Tweak the resolver score of a particular package/version.  This
+   *  requires that resolver_exists() and that the resolver is "fresh"
+   *  (i.e., that next_solution() and current_solution() have never
+   *  been called)
+   *
+   *  \param pkg the package to adjust
+   *  \param ver the version to adjust
+   *  \param score an adjustment to be added to the score of pkg:ver
+   */
+  void tweak_score(const pkgCache::PkgIterator &pkg,
+		   const pkgCache::VerIterator &ver,
+		   int score);
+
   bool try_fix_broken(undo_group *undo);
   // Attempts to fix any broken packages, dumping the changes the problem
   // fixer creates into the given undo group.

Modified: branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h	Thu Apr 28 13:03:03 2005
@@ -808,10 +808,18 @@
       version_scores[i]=0;
   }
 
+  /** \return \b true if no solutions have been examined yet.
+   *  This implies that it is safe to modify package scores.
+   */
+  bool fresh() const
+  {
+    return open.empty() && !finished;
+  }
+
   /** \return \b true if the open queue is empty. */
   bool exhausted() const
   {
-    return open.empty();
+    return open.empty() && finished;
   }
 
   /** Tells the resolver how highly to value a particular package