Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10135 - main/branches/2.1.2/bin
Date: Sat, 03 May 2008 19:25:11
Message-Id: E1JsNM4-00082y-3L@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-05-03 19:25:07 +0000 (Sat, 03 May 2008)
3 New Revision: 10135
4
5 Modified:
6 main/branches/2.1.2/bin/emerge
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 (trunk r10134)
17
18
19 Modified: main/branches/2.1.2/bin/emerge
20 ===================================================================
21 --- main/branches/2.1.2/bin/emerge 2008-05-03 19:00:47 UTC (rev 10134)
22 +++ main/branches/2.1.2/bin/emerge 2008-05-03 19:25:07 UTC (rev 10135)
23 @@ -2424,8 +2424,6 @@
24 root_config = self.roots[self.target_root]
25 sets = root_config.sets
26 getSetAtoms = root_config.setconfig.getSetAtoms
27 - oneshot = "--oneshot" in self.myopts or \
28 - "--onlydeps" in self.myopts
29 myfavorites=[]
30 myroot = self.target_root
31 dbs = self._filtered_trees[myroot]["dbs"]
32 @@ -2557,8 +2555,7 @@
33 self._sets[s] = expanded_set
34 args.append(SetArg(arg=SETPREFIX+s, set=expanded_set,
35 root_config=root_config))
36 - #if not oneshot:
37 - # myfavorites.append(x)
38 + myfavorites.append(x)
39 continue
40 if not is_valid_package_atom(x):
41 portage.writemsg("\n\n!!! '%s' is not a valid package atom.\n" % x,
42 @@ -2645,8 +2642,7 @@
43 if myatom in args_set:
44 continue
45 args_set.add(myatom)
46 - if not oneshot:
47 - myfavorites.append(myatom)
48 + myfavorites.append(myatom)
49 self._set_atoms.update(chain(*self._sets.itervalues()))
50 atom_arg_map = self._atom_arg_map
51 for arg in args:
52 @@ -4899,7 +4895,8 @@
53 s = SETPREFIX + k
54 if s in world_set:
55 continue
56 - all_added.append(SETPREFIX + k)
57 + # sets in world are supported in newer portage
58 + #all_added.append(SETPREFIX + k)
59 all_added.extend(added_favorites)
60 all_added.sort()
61 for a in all_added:
62 @@ -4915,11 +4912,13 @@
63 Add a resume command to the graph and validate it in the process. This
64 will raise a PackageNotFound exception if a package is not available.
65 """
66 - self._sets["args"].update(resume_data.get("favorites", []))
67 +
68 + if not isinstance(resume_data, dict):
69 + return False
70 + favorites = resume_data.get("favorites")
71 + if isinstance(favorites, list):
72 + self._load_favorites(resume_data)
73 mergelist = resume_data.get("mergelist", [])
74 - favorites = resume_data.get("favorites")
75 - if not isinstance(favorites, list):
76 - favorites = []
77
78 if mergelist and "--skipfirst" in self.myopts:
79 for i, task in enumerate(mergelist):
80 @@ -4976,15 +4975,9 @@
81 if not serialized_tasks or "--nodeps" in self.myopts:
82 self._serialized_tasks_cache = serialized_tasks
83 else:
84 - favorites_set = InternalPackageSet(atom for atom in favorites \
85 - if isinstance(atom, basestring) and portage.isvalidatom(atom))
86 - for node in serialized_tasks:
87 - if isinstance(node, Package) and \
88 - node.operation == "merge" and \
89 - favorites_set.findAtomForPackage(node.cpv, node.metadata):
90 - self._set_nodes.add(node)
91 + self._select_package = self._select_pkg_from_graph
92 + self.myparams.add("selective")
93
94 - self._select_package = self._select_pkg_from_graph
95 for task in serialized_tasks:
96 if isinstance(task, Package) and \
97 task.operation == "merge":
98 @@ -5008,13 +5001,68 @@
99 except self._unknown_internal_error:
100 return False
101
102 - for node in self.digraph.root_nodes():
103 - if isinstance(node, Package) and \
104 - node.operation == "merge":
105 - # Give hint to the --tree display.
106 - self._set_nodes.add(node)
107 return True
108
109 + def _load_favorites(self, favorites):
110 + """
111 + Use a list of favorites to resume state from a
112 + previous select_files() call. This creates similar
113 + DependencyArg instances to those that would have
114 + been created by the original select_files() call.
115 + This allows Package instances to be matched with
116 + DependencyArg instances during graph creation.
117 + """
118 + root_config = self.roots[self.target_root]
119 + getSetAtoms = root_config.setconfig.getSetAtoms
120 + sets = root_config.sets
121 + args = []
122 + for x in favorites:
123 + if not isinstance(x, basestring):
124 + continue
125 + if x in ("system", "world"):
126 + x = SETPREFIX + x
127 + if x.startswith(SETPREFIX):
128 + s = x[len(SETPREFIX):]
129 + if s not in sets:
130 + continue
131 + if s in self._sets:
132 + continue
133 + # Recursively expand sets so that containment tests in
134 + # self._get_parent_sets() properly match atoms in nested
135 + # sets (like if world contains system).
136 + expanded_set = InternalPackageSet(
137 + initial_atoms=getSetAtoms(s))
138 + self._sets[s] = expanded_set
139 + args.append(SetArg(arg=x, set=expanded_set,
140 + root_config=root_config))
141 + else:
142 + if not portage.isvalidatom(x):
143 + continue
144 + args.append(AtomArg(arg=x, atom=x,
145 + root_config=root_config))
146 +
147 + # Create the "args" package set from atoms and
148 + # packages given as arguments.
149 + args_set = self._sets["args"]
150 + for arg in args:
151 + if not isinstance(arg, (AtomArg, PackageArg)):
152 + continue
153 + myatom = arg.atom
154 + if myatom in args_set:
155 + continue
156 + args_set.add(myatom)
157 + self._set_atoms.update(chain(*self._sets.itervalues()))
158 + atom_arg_map = self._atom_arg_map
159 + for arg in args:
160 + for atom in arg.set:
161 + atom_key = (atom, arg.root_config.root)
162 + refs = atom_arg_map.get(atom_key)
163 + if refs is None:
164 + refs = []
165 + atom_arg_map[atom_key] = refs
166 + if arg not in refs:
167 + refs.append(arg)
168 +
169 class _internal_exception(portage_exception.PortageException):
170 def __init__(self, value=""):
171 portage_exception.PortageException.__init__(self, value)
172 @@ -5355,6 +5403,8 @@
173 buildpkgonly = "--buildpkgonly" in self.myopts
174 fetchonly = "--fetchonly" in self.myopts or \
175 "--fetch-all-uri" in self.myopts
176 + oneshot = "--oneshot" in self.myopts or \
177 + "--onlydeps" in self.myopts
178 pretend = "--pretend" in self.myopts
179 ldpath_mtimes = mtimedb["ldpath"]
180 xterm_titles = "notitles" not in self.settings.features
181 @@ -5704,10 +5754,8 @@
182 if retval != os.EX_OK:
183 return retval
184 #need to check for errors
185 - if "--buildpkgonly" not in self.myopts:
186 - self.trees[x[1]]["vartree"].inject(x[2])
187 - myfavkey = portage.cpv_getkey(x[2])
188 - if not fetchonly and not pretend and \
189 + if not buildpkgonly:
190 + if not (fetchonly or oneshot or pretend) and \
191 args_set.findAtomForPackage(pkg_key, metadata):
192 world_set.lock()
193 world_set.load()
194
195 --
196 gentoo-commits@l.g.o mailing list