]> git.saurik.com Git - apt.git/commitdiff
convert a lot of places to use IsNegative instead of checking by hand
authorDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 11 May 2011 14:05:30 +0000 (16:05 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 11 May 2011 14:05:30 +0000 (16:05 +0200)
for the three different dependencies

apt-pkg/algorithms.cc
apt-pkg/depcache.cc
apt-pkg/orderlist.cc
apt-pkg/pkgcache.cc
cmdline/apt-cache.cc

index e7703ca93b0d41234d869a18f4fc14879e0a77dc..2dae4258a964c1935201235e7c3a72c1f26172d4 100644 (file)
@@ -101,9 +101,7 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
         DepIterator Start;
         DepIterator End;
         D.GlobOr(Start,End);
-        if (Start->Type == pkgCache::Dep::Conflicts ||
-            Start->Type == pkgCache::Dep::DpkgBreaks ||
-            Start->Type == pkgCache::Dep::Obsoletes ||
+        if (Start.IsNegative() == true ||
             End->Type == pkgCache::Dep::PreDepends)
          {
            if ((Sim[End] & pkgDepCache::DepGInstall) == 0)
@@ -695,9 +693,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
            {
               /* We let the algorithm deal with conflicts on its next iteration,
                it is much smarter than us */
-              if (Start->Type == pkgCache::Dep::Conflicts || 
-                  Start->Type == pkgCache::Dep::DpkgBreaks || 
-                  Start->Type == pkgCache::Dep::Obsoletes)
+              if (Start.IsNegative() == true)
                   break;
               
               if (Debug == true)
@@ -926,9 +922,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
               if a package has a dep on another package that cant be found */
            SPtrArray<pkgCache::Version *> VList = Start.AllTargets();
            if (*VList == 0 && (Flags[I->ID] & Protected) != Protected &&
-               Start->Type != pkgCache::Dep::Conflicts &&
-               Start->Type != pkgCache::Dep::DpkgBreaks &&
-               Start->Type != pkgCache::Dep::Obsoletes &&
+               Start.IsNegative() == false &&
                Cache[I].NowBroken() == false)
            {          
               if (InOr == true)
@@ -953,10 +947,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
                   at is not the currently selected version of the 
                   package, which means it is not necessary to 
                   remove/keep */
-               if (Cache[Pkg].InstallVer != Ver &&
-                   (Start->Type == pkgCache::Dep::Conflicts ||
-                    Start->Type == pkgCache::Dep::DpkgBreaks ||
-                    Start->Type == pkgCache::Dep::Obsoletes)) 
+               if (Cache[Pkg].InstallVer != Ver && Start.IsNegative() == true)
                {
                   if (Debug) 
                      clog << "  Conflicts//Breaks against version " 
@@ -974,9 +965,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
                  fiddle with the VList package */
               if (Scores[I->ID] <= Scores[Pkg->ID] ||
                   ((Cache[Start] & pkgDepCache::DepNow) == 0 &&
-                   End->Type != pkgCache::Dep::Conflicts &&
-                   End->Type != pkgCache::Dep::DpkgBreaks &&
-                   End->Type != pkgCache::Dep::Obsoletes))
+                   End.IsNegative() == false))
               {
                  // Try a little harder to fix protected packages..
                  if ((Flags[I->ID] & Protected) == Protected)
@@ -1083,10 +1072,8 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
            }
 
            // Hm, nothing can possibly satisify this dep. Nuke it.
-           if (VList[0] == 0 && 
-               Start->Type != pkgCache::Dep::Conflicts &&
-               Start->Type != pkgCache::Dep::DpkgBreaks &&
-               Start->Type != pkgCache::Dep::Obsoletes &&
+           if (VList[0] == 0 &&
+               Start.IsNegative() == false &&
                (Flags[I->ID] & Protected) != Protected)
            {
               bool Installed = Cache[I].Install();
@@ -1132,9 +1119,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
               Change = true;
               if ((Cache[J->Dep] & pkgDepCache::DepGNow) == 0)
               {
-                 if (J->Dep->Type == pkgCache::Dep::Conflicts || 
-                     J->Dep->Type == pkgCache::Dep::DpkgBreaks ||
-                     J->Dep->Type == pkgCache::Dep::Obsoletes)
+                 if (J->Dep.IsNegative() == true)
                  {
                     if (Debug == true)
                        clog << "  Fixing " << I.FullName(false) << " via remove of " << J->Pkg.FullName(false) << endl;
index 34ead1726cc3665f145a70f85d73e305aa1d31b5..18b6d160a133865cb7e7f27330028e291fccf733 100644 (file)
@@ -339,8 +339,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
    /* Check simple depends. A depends -should- never self match but 
       we allow it anyhow because dpkg does. Technically it is a packaging
       bug. Conflicts may never self match */
-   if (Dep.TargetPkg() != Dep.ParentPkg() ||
-       (Dep->Type != Dep::Conflicts && Dep->Type != Dep::DpkgBreaks && Dep->Type != Dep::Obsoletes))
+   if (Dep.TargetPkg() != Dep.ParentPkg() || Dep.IsNegative() == false)
    {
       PkgIterator Pkg = Dep.TargetPkg();
       // Check the base package
@@ -370,8 +369,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
    {
       /* 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 &&
-         (Dep->Type == Dep::Conflicts || Dep->Type == Dep::DpkgBreaks))
+      if (P.OwnerPkg()->Group == Pkg->Group && Dep.IsNegative() == true)
         continue;
       
       // Check if the provides is a hit
@@ -594,9 +592,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &V)
 
       /* Invert for Conflicts. We have to do this twice to get the
          right sense for a conflicts group */
-      if (D->Type == Dep::Conflicts ||
-         D->Type == Dep::DpkgBreaks ||
-         D->Type == Dep::Obsoletes)
+      if (D.IsNegative() == true)
         State = ~State;
       
       // Add to the group if we are within an or..
@@ -607,9 +603,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &V)
         Group = 0;
       
       // Invert for Conflicts
-      if (D->Type == Dep::Conflicts ||
-         D->Type == Dep::DpkgBreaks ||
-         D->Type == Dep::Obsoletes)
+      if (D.IsNegative() == true)
         State = ~State;
    }    
 }
@@ -742,9 +736,7 @@ void pkgDepCache::Update(OpProgress *Prog)
               Group = 0;
 
            // Invert for Conflicts
-           if (D->Type == Dep::Conflicts ||
-               D->Type == Dep::DpkgBreaks ||
-               D->Type == Dep::Obsoletes)
+           if (D.IsNegative() == true)
               State = ~State;
         }
       }
@@ -774,9 +766,7 @@ void pkgDepCache::Update(DepIterator D)
       State = DependencyState(D);
     
       // Invert for Conflicts
-      if (D->Type == Dep::Conflicts ||
-         D->Type == Dep::DpkgBreaks ||
-         D->Type == Dep::Obsoletes)
+      if (D.IsNegative() == true)
         State = ~State;
 
       RemoveStates(D.ParentPkg());
@@ -1222,8 +1212,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
       /* For conflicts we just de-install the package and mark as auto,
          Conflicts may not have or groups.  For dpkg's Breaks we try to
          upgrade the package. */
-      if (Start->Type == Dep::Conflicts || Start->Type == Dep::Obsoletes ||
-         Start->Type == Dep::DpkgBreaks)
+      if (Start.IsNegative() == true)
       {
         for (Version **I = List; *I != 0; I++)
         {
index eab05a4975341725fea26bbc4e6db959a1110110..ba43bc7572cde5057b70848b42032e2b1f8cdea1 100644 (file)
@@ -507,15 +507,11 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
       if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)
         continue;
       
-      if (D->Type != pkgCache::Dep::Conflicts &&
-         D->Type != pkgCache::Dep::DpkgBreaks &&
-         D->Type != pkgCache::Dep::Obsoletes &&
+      if (D.IsNegative() == false &&
          Cache[Pkg].InstallVer != *I)
         continue;
       
-      if ((D->Type == pkgCache::Dep::Conflicts ||
-          D->Type == pkgCache::Dep::DpkgBreaks ||
-          D->Type == pkgCache::Dep::Obsoletes) &&
+      if (D.IsNegative() == true &&
          (Version *)Pkg.CurrentVer() != *I)
         continue;
       
@@ -647,9 +643,7 @@ bool pkgOrderList::DepUnPackCrit(DepIterator D)
       {
         /* Forward critical dependencies MUST be correct before the 
            package can be unpacked. */
-        if (D->Type != pkgCache::Dep::Conflicts &&
-            D->Type != pkgCache::Dep::DpkgBreaks &&
-            D->Type != pkgCache::Dep::Obsoletes &&
+        if (D.IsNegative() == false &&
             D->Type != pkgCache::Dep::PreDepends)
            continue;
                                 
@@ -1077,9 +1071,7 @@ bool pkgOrderList::CheckDep(DepIterator D)
       
       /* Conflicts requires that all versions are not present, depends
          just needs one */
-      if (D->Type != pkgCache::Dep::Conflicts && 
-         D->Type != pkgCache::Dep::DpkgBreaks && 
-         D->Type != pkgCache::Dep::Obsoletes)
+      if (D.IsNegative() == false)
       {
         /* Try to find something that does not have the after flag set
            if at all possible */
index 6c12b4581eefaf5f664ddfde6c03c2b700bceff5..38e4e904ed41133ae2feb07b9bdd94fad8584354 100644 (file)
@@ -521,9 +521,7 @@ std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const
    conflicts (including dpkg's Breaks fields). */
 bool pkgCache::DepIterator::IsCritical() const
 {
-   if (S->Type == pkgCache::Dep::Conflicts ||
-       S->Type == pkgCache::Dep::DpkgBreaks ||
-       S->Type == pkgCache::Dep::Obsoletes ||
+   if (IsNegative() == true ||
        S->Type == pkgCache::Dep::Depends ||
        S->Type == pkgCache::Dep::PreDepends)
       return true;
@@ -618,9 +616,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
         if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false)
            continue;
 
-        if ((S->Type == pkgCache::Dep::Conflicts ||
-             S->Type == pkgCache::Dep::DpkgBreaks ||
-             S->Type == pkgCache::Dep::Obsoletes) &&
+        if (IsNegative() == true &&
             ParentPkg() == I.ParentPkg())
            continue;
         
@@ -635,9 +631,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
         if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false)
            continue;
         
-        if ((S->Type == pkgCache::Dep::Conflicts ||
-             S->Type == pkgCache::Dep::DpkgBreaks ||
-             S->Type == pkgCache::Dep::Obsoletes) &&
+        if (IsNegative() == true &&
             ParentPkg() == I.OwnerPkg())
            continue;
         
index f66c22c20715cc1062c7bd17d7c02a2de6c6d863..232bb93ec670eafd23b432248c1c631af00f8a71 100644 (file)
@@ -121,9 +121,7 @@ bool ShowUnMet(pkgCache::VerIterator const &V, bool const &Important)
                  continue;
 
            // Skip conflicts and replaces
-           if (End->Type == pkgCache::Dep::DpkgBreaks ||
-               End->Type == pkgCache::Dep::Replaces ||
-               End->Type == pkgCache::Dep::Conflicts)
+           if (End.IsNegative() == true)
               continue;
 
            // Verify the or group
@@ -848,10 +846,7 @@ bool XVcg(CommandLine &CmdL)
               {
                  /* If a conflicts does not meet anything in the database
                     then show the relation but do not recurse */
-                 if (Hit == false && 
-                     (D->Type == pkgCache::Dep::Conflicts ||
-                      D->Type == pkgCache::Dep::DpkgBreaks ||
-                      D->Type == pkgCache::Dep::Obsoletes))
+                 if (Hit == false && D.IsNegative() == true)
                  {
                     if (Show[D.TargetPkg()->ID] == None && 
                         Show[D.TargetPkg()->ID] != ToShow)
@@ -1060,9 +1055,7 @@ bool Dotty(CommandLine &CmdL)
               {
                  /* If a conflicts does not meet anything in the database
                     then show the relation but do not recurse */
-                 if (Hit == false && 
-                     (D->Type == pkgCache::Dep::Conflicts ||
-                      D->Type == pkgCache::Dep::Obsoletes))
+                 if (Hit == false && D.IsNegative() == true)
                  {
                     if (Show[D.TargetPkg()->ID] == None && 
                         Show[D.TargetPkg()->ID] != ToShow)
@@ -1082,6 +1075,7 @@ bool Dotty(CommandLine &CmdL)
               {
                  case pkgCache::Dep::Conflicts:
                  case pkgCache::Dep::Obsoletes:
+                 case pkgCache::Dep::DpkgBreaks:
                  printf("[color=springgreen];\n");
                  break;