From 0d326c6b5f7dae7f34c16cbace64616b6bad1974 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Mon, 21 Sep 2009 17:43:04 +0000 Subject: [PATCH] Merged from trunk -r14306:14313 | 14307 | Fix typos in http.client imports. | | zmedico | | | 14308 | Remove virtuals from the cache because they're unused since | | zmedico | portage-2.1.6 and it won't hurt older portage. | | 14309 | Fix redundant Atom construtor call in | | zmedico | _show_unsatisfied_dep(). | | 14310 | Tread blockers as invalid. | | zmedico | | | 14311 | Fix AtomArg constructor calls to pass in Atom instances, so | | zmedico | the constructor never has to construct one. | | 14312 | When generating config.prevmaskdict, only call the Atom | | zmedico | constructor when necessary. | | 14313 | Make Atom.__init__ call the base class constructor, though | | zmedico | it doesn't seem to matter. | svn path=/main/branches/prefix/; revision=14344 --- pym/_emerge/AtomArg.py | 3 --- pym/_emerge/BlockerCache.py | 4 --- pym/_emerge/depgraph.py | 40 +++++++++++++--------------- pym/_emerge/is_valid_package_atom.py | 2 +- pym/portage/__init__.py | 4 ++- pym/portage/dep.py | 2 ++ pym/portage/getbinpkg.py | 12 ++++----- 7 files changed, 31 insertions(+), 36 deletions(-) diff --git a/pym/_emerge/AtomArg.py b/pym/_emerge/AtomArg.py index 6178be266..71cc22273 100644 --- a/pym/_emerge/AtomArg.py +++ b/pym/_emerge/AtomArg.py @@ -17,7 +17,4 @@ class AtomArg(DependencyArg): def __init__(self, atom=None, **kwargs): DependencyArg.__init__(self, **kwargs) self.atom = atom - if not isinstance(self.atom, portage.dep.Atom): - self.atom = portage.dep.Atom(self.atom) self.set = (self.atom, ) - diff --git a/pym/_emerge/BlockerCache.py b/pym/_emerge/BlockerCache.py index 7b0db0ece..9962ffdd5 100644 --- a/pym/_emerge/BlockerCache.py +++ b/pym/_emerge/BlockerCache.py @@ -18,7 +18,6 @@ class BlockerCache(portage.cache.mappings.MutableMapping): emerge. The cache is invalidated whenever it is detected that something has changed that might alter the results of dep_check() calls: 1) the set of installed packages (including COUNTER) has changed - 2) the old-style virtuals have changed """ # Number of uncached packages to trigger cache update, since @@ -35,7 +34,6 @@ class BlockerCache(portage.cache.mappings.MutableMapping): def __init__(self, myroot, vardb): self._vardb = vardb - self._virtuals = vardb.settings.getvirtuals() self._cache_filename = os.path.join(myroot, portage.CACHE_PATH, "vdb_blockers.pickle") self._cache_version = "1" @@ -113,7 +111,6 @@ class BlockerCache(portage.cache.mappings.MutableMapping): if not cache_valid: self._cache_data = {"version":self._cache_version} self._cache_data["blockers"] = {} - self._cache_data["virtuals"] = self._virtuals self._modified.clear() def flush(self): @@ -129,7 +126,6 @@ class BlockerCache(portage.cache.mappings.MutableMapping): { version : "1", "blockers" : {cpv1:(counter,(atom1, atom2...)), cpv2...}, - "virtuals" : vardb.settings.getvirtuals() } """ if len(self._modified) >= self._cache_threshold and \ diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index ab342929e..a527b071d 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -1278,8 +1278,8 @@ class depgraph(object): deps = [] for cat in categories: - deps.append(insert_category_into_atom( - atom_without_category, cat)) + deps.append(Atom(insert_category_into_atom( + atom_without_category, cat))) return deps def _have_new_virt(self, root, atom_cp): @@ -1441,15 +1441,14 @@ class depgraph(object): # 2) It takes away freedom from the resolver to choose other # possible expansions when necessary. if "/" in x: - args.append(AtomArg(arg=x, atom=x, + args.append(AtomArg(arg=x, atom=Atom(x), root_config=root_config)) continue expanded_atoms = self._dep_expand(root_config, x) installed_cp_set = set() for atom in expanded_atoms: - atom_cp = portage.dep_getkey(atom) - if vardb.cp_list(atom_cp): - installed_cp_set.add(atom_cp) + if vardb.cp_list(atom.cp): + installed_cp_set.add(atom.cp) if len(installed_cp_set) > 1: non_virtual_cps = set() @@ -1462,7 +1461,7 @@ class depgraph(object): if len(expanded_atoms) > 1 and len(installed_cp_set) == 1: installed_cp = iter(installed_cp_set).next() expanded_atoms = [atom for atom in expanded_atoms \ - if portage.dep_getkey(atom) == installed_cp] + if atom.cp == installed_cp] if len(expanded_atoms) > 1: print() @@ -1473,15 +1472,14 @@ class depgraph(object): if expanded_atoms: atom = expanded_atoms[0] else: - null_atom = insert_category_into_atom(x, "null") - null_cp = portage.dep_getkey(null_atom) - cat, atom_pn = portage.catsplit(null_cp) + null_atom = Atom(insert_category_into_atom(x, "null")) + cat, atom_pn = portage.catsplit(null_atom.cp) virts_p = root_config.settings.get_virts_p().get(atom_pn) if virts_p: # Allow the depgraph to choose which virtual. - atom = insert_category_into_atom(x, "virtual") + atom = Atom(null_atom.replace('null/', 'virtual/', 1)) else: - atom = insert_category_into_atom(x, "null") + null_atom args.append(AtomArg(arg=x, atom=atom, root_config=root_config)) @@ -1514,9 +1512,9 @@ class depgraph(object): if not slot: # portage now masks packages with missing slot, but it's # possible that one was installed by an older version - atom = portage.cpv_getkey(cpv) + atom = Atom(portage.cpv_getkey(cpv)) else: - atom = "%s:%s" % (portage.cpv_getkey(cpv), slot) + atom = Atom("%s:%s" % (portage.cpv_getkey(cpv), slot)) args.append(AtomArg(arg=atom, atom=atom, root_config=root_config)) @@ -1911,7 +1909,6 @@ class depgraph(object): return selected_atoms def _show_unsatisfied_dep(self, root, atom, myparent=None, arg=None): - atom = portage.dep.Atom(atom) atom_set = InternalPackageSet(initial_atoms=(atom,)) xinfo = '"%s"' % atom if arg: @@ -4807,7 +4804,9 @@ class depgraph(object): args.append(SetArg(arg=x, set=expanded_set, root_config=root_config)) else: - if not portage.isvalidatom(x): + try: + x = Atom(x) + except portage.exception.InvalidAtom: continue args.append(AtomArg(arg=x, atom=x, root_config=root_config)) @@ -4977,15 +4976,14 @@ class _dep_check_composite_db(portage.dbapi): if expanded_atoms: atom = expanded_atoms[0] else: - null_atom = insert_category_into_atom(atom, "null") - null_cp = portage.dep_getkey(null_atom) - cat, atom_pn = portage.catsplit(null_cp) + null_atom = Atom(insert_category_into_atom(atom, "null")) + cat, atom_pn = portage.catsplit(null_atom.cp) virts_p = root_config.settings.get_virts_p().get(atom_pn) if virts_p: # Allow the resolver to choose which virtual. - atom = insert_category_into_atom(atom, "virtual") + atom = Atom(null_atom.replace('null/', 'virtual/', 1)) else: - atom = insert_category_into_atom(atom, "null") + atom = null_atom return atom def aux_get(self, cpv, wants): diff --git a/pym/_emerge/is_valid_package_atom.py b/pym/_emerge/is_valid_package_atom.py index 11920be30..6295667a5 100644 --- a/pym/_emerge/is_valid_package_atom.py +++ b/pym/_emerge/is_valid_package_atom.py @@ -10,4 +10,4 @@ def is_valid_package_atom(x): alphanum = re.search(r'\w', x) if alphanum: x = x[:alphanum.start()] + "cat/" + x[alphanum.start():] - return portage.isvalidatom(x) + return portage.isvalidatom(x, allow_blockers=False) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 191e5385d..420cdcd80 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1732,7 +1732,9 @@ class config(object): # revmaskdict self.prevmaskdict={} for x in self.packages: - x = portage.dep.Atom(x.lstrip('*')) + # Negative atoms are filtered by the above stack_lists() call. + if not isinstance(x, dep.Atom): + x = dep.Atom(x.lstrip('*')) self.prevmaskdict.setdefault(x.cp, []).append(x) self._pkeywords_list = [] diff --git a/pym/portage/dep.py b/pym/portage/dep.py index 68e6c6b22..ebdf1ea83 100644 --- a/pym/portage/dep.py +++ b/pym/portage/dep.py @@ -519,6 +519,8 @@ class Atom(_atom_base): raise TypeError(_("Expected %s, got %s") % \ (_atom_base, type(s))) + _atom_base.__init__(s) + if "!" == s[:1]: blocker = self._blocker(forbid_overlap=("!" == s[1:2])) if blocker.overlap.forbid: diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index 939ab641c..0ef5f0d52 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -41,14 +41,14 @@ except ImportError as e: try: try: from http.client import HTTPConnection as http_client_HTTPConnection - from http.client import HTTPSConnection as http_client_HTTPConnection - from http.client import BadStatusLine as http_client_HTTPConnection - from http.client import ResponseNotReady as http_client_HTTPConnection + from http.client import HTTPSConnection as http_client_HTTPSConnection + from http.client import BadStatusLine as http_client_BadStatusLine + from http.client import ResponseNotReady as http_client_ResponseNotReady except ImportError: from httplib import HTTPConnection as http_client_HTTPConnection - from httplib import HTTPSConnection as http_client_HTTPConnection - from httplib import BadStatusLine as http_client_HTTPConnection - from httplib import ResponseNotReady as http_client_HTTPConnection + from httplib import HTTPSConnection as http_client_HTTPSConnection + from httplib import BadStatusLine as http_client_BadStatusLine + from httplib import ResponseNotReady as http_client_ResponseNotReady except ImportError as e: sys.stderr.write(colorize("BAD","!!! CANNOT IMPORT HTTP.CLIENT: ")+str(e)+"\n") -- 2.26.2