summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-06-03 09:50:06 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-06-03 09:50:06 +0200
commit81305a0b30cc12aa6d32081bbdcf930907ecfbbe (patch)
tree14369bed1e8bd905c7ee886d9316f5cfb06eeaeb
parente2c66de5c5e63d8400efb0522c31fbe1ec225f93 (diff)
deprecate AddSize with Multiplier as it is unused and switch to
boolean instead to handle the sizes more gracefully.
-rw-r--r--apt-pkg/depcache.cc73
-rw-r--r--apt-pkg/depcache.h5
-rw-r--r--debian/changelog2
3 files changed, 76 insertions, 4 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 6e0eeab5b..786b20ec0 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -407,8 +407,11 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
/*}}}*/
// DepCache::AddSizes - Add the packages sizes to the counters /*{{{*/
// ---------------------------------------------------------------------
-/* Call with Mult = -1 to preform the inverse opration */
-void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
+/* Call with Mult = -1 to preform the inverse opration
+ The Mult increases the complexity of the calulations here and is unused -
+ or do we really have a usecase for removing the size of a package two
+ times? So let us replace it with a simple bool and be done with it… */
+__deprecated void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
{
StateCache &P = PkgState[Pkg->ID];
@@ -454,6 +457,72 @@ void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
}
}
/*}}}*/
+// DepCache::AddSizes - Add the packages sizes to the counters /*{{{*/
+// ---------------------------------------------------------------------
+/* Call with Inverse = true to preform the inverse opration */
+void pkgDepCache::AddSizes(const PkgIterator &Pkg, bool const &Inverse)
+{
+ StateCache &P = PkgState[Pkg->ID];
+
+ if (Pkg->VersionList == 0)
+ return;
+
+ if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
+ P.Keep() == true)
+ return;
+
+ // Compute the size data
+ if (P.NewInstall() == true)
+ {
+ if (Inverse == false) {
+ iUsrSize += P.InstVerIter(*this)->InstalledSize;
+ iDownloadSize += P.InstVerIter(*this)->Size;
+ } else {
+ iUsrSize -= P.InstVerIter(*this)->InstalledSize;
+ iDownloadSize -= P.InstVerIter(*this)->Size;
+ }
+ return;
+ }
+
+ // Upgrading
+ if (Pkg->CurrentVer != 0 &&
+ (P.InstallVer != (Version *)Pkg.CurrentVer() ||
+ (P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0)
+ {
+ if (Inverse == false) {
+ iUsrSize -= Pkg.CurrentVer()->InstalledSize;
+ iUsrSize += P.InstVerIter(*this)->InstalledSize;
+ iDownloadSize += P.InstVerIter(*this)->Size;
+ } else {
+ iUsrSize -= P.InstVerIter(*this)->InstalledSize;
+ iUsrSize += Pkg.CurrentVer()->InstalledSize;
+ iDownloadSize -= P.InstVerIter(*this)->Size;
+ }
+ return;
+ }
+
+ // Reinstall
+ if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack &&
+ P.Delete() == false)
+ {
+ if (Inverse == false)
+ iDownloadSize += P.InstVerIter(*this)->Size;
+ else
+ iDownloadSize -= P.InstVerIter(*this)->Size;
+ return;
+ }
+
+ // Removing
+ if (Pkg->CurrentVer != 0 && P.InstallVer == 0)
+ {
+ if (Inverse == false)
+ iUsrSize -= Pkg.CurrentVer()->InstalledSize;
+ else
+ iUsrSize += Pkg.CurrentVer()->InstalledSize;
+ return;
+ }
+}
+ /*}}}*/
// DepCache::AddStates - Add the package to the state counter /*{{{*/
// ---------------------------------------------------------------------
/* This routine is tricky to use, you must make sure that it is never
diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h
index 3decc7a5f..d4258438f 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -321,8 +321,9 @@ class pkgDepCache : protected pkgCache::Namespace
void Update(PkgIterator const &P);
// Count manipulators
- void AddSizes(const PkgIterator &Pkg,signed long Mult = 1);
- inline void RemoveSizes(const PkgIterator &Pkg) {AddSizes(Pkg,-1);};
+ void AddSizes(const PkgIterator &Pkg, bool const &Invert = false);
+ inline void RemoveSizes(const PkgIterator &Pkg) {AddSizes(Pkg, true);};
+ void AddSizes(const PkgIterator &Pkg,signed long Mult) __deprecated;
void AddStates(const PkgIterator &Pkg,int Add = 1);
inline void RemoveStates(const PkgIterator &Pkg) {AddStates(Pkg,-1);};
diff --git a/debian/changelog b/debian/changelog
index e153027b3..2be956752 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ apt (0.7.26~exp6) UNRELEASED; urgency=low
- switch {,Install-}Size to unsigned long long
* apt-pkg/depcache.cc:
- deal with long long, not with int to remove 2GB Limit (LP: #250909)
+ - deprecate AddSize with Multiplier as it is unused and switch to
+ boolean instead to handle the sizes more gracefully.
-- David Kalnischkies <kalnischkies@gmail.com> Thu, 03 Jun 2010 09:19:01 +0200