Index: pym/_emerge/FakeVartree.py |
diff --git a/pym/_emerge/FakeVartree.py b/pym/_emerge/FakeVartree.py |
index 977824c78433c9104d1b9e5900ea236bd39e484f..9e3dacae2e345880d37314be85fcd8ec301c64d2 100644 |
--- a/pym/_emerge/FakeVartree.py |
+++ b/pym/_emerge/FakeVartree.py |
@@ -100,6 +100,16 @@ class FakeVartree(vartree): |
pkg, self.dbapi, self._global_updates) |
return self._aux_get(pkg, wants) |
+ def cpv_discard(self, pkg): |
+ """ |
+ Discard a package from the fake vardb if it exists. |
diandersAtChromium
2011/03/22 02:57:59
Is pkg always a Package object? It's never a 4-tu
davidjames
2011/03/23 20:19:11
Nope, we don't need that functionality... that sai
|
+ """ |
+ old_pkg = self.dbapi.get(pkg) |
diandersAtChromium
2011/03/22 02:57:59
I would _love_ if it you added a docstring to Pack
davidjames
2011/03/23 20:19:11
That's a good idea for a followup CL.
|
+ if old_pkg: |
diandersAtChromium
2011/03/22 02:57:59
Should check for 'is None' or use 'if pkg in self.
davidjames
2011/03/23 20:19:11
Done.
|
+ self.dbapi.cpv_remove(old_pkg) |
+ self._pkg_cache.pop(old_pkg, None) |
+ self._aux_get_history.discard(old_pkg.cpv) |
+ |
def sync(self, acquire_lock=1): |
""" |
Call this method to synchronize state with the real vardb |
@@ -141,9 +151,7 @@ class FakeVartree(vartree): |
# Remove any packages that have been uninstalled. |
for pkg in list(pkg_vardb): |
if pkg.cpv not in current_cpv_set: |
- pkg_vardb.cpv_remove(pkg) |
- pkg_cache.pop(pkg, None) |
- aux_get_history.discard(pkg.cpv) |
+ self.cpv_discard(pkg) |
diandersAtChromium
2011/03/22 02:57:59
Looks like you added an extra level of indirection
davidjames
2011/03/23 20:19:11
Yup.
|
# Validate counters and timestamps. |
slot_counters = {} |
@@ -162,9 +170,7 @@ class FakeVartree(vartree): |
if counter != pkg.counter or \ |
mtime != pkg.mtime: |
- pkg_vardb.cpv_remove(pkg) |
- pkg_cache.pop(pkg, None) |
- aux_get_history.discard(pkg.cpv) |
+ self.cpv_discard(pkg) |
pkg = None |
if pkg is None: |