diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2012-01-13 15:45:08 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2012-01-13 15:45:08 +0100 |
commit | 854341141df83c767bb4310e9e6084c5a4bff7f7 (patch) | |
tree | cb17502753a5c11bb14781f7288a79635b18fd5a | |
parent | 5f909b67fb903f700df1bd6242ada86d58c0b068 (diff) |
factor out the detection of self-conflicts into Dep::IsIgnorable
-rw-r--r-- | apt-pkg/cacheiterators.h | 2 | ||||
-rw-r--r-- | apt-pkg/depcache.cc | 13 | ||||
-rw-r--r-- | apt-pkg/packagemanager.cc | 2 | ||||
-rw-r--r-- | apt-pkg/pkgcache.cc | 49 |
4 files changed, 39 insertions, 27 deletions
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 5382f3838..e6a0fddb0 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -283,6 +283,8 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> { 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; diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 3c6dc4325..085159711 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -371,19 +371,10 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res) // Check the providing packages PrvIterator P = Dep.TargetPkg().ProvidesList(); - PkgIterator Pkg = Dep.ParentPkg(); 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) diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 4f9762701..c9d7a3024 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -250,7 +250,7 @@ bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D, 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) diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 5361696d0..997c70768 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -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) { - if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false) + if (IsIgnorable(I.ParentPkg()) == true) continue; - if (IsNegative() == true && - ParentPkg() == I.ParentPkg()) + if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false) continue; - + 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) { - if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false) + if (IsIgnorable(I) == true) 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) @@ -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 /*{{{*/ // --------------------------------------------------------------------- /* */ |