+
+// Policy::GetCandidateVer - Get the candidate install version /*{{{*/
+// ---------------------------------------------------------------------
+/* Evaluate the package pins and the default list to deteremine what the
+ best package is. */
+pkgCache::VerIterator pkgPolicy::GetCandidateVerNew(pkgCache::PkgIterator const &Pkg)
+{
+ // TODO: Replace GetCandidateVer()
+ pkgCache::VerIterator cand;
+ int candPriority = -1;
+ bool candInstalled = false;
+ pkgVersioningSystem *vs = Cache->VS;
+
+ for (pkgCache::VerIterator ver = Pkg.VersionList(); ver.end() == false; ver++) {
+ int priority = GetPriority(ver);
+ bool installed = ver->ID == Pkg.CurrentVer()->ID;
+
+ if (priority < candPriority)
+ continue;
+ if (priority < 1000
+ && (priority == candPriority || installed < candInstalled)
+ && (cand.IsGood() && vs->CmpVersion(ver.VerStr(), cand.VerStr()) < 0))
+ continue;
+
+ candPriority = priority;
+ candInstalled = installed;
+ cand = ver;
+ }
+
+ return cand;
+}