[Aptitude-svn-commit] r3931 - in branches/aptitude-0.3/aptitude: . src/generic/problemresolver

Daniel Burrows dburrows at costa.debian.org
Fri Aug 19 22:34:46 UTC 2005


Author: dburrows
Date: Fri Aug 19 22:34:43 2005
New Revision: 3931

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
Log:
Better debug output, early branching for user requests.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Fri Aug 19 22:34:43 2005
@@ -1,5 +1,11 @@
 2005-08-19  Daniel Burrows  <dburrows at debian.org>
 
+	* src/generic/problemresolver/problemresolver.h:
+
+	  Improve debugging output (used to catch the below bug) and add
+	  early branching for user requests (should mean that if the user
+	  requests something impossible, we tell them ASAP).
+
 	* src/generic/aptitude_resolver_universe.cc:
 
 	  Fix solved_by(): it was returning "true" for most non-virtual

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	Fri Aug 19 22:34:43 2005
@@ -1080,9 +1080,14 @@
     for(typename std::set<version>::const_iterator ai = user_mandated.begin();
 	ai != user_mandated.end(); ++ai)
       {
+	version v = s.version_of(ai->get_package());
 	// If it's already being installed, then we're fine.
-	if(s.version_of(ai->get_package()) == *ai)
+	if(v == *ai)
 	  continue;
+	// Don't allow another version of this package to be
+	// installed.
+	else if(v != ai->get_package().current_version())
+	  return true;
 
 	// Check (very slowly) whether we made a decision where we had
 	// the opportunity to use this version (and of course didn't).
@@ -1092,7 +1097,7 @@
 	    {
 	      if(debug)
 		{
-		  std::cout << ai->get_package().get_name() << " version " << ai->get_name() << " is avoided by:" << std::endl;
+		  std::cout << ai->get_package().get_name() << " version " << ai->get_name() << " is avoided (when resolving " << si->second.d << ") by the solution:" << std::endl;
 		  s.dump(std::cout);
 		  std::cout << std::endl;
 		}
@@ -1104,6 +1109,32 @@
     return false;
   }
 
+  /** \return \b true if the resolution of the given dependency might
+   *                  be affected by a user constraint.
+   */
+  bool impinges_user_constraint(const dep &d) const
+  {
+    if(user_hardened.find(d) != user_hardened.end())
+      return true;
+
+    for(typename dep::solver_iterator si = d.solvers_begin();
+	!si.end(); ++si)
+      {
+	if(user_rejected.find(*si) != user_rejected.end())
+	  return true;
+
+	for(typename std::set<version>::iterator mi = user_mandated.begin();
+	    mi != user_mandated.end(); ++mi)
+	  {
+	    if(mi->get_package() == (*si).get_package())
+	      return true;
+	  }
+      }
+
+    return false;
+  }
+
+
   /** \return \b true if the given solution should be deferred. */
   bool should_defer(const solution &s) const
   {
@@ -1566,6 +1597,15 @@
 	return;
       }
 
+    // First, try to generate successors for the broken dependencies
+    // that are affected by user constraints (branching these off ASAP
+    // lets us keep the branching factor low and converge faster).
+    for(typename std::set<dep>::const_iterator bi=s.get_broken().begin();
+	bi!=s.get_broken().end() && (sols==0 || sols<max_successors); ++bi)
+      if(impinges_user_constraint(*bi))
+	generate_successors(s, *bi, sols);
+
+
     for(typename std::set<dep>::const_iterator bi=s.get_broken().begin();
 	bi!=s.get_broken().end() && (sols==0 || sols<max_successors); ++bi)
       generate_successors(s, *bi, sols);



More information about the Aptitude-svn-commit mailing list