]> git.saurik.com Git - apt.git/commitdiff
factor out the detection of self-conflicts into Dep::IsIgnorable
authorDavid Kalnischkies <kalnischkies@gmail.com>
Fri, 13 Jan 2012 14:45:08 +0000 (15:45 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Fri, 13 Jan 2012 14:45:08 +0000 (15:45 +0100)
apt-pkg/cacheiterators.h
apt-pkg/depcache.cc
apt-pkg/packagemanager.cc
apt-pkg/pkgcache.cc

index 5382f3838a0475f77537326d36f147bfc78e7b3b..e6a0fddb0667baa32570000db18a5debebcc3852 100644 (file)
@@ -283,6 +283,8 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
        inline bool Reverse() const {return Type == DepRev;};
        bool IsCritical() const;
        bool IsNegative() const;
        inline bool Reverse() const {return Type == DepRev;};
        bool IsCritical() const;
        bool IsNegative() const;
+       bool IsIgnorable(PrvIterator const &Prv) const;
+       bool IsIgnorable(PkgIterator const &Pkg) const;
        void GlobOr(DepIterator &Start,DepIterator &End);
        Version **AllTargets() const;
        bool SmartTargetPkg(PkgIterator &Result) const;
        void GlobOr(DepIterator &Start,DepIterator &End);
        Version **AllTargets() const;
        bool SmartTargetPkg(PkgIterator &Result) const;
index 3c6dc4325ff4748748ad71a683cb75614a463f28..0851597111cff81a8cb7ba9ee59075a26d53c162 100644 (file)
@@ -371,19 +371,10 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
    
    // Check the providing packages
    PrvIterator P = Dep.TargetPkg().ProvidesList();
    
    // Check the providing packages
    PrvIterator P = Dep.TargetPkg().ProvidesList();
-   PkgIterator Pkg = Dep.ParentPkg();
    for (; P.end() != true; ++P)
    {
    for (; P.end() != true; ++P)
    {
-      if (Dep.IsNegative() == true)
-      {
-        /* Provides may never be applied against the same package (or group)
-           if it is a conflicts. See the comment above. */
-        if (P.OwnerPkg()->Group == Pkg->Group)
-           continue;
-        // Implicit group-conflicts should not be applied on providers of other groups
-        if (Pkg->Group == Dep.TargetPkg()->Group && P.OwnerPkg()->Group != Pkg->Group)
-           continue;
-      }
+      if (Dep.IsIgnorable(P) == true)
+        continue;
 
       // Check if the provides is a hit
       if (Type == NowVersion)
 
       // Check if the provides is a hit
       if (Type == NowVersion)
index 4f97627016009e5a4b3a2c19bde9367e482cac65..c9d7a3024c778750ba35d0849fdcb3d57c1132cf 100644 (file)
@@ -250,7 +250,7 @@ bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D,
         continue;
       
       // Ignore self conflicts, ignore conflicts from irrelevent versions
         continue;
       
       // Ignore self conflicts, ignore conflicts from irrelevent versions
-      if (D.ParentPkg() == Pkg || D.ParentVer() != D.ParentPkg().CurrentVer())
+      if (D.IsIgnorable(Pkg) || D.ParentVer() != D.ParentPkg().CurrentVer())
         continue;
       
       if (Cache.VS().CheckDep(Ver,D->CompareOp,D.TargetVer()) == false)
         continue;
       
       if (Cache.VS().CheckDep(Ver,D->CompareOp,D.TargetVer()) == false)
index 5361696d08a423d830c8379a95be8ffb46d56607..997c70768adb192ea89c5be5974b74ec7c1d5c19 100644 (file)
@@ -619,13 +619,12 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
       // Walk along the actual package providing versions
       for (VerIterator I = DPkg.VersionList(); I.end() == false; ++I)
       {
       // Walk along the actual package providing versions
       for (VerIterator I = DPkg.VersionList(); I.end() == false; ++I)
       {
-        if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false)
+        if (IsIgnorable(I.ParentPkg()) == true)
            continue;
 
            continue;
 
-        if (IsNegative() == true &&
-            ParentPkg() == I.ParentPkg())
+        if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false)
            continue;
            continue;
-        
+
         Size++;
         if (Res != 0)
            *End++ = I;
         Size++;
         if (Res != 0)
            *End++ = I;
@@ -634,19 +633,11 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
       // Follow all provides
       for (PrvIterator I = DPkg.ProvidesList(); I.end() == false; ++I)
       {
       // Follow all provides
       for (PrvIterator I = DPkg.ProvidesList(); I.end() == false; ++I)
       {
-        if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false)
+        if (IsIgnorable(I) == true)
            continue;
 
            continue;
 
-        if (IsNegative() == true)
-        {
-           /* Provides may never be applied against the same package (or group)
-              if it is a conflicts. See the comment above. */
-           if (I.OwnerPkg()->Group == ParentPkg()->Group)
-              continue;
-           // Implicit group-conflicts should not be applied on providers of other groups
-           if (ParentPkg()->Group == TargetPkg()->Group && I.OwnerPkg()->Group != ParentPkg()->Group)
-              continue;
-        }
+        if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false)
+           continue;
 
         Size++;
         if (Res != 0)
 
         Size++;
         if (Res != 0)
@@ -689,6 +680,34 @@ void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End)
    }
 }
                                                                        /*}}}*/
    }
 }
                                                                        /*}}}*/
+// DepIterator::IsIgnorable - should this packag/providr be ignored?   /*{{{*/
+// ---------------------------------------------------------------------
+/* Deps like self-conflicts should be ignored as well as implicit conflicts
+   on virtual packages. */
+bool pkgCache::DepIterator::IsIgnorable(PkgIterator const &Pkg) const
+{
+   if (ParentPkg() == TargetPkg())
+      return IsNegative();
+
+   return false;
+}
+bool pkgCache::DepIterator::IsIgnorable(PrvIterator const &Prv) const
+{
+   if (IsNegative() == false)
+      return false;
+
+   PkgIterator const Pkg = ParentPkg();
+   /* Provides may never be applied against the same package (or group)
+      if it is a conflicts. See the comment above. */
+   if (Prv.OwnerPkg()->Group == Pkg->Group)
+      return true;
+   // Implicit group-conflicts should not be applied on providers of other groups
+   if (Pkg->Group == TargetPkg()->Group && Prv.OwnerPkg()->Group != Pkg->Group)
+      return true;
+
+   return false;
+}
+                                                                       /*}}}*/
 // ostream operator to handle string representation of a dependecy     /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 // ostream operator to handle string representation of a dependecy     /*{{{*/
 // ---------------------------------------------------------------------
 /* */