Move FakeVartree population out of the constructor by calling the sync()
authorZac Medico <zmedico@gentoo.org>
Sat, 7 Nov 2009 01:09:49 +0000 (01:09 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 7 Nov 2009 01:09:49 +0000 (01:09 -0000)
method explicitly. This allows the depgraph constructor avoid populating
the FakeVartree, and delay it until depgraph._load_vdb() is called.
(trunk r14773)

svn path=/main/branches/2.1.7/; revision=14786

pym/_emerge/BlockerDB.py
pym/_emerge/FakeVartree.py
pym/_emerge/depgraph.py

index ff1e525a2fe352f6adaa76594d5974057424a129..4c99b5a744c8322619fb4282364bb61e3c20217e 100644 (file)
@@ -29,15 +29,13 @@ class BlockerDB(object):
        def _get_fake_vartree(self, acquire_lock=0):
                fake_vartree = self._fake_vartree
                if fake_vartree is None:
-                       fake_vartree = FakeVartree(self._root_config,
-                               acquire_lock=acquire_lock)
+                       fake_vartree = FakeVartree(self._root_config)
                        self._fake_vartree = fake_vartree
                        self._dep_check_trees = { self._vartree.root : {
                                "porttree"    :  fake_vartree,
                                "vartree"     :  fake_vartree,
                        }}
-               else:
-                       fake_vartree.sync(acquire_lock=acquire_lock)
+               fake_vartree.sync(acquire_lock=acquire_lock)
                return fake_vartree
 
        def findInstalledBlockers(self, new_pkg, acquire_lock=0):
index 07703f3f2789e907e42779e3c116bd1758b50e2b..e1b81980959f8435ec7801e29a1bfd301c91d44a 100644 (file)
@@ -21,8 +21,9 @@ class FakeVartree(portage.vartree):
        allows things like vardb global updates to be done in memory so that the
        user doesn't necessarily need write access to the vardb in cases where
        global updates are necessary (updates are performed when necessary if there
-       is not a matching ebuild in the tree)."""
-       def __init__(self, root_config, pkg_cache=None, acquire_lock=1):
+       is not a matching ebuild in the tree). Instances of this class are not
+       populated until the sync() method is called."""
+       def __init__(self, root_config, pkg_cache=None):
                self._root_config = root_config
                if pkg_cache is None:
                        pkg_cache = {}
@@ -49,8 +50,6 @@ class FakeVartree(portage.vartree):
                self._portdb = portdb
                self._global_updates = None
 
-               self.sync()
-
        def _match_wrapper(self, cpv, use_cache=1):
                """
                Make sure the metadata in Package instances gets updated for any
index 5d76a49f0b7670235bf9b0078689a58f1eb670c0..e7407893f4f9d40c2b1f18e6c702750fd25afa0c 100644 (file)
@@ -269,10 +269,14 @@ class depgraph(object):
                                "--nodeps" not in self._frozen_config.myopts and \
                                "--buildpkgonly" not in self._frozen_config.myopts
 
+                       fake_vartree = self._frozen_config.trees[myroot]["vartree"]
+                       fake_vartree.sync()
+
                        if preload_installed_pkgs:
+                               vardb = fake_vartree.dbapi
                                fakedb = self._dynamic_config._graph_trees[
                                        myroot]["vartree"].dbapi
-                               vardb = self._frozen_config.trees[myroot]["vartree"].dbapi
+
                                for pkg in vardb:
                                        self._spinner_update()
                                        # This triggers metadata updates via FakeVartree.