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

Daniel Burrows dburrows@costa.debian.org
Sat, 09 Apr 2005 19:05:28 +0000


Author: dburrows
Date: Sat Apr  9 19:05:25 2005
New Revision: 2969

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/problemresolver/aptitude_resolver.h
Log:
Drop self-conflicts from the exported dependencies.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sat Apr  9 19:05:25 2005
@@ -2,6 +2,10 @@
 
 	* src/generic/problemresolver/aptitude_resolver.h:
 
+	  Add code to drop self-conflicts.
+
+	* src/generic/problemresolver/aptitude_resolver.h:
+
 	  Drastically overhaul how Conflicts are handled.  Now each
 	  Conflicts line generates a separate dependency for every listed
 	  package *and* one dependency for each provider of every listed

Modified: branches/aptitude-0.3/aptitude/src/generic/problemresolver/aptitude_resolver.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/problemresolver/aptitude_resolver.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/problemresolver/aptitude_resolver.h	Sat Apr  9 19:05:25 2005
@@ -661,17 +661,28 @@
     // Advance to the next valid dep (inclusive of dep).
     void normalize()
     {
-      while(dep.end() && !pkg.end())
+      // If prv_open, we are iterating over the Provides of something
+      // upon which a package depends.  This is a good situation
+      // *unless* we ran out of Provides or we have an indirect
+      // self-conflict.
+      if(prv_open)
 	{
-	  // If prv_open, we are iterating over the Provides of
-	  // something upon which a package depends.  This is a good
-	  // situation *unless* we ran out of Provides.
-	  if(prv_open && prv.end())
-	    prv_open=false;
+	  assert(!dep.end());
+	  assert(dep->Type == pkgCache::Dep::Conflicts);
 
-	  if(prv_open)
-	    return;
+	  while(!prv.end() && prv.OwnerPkg()==dep.ParentPkg())
+	    ++prv;
 
+	  if(prv.end())
+	    {
+	      prv_open=false;
+	      ++dep;
+	    }
+	}
+
+      // Now, if we ran our of deps, try to find another one.
+      while(dep.end() && !pkg.end())
+	{
 	  while(dep.end() && !ver.end())
 	    {
 	      // Since dep is an end iterator, advance at least
@@ -692,6 +703,11 @@
 		    dep=ver.DependsList();
 		}
 	    }
+
+	  // Avoid direct self-deps. (self-conflicts in particular,
+	  // but a non-conflict self-dep is pointless)
+	  while(!dep.end() && dep.ParentPkg() == dep.TargetPkg())
+	    ++dep;
 	}
     }
   public:
@@ -717,7 +733,7 @@
     {
       assert(!dep.end());
 
-      // If the Provides list is open, push it.
+      // If the Provides list is open, advance it.
       if(!prv.end())
 	++prv;
       // otherwise, if we aren't trying to iterate over a Provides
@@ -808,17 +824,22 @@
 	  // trivially broken (i.e., without following provides).
 	  if(!prv_open)
 	    {
-	      pkgCache::VerIterator ver=(*apt_cache_file)[the_dep.TargetPkg()].InstVerIter(*apt_cache_file);
+	      // If it's a direct self-conflict, jump into provides
+	      // right away.
+	      if(the_dep.TargetPkg() != the_dep.ParentPkg())
+		{
+		  pkgCache::VerIterator ver=(*apt_cache_file)[the_dep.TargetPkg()].InstVerIter(*apt_cache_file);
 
-	      if(!ver.end() &&
-		 (!the_dep.TargetVer() ||
-		  (ver.VerStr() &&
-		   _system->VS->CheckDep(ver.VerStr(),
-					 the_dep->CompareOp,
-					 the_dep.TargetVer()))))
-		// OK, the dep is broken without provides, no need to
-		// descend.
-		return;
+		  if(!ver.end() &&
+		     (!the_dep.TargetVer() ||
+		      (ver.VerStr() &&
+		       _system->VS->CheckDep(ver.VerStr(),
+					     the_dep->CompareOp,
+					     the_dep.TargetVer()))))
+		    // OK, the dep is broken without provides, no need
+		    // to descend.
+		    return;
+		}
 
 	      prv_open=true;
 	      prv=the_dep.TargetPkg().ProvidesList();
@@ -830,17 +851,21 @@
 	  // that matches.
 	  while(!prv.end())
 	    {
-	      // First, is the providing version going to be
-	      // installed?
-	      if((*apt_cache_file)[prv.OwnerPkg()].InstVerIter(*apt_cache_file) == prv.OwnerVer())
+	      // Ignore indirect self-conflicts.
+	      if(prv.OwnerPkg() != the_dep.TargetPkg())
 		{
-		  // Ok, does it match the version string?
-		  if(!the_dep.TargetVer() ||
-		     (prv.ProvideVersion() &&
-		      _system->VS->CheckDep(prv.ProvideVersion(),
-					    the_dep->CompareOp,
-					    the_dep.TargetVer())))
-		    return;
+		  // First, is the providing version going to be
+		  // installed?
+		  if((*apt_cache_file)[prv.OwnerPkg()].InstVerIter(*apt_cache_file) == prv.OwnerVer())
+		    {
+		      // Ok, does it match the version string?
+		      if(!the_dep.TargetVer() ||
+			 (prv.ProvideVersion() &&
+			  _system->VS->CheckDep(prv.ProvideVersion(),
+						the_dep->CompareOp,
+						the_dep.TargetVer())))
+			return;
+		    }
 		}
 
 	      ++prv;
@@ -849,7 +874,8 @@
 	  // Control should never reach this point because if a
 	  // Conflicts is InstBroken, then SOMETHING providing the
 	  // conflicted name should be planned to be installed.
-	  assert(!prv.end());
+	  if(prv.end())
+	    normalize();
 	}
     }
   public: