handle empty sets properly
authorMarius Mauch <genone@gentoo.org>
Fri, 5 Oct 2007 22:07:23 +0000 (22:07 -0000)
committerMarius Mauch <genone@gentoo.org>
Fri, 5 Oct 2007 22:07:23 +0000 (22:07 -0000)
svn path=/main/trunk/; revision=7974

pym/emerge/__init__.py

index c12b5d8e0a2ea0900948ad6db94be99dc6dac75d..080248b8dc69db565baacfaa56bf957e04d8cf79 100644 (file)
@@ -6407,6 +6407,7 @@ def emerge_main():
        setconfig = make_default_config(settings, trees[settings["ROOT"]])
        del setconfigpaths
        if myaction not in ["search", "metadata", "sync"]:
+               oldargs = myfiles[:]
                packagesets, setconfig_errors = setconfig.getSetsWithAliases()
                for s in packagesets:
                        if s in myfiles:
@@ -6414,10 +6415,19 @@ def emerge_main():
                                if myaction in ["unmerge", "prune", "clean", "depclean"] and not packagesets[s].supportsOperation("unmerge"):
                                        print "emerge: the given set %s does not support unmerge operations" % s
                                        sys.exit(1)
-                               myfiles.extend(packagesets[s].getAtoms())
+                               if not packagesets[s].getAtoms():
+                                       print "emerge: '%s' is an empty set" % s
+                               else:
+                                       myfiles.extend(packagesets[s].getAtoms())
                                for e in packagesets[s].errors:
                                        print e
                                myfiles.remove(s)
+               # Need to handle empty sets specially, otherwise emerge will react 
+               # with the help message for empty argument lists
+               if oldargs and not myfiles:
+                       print "emerge: no targets left after set expansion"
+                       sys.exit(0)
+               del oldargs
 
        if ("--tree" in myopts) and ("--columns" in myopts):
                print "emerge: can't specify both of \"--tree\" and \"--columns\"."