expand_set_arguments: defer set load for depgraph
authorZac Medico <zmedico@gentoo.org>
Wed, 13 Mar 2013 05:10:08 +0000 (22:10 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 13 Mar 2013 05:10:08 +0000 (22:10 -0700)
This allows the depgraph to display the "Calculating dependencies"
message before sets are loaded, as discussed in bug #461412.

pym/_emerge/actions.py
pym/_emerge/depgraph.py

index 7fe8e838833bda1a496822f58274a716dca70f8b..d7d248af2fe53f56a4570caac7a8131917a299ed 100644 (file)
@@ -3340,7 +3340,7 @@ def expand_set_arguments(myfiles, myaction, root_config):
        # world file, the depgraph performs set expansion later. It will get
        # confused about where the atoms came from if it's not allowed to
        # expand them itself.
-       do_not_expand = (None, )
+       do_not_expand = myaction is None
        newargs = []
        for a in myfiles:
                if a in ("system", "world"):
@@ -3406,6 +3406,14 @@ def expand_set_arguments(myfiles, myaction, root_config):
                                        for line in textwrap.wrap(msg, 50):
                                                out.ewarn(line)
                                setconfig.active.append(s)
+
+                               if do_not_expand:
+                                       # Loading sets can be slow, so skip it here, in order
+                                       # to allow the depgraph to indicate progress with the
+                                       # spinner while sets are loading (bug #461412).
+                                       newargs.append(a)
+                                       continue
+
                                try:
                                        set_atoms = setconfig.getSetAtoms(s)
                                except portage.exception.PackageSetNotFound as e:
@@ -3426,8 +3434,6 @@ def expand_set_arguments(myfiles, myaction, root_config):
                                        retval = 1
                                elif not set_atoms:
                                        print("emerge: '%s' is an empty set" % s)
-                               elif myaction not in do_not_expand:
-                                       newargs.extend(set_atoms)
                                else:
                                        newargs.append(SETPREFIX+s)
                                for e in sets[s].errors:
index 965d3bceff7bc4fb54240dcf9c9a051fd702ea69..7e3a0eb1a49143e486a42f77d3b2fd3bda55ac0c 100644 (file)
@@ -2714,6 +2714,29 @@ class depgraph(object):
                                                raise portage.exception.PackageSetNotFound(s)
                                        if s in depgraph_sets.sets:
                                                continue
+
+                                       try:
+                                               set_atoms = root_config.setconfig.getSetAtoms(s)
+                                       except portage.exception.PackageSetNotFound as e:
+                                               writemsg_level("\n\n", level=logging.ERROR,
+                                                       noiselevel=-1)
+                                               for pset in list(depgraph_sets.sets.values()) + [sets[s]]:
+                                                       for error_msg in pset.errors:
+                                                               sys.stderr.write("%s\n" % (error_msg,))
+
+                                               writemsg_level(("emerge: the given set '%s' "
+                                                       "contains a non-existent set named '%s'.\n") % \
+                                                       (s, e), level=logging.ERROR, noiselevel=-1)
+                                               if s in ('world', 'selected') and \
+                                                       SETPREFIX + e.value in sets['selected']:
+                                                       writemsg_level(("Use `emerge --deselect %s%s` to "
+                                                               "remove this set from world_sets.\n") %
+                                                               (SETPREFIX, e,), level=logging.ERROR,
+                                                               noiselevel=-1)
+                                               writemsg_level("\n", level=logging.ERROR,
+                                                       noiselevel=-1)
+                                               return False, myfavorites
+
                                        pset = sets[s]
                                        depgraph_sets.sets[s] = pset
                                        args.append(SetArg(arg=x, pset=pset,
@@ -7031,6 +7054,11 @@ class depgraph(object):
 
                self._display_autounmask()
 
+               for depgraph_sets in self._dynamic_config.sets.values():
+                       for pset in depgraph_sets.sets.values():
+                               for e in pset.errors:
+                                       sys.stderr.write("%s\n" % (e,))
+
                # TODO: Add generic support for "set problem" handlers so that
                # the below warnings aren't special cases for world only.