* Tweak isvalidatom() to treat "null" category as valid, but missing category
authorZac Medico <zmedico@gentoo.org>
Sat, 31 May 2008 09:11:25 +0000 (09:11 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 31 May 2008 09:11:25 +0000 (09:11 -0000)
  as invalid (previously both where treated as invalid).

* Fix a spot inside emerge's unmerge() function that sometimes generates
  invalid atoms by adding an unnecessary "=" to the front. Even when in
  cases that resulted in a valid atom here, adding the "=" was redundant
  because dep_expand() does that automatically now (for backward compat).

svn path=/main/trunk/; revision=10516

pym/_emerge/__init__.py
pym/portage/dep.py

index 7d9cbdfa82cac816f36f14b2b76e37cd1f1ae5d4..8a73156e9640dfc704d3196ed6a8c841bc3e9e2c 100644 (file)
@@ -6427,8 +6427,7 @@ def unmerge(root_config, myopts, unmerge_action,
                                sys.exit(1)
        
                        if not mymatch and x[0] not in "<>=~":
-                               #add a "=" if missing
-                               mymatch=localtree.dep_match("="+x)
+                               mymatch = localtree.dep_match(x)
                        if not mymatch:
                                portage.writemsg("\n--- Couldn't find '%s' to %s.\n" % \
                                        (x, unmerge_action), noiselevel=-1)
index d0e487afc135646f33bc606d42043ae44e53be80..b3c763f4a02391b72cbc6dede54497748dd87e04 100644 (file)
@@ -593,19 +593,30 @@ def isvalidatom(atom, allow_blockers=False):
        if allow_blockers and atom.startswith("!"):
                atom = atom[1:]
        cpv = dep_getcpv(atom)
+       cpv_catsplit = catsplit(cpv)
+       mycpv_cps = None
        if cpv:
-               if _valid_category.match(catsplit(cpv)[0]) is None:
-                       return 0
-               mycpv_cps = catpkgsplit(cpv)
-       else:
-               mycpv_cps = None
+               if len(cpv_catsplit) == 2:
+                       if _valid_category.match(cpv_catsplit[0]) is None:
+                               return 0
+                       if cpv_catsplit[0] == "null":
+                               # "null" category is valid, missing category is not.
+                               mycpv_cps = catpkgsplit(cpv.replace("null/", "cat/", 1))
+                               if mycpv_cps:
+                                       mycpv_cps[0] = "null"
+               if not mycpv_cps:
+                       mycpv_cps = catpkgsplit(cpv)
+
        operator = get_operator(atom)
        if operator:
                if operator[0] in "<>" and remove_slot(atom).endswith("*"):
                        return 0
-               if mycpv_cps and mycpv_cps[0] != "null":
-                       # >=cat/pkg-1.0
-                       return 1
+               if mycpv_cps:
+                       if len(cpv_catsplit) == 2:
+                               # >=cat/pkg-1.0
+                               return 1
+                       else:
+                               return 0
                else:
                        # >=cat/pkg or >=pkg-1.0 (no category)
                        return 0
@@ -613,7 +624,7 @@ def isvalidatom(atom, allow_blockers=False):
                # cat/pkg-1.0
                return 0
 
-       if (len(atom.split('/')) == 2):
+       if len(cpv_catsplit) == 2:
                # cat/pkg
                return 1
        else: