1 |
Author: zmedico |
2 |
Date: 2008-05-03 19:00:47 +0000 (Sat, 03 May 2008) |
3 |
New Revision: 10134 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/_emerge/__init__.py |
7 |
Log: |
8 |
Improve --resume handling of saved "favorites" argument atoms: |
9 |
|
10 |
* Save the favorites in oneshot mode too since they're still useful for |
11 |
restoring state upon --resume. |
12 |
|
13 |
* Add a depgraph._load_favorites() method to resume state from a previous |
14 |
select_files() call. This allows Package instances to be matched with |
15 |
DependencyArg instances during graph creation. |
16 |
|
17 |
|
18 |
Modified: main/trunk/pym/_emerge/__init__.py |
19 |
=================================================================== |
20 |
--- main/trunk/pym/_emerge/__init__.py 2008-05-03 08:25:40 UTC (rev 10133) |
21 |
+++ main/trunk/pym/_emerge/__init__.py 2008-05-03 19:00:47 UTC (rev 10134) |
22 |
@@ -2285,8 +2285,6 @@ |
23 |
root_config = self.roots[self.target_root] |
24 |
sets = root_config.sets |
25 |
getSetAtoms = root_config.setconfig.getSetAtoms |
26 |
- oneshot = "--oneshot" in self.myopts or \ |
27 |
- "--onlydeps" in self.myopts |
28 |
myfavorites=[] |
29 |
myroot = self.target_root |
30 |
dbs = self._filtered_trees[myroot]["dbs"] |
31 |
@@ -2410,8 +2408,7 @@ |
32 |
self._sets[s] = expanded_set |
33 |
args.append(SetArg(arg=x, set=expanded_set, |
34 |
root_config=root_config)) |
35 |
- if not oneshot: |
36 |
- myfavorites.append(x) |
37 |
+ myfavorites.append(x) |
38 |
continue |
39 |
if not is_valid_package_atom(x): |
40 |
portage.writemsg("\n\n!!! '%s' is not a valid package atom.\n" % x, |
41 |
@@ -2498,8 +2495,7 @@ |
42 |
if myatom in args_set: |
43 |
continue |
44 |
args_set.add(myatom) |
45 |
- if not oneshot: |
46 |
- myfavorites.append(myatom) |
47 |
+ myfavorites.append(myatom) |
48 |
self._set_atoms.update(chain(*self._sets.itervalues())) |
49 |
atom_arg_map = self._atom_arg_map |
50 |
for arg in args: |
51 |
@@ -4761,11 +4757,13 @@ |
52 |
Add a resume command to the graph and validate it in the process. This |
53 |
will raise a PackageNotFound exception if a package is not available. |
54 |
""" |
55 |
- self._sets["args"].update(resume_data.get("favorites", [])) |
56 |
+ |
57 |
+ if not isinstance(resume_data, dict): |
58 |
+ return False |
59 |
+ favorites = resume_data.get("favorites") |
60 |
+ if isinstance(favorites, list): |
61 |
+ self._load_favorites(resume_data) |
62 |
mergelist = resume_data.get("mergelist", []) |
63 |
- favorites = resume_data.get("favorites") |
64 |
- if not isinstance(favorites, list): |
65 |
- favorites = [] |
66 |
|
67 |
if mergelist and "--skipfirst" in self.myopts: |
68 |
for i, task in enumerate(mergelist): |
69 |
@@ -4822,15 +4820,9 @@ |
70 |
if not serialized_tasks or "--nodeps" in self.myopts: |
71 |
self._serialized_tasks_cache = serialized_tasks |
72 |
else: |
73 |
- favorites_set = InternalPackageSet(atom for atom in favorites \ |
74 |
- if isinstance(atom, basestring) and portage.isvalidatom(atom)) |
75 |
- for node in serialized_tasks: |
76 |
- if isinstance(node, Package) and \ |
77 |
- node.operation == "merge" and \ |
78 |
- favorites_set.findAtomForPackage(node.cpv, node.metadata): |
79 |
- self._set_nodes.add(node) |
80 |
+ self._select_package = self._select_pkg_from_graph |
81 |
+ self.myparams.add("selective") |
82 |
|
83 |
- self._select_package = self._select_pkg_from_graph |
84 |
for task in serialized_tasks: |
85 |
if isinstance(task, Package) and \ |
86 |
task.operation == "merge": |
87 |
@@ -4854,13 +4846,68 @@ |
88 |
except self._unknown_internal_error: |
89 |
return False |
90 |
|
91 |
- for node in self.digraph.root_nodes(): |
92 |
- if isinstance(node, Package) and \ |
93 |
- node.operation == "merge": |
94 |
- # Give hint to the --tree display. |
95 |
- self._set_nodes.add(node) |
96 |
return True |
97 |
|
98 |
+ def _load_favorites(self, favorites): |
99 |
+ """ |
100 |
+ Use a list of favorites to resume state from a |
101 |
+ previous select_files() call. This creates similar |
102 |
+ DependencyArg instances to those that would have |
103 |
+ been created by the original select_files() call. |
104 |
+ This allows Package instances to be matched with |
105 |
+ DependencyArg instances during graph creation. |
106 |
+ """ |
107 |
+ root_config = self.roots[self.target_root] |
108 |
+ getSetAtoms = root_config.setconfig.getSetAtoms |
109 |
+ sets = root_config.sets |
110 |
+ args = [] |
111 |
+ for x in favorites: |
112 |
+ if not isinstance(x, basestring): |
113 |
+ continue |
114 |
+ if x in ("system", "world"): |
115 |
+ x = SETPREFIX + x |
116 |
+ if x.startswith(SETPREFIX): |
117 |
+ s = x[len(SETPREFIX):] |
118 |
+ if s not in sets: |
119 |
+ continue |
120 |
+ if s in self._sets: |
121 |
+ continue |
122 |
+ # Recursively expand sets so that containment tests in |
123 |
+ # self._get_parent_sets() properly match atoms in nested |
124 |
+ # sets (like if world contains system). |
125 |
+ expanded_set = InternalPackageSet( |
126 |
+ initial_atoms=getSetAtoms(s)) |
127 |
+ self._sets[s] = expanded_set |
128 |
+ args.append(SetArg(arg=x, set=expanded_set, |
129 |
+ root_config=root_config)) |
130 |
+ else: |
131 |
+ if not portage.isvalidatom(x): |
132 |
+ continue |
133 |
+ args.append(AtomArg(arg=x, atom=x, |
134 |
+ root_config=root_config)) |
135 |
+ |
136 |
+ # Create the "args" package set from atoms and |
137 |
+ # packages given as arguments. |
138 |
+ args_set = self._sets["args"] |
139 |
+ for arg in args: |
140 |
+ if not isinstance(arg, (AtomArg, PackageArg)): |
141 |
+ continue |
142 |
+ myatom = arg.atom |
143 |
+ if myatom in args_set: |
144 |
+ continue |
145 |
+ args_set.add(myatom) |
146 |
+ self._set_atoms.update(chain(*self._sets.itervalues())) |
147 |
+ atom_arg_map = self._atom_arg_map |
148 |
+ for arg in args: |
149 |
+ for atom in arg.set: |
150 |
+ atom_key = (atom, arg.root_config.root) |
151 |
+ refs = atom_arg_map.get(atom_key) |
152 |
+ if refs is None: |
153 |
+ refs = [] |
154 |
+ atom_arg_map[atom_key] = refs |
155 |
+ if arg not in refs: |
156 |
+ refs.append(arg) |
157 |
+ |
158 |
class _internal_exception(portage.exception.PortageException): |
159 |
def __init__(self, value=""): |
160 |
portage.exception.PortageException.__init__(self, value) |
161 |
@@ -5202,6 +5249,8 @@ |
162 |
failed_fetches = [] |
163 |
fetchonly = "--fetchonly" in self.myopts or \ |
164 |
"--fetch-all-uri" in self.myopts |
165 |
+ oneshot = "--oneshot" in self.myopts or \ |
166 |
+ "--onlydeps" in self.myopts |
167 |
pretend = "--pretend" in self.myopts |
168 |
ldpath_mtimes = mtimedb["ldpath"] |
169 |
xterm_titles = "notitles" not in self.settings.features |
170 |
@@ -5555,10 +5604,8 @@ |
171 |
if retval != os.EX_OK: |
172 |
return retval |
173 |
#need to check for errors |
174 |
- if "--buildpkgonly" not in self.myopts: |
175 |
- self.trees[x[1]]["vartree"].inject(x[2]) |
176 |
- myfavkey = portage.cpv_getkey(x[2]) |
177 |
- if not fetchonly and not pretend and \ |
178 |
+ if not buildpkgonly: |
179 |
+ if not (fetchonly or oneshot or pretend) and \ |
180 |
args_set.findAtomForPackage(pkg_key, metadata): |
181 |
world_set.lock() |
182 |
world_set.load() # maybe it's changed on disk |
183 |
|
184 |
-- |
185 |
gentoo-commits@l.g.o mailing list |