Merge lp:~jelmer/bzr-builddeb/multi-tarball-pt8 into lp:bzr-builddeb
- multi-tarball-pt8
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Superseded |
---|---|
Proposed branch: | lp:~jelmer/bzr-builddeb/multi-tarball-pt8 |
Merge into: | lp:bzr-builddeb |
Diff against target: |
635 lines (+157/-145) 4 files modified
cmds.py (+1/-1) import_dsc.py (+86/-103) tests/test_import_dsc.py (+26/-26) upstream/pristinetar.py (+44/-15) |
To merge this branch: | bzr merge lp:~jelmer/bzr-builddeb/multi-tarball-pt8 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Bzr-builddeb-hackers | Pending | ||
Review via email: mp+68224@code.launchpad.net |
This proposal has been superseded by a proposal from 2011-07-18.
Commit message
Description of the change
To post a comment you must log in.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'cmds.py' |
2 | --- cmds.py 2011-06-28 08:41:44 +0000 |
3 | +++ cmds.py 2011-07-18 10:01:28 +0000 |
4 | @@ -964,7 +964,7 @@ |
5 | db.extract_upstream_tree(parents[0], tempdir) |
6 | else: |
7 | db._create_empty_upstream_tree(tempdir) |
8 | - tree = db.get_branch_tip_revtree() |
9 | + tree = db.branch.basis_tree() |
10 | tree.lock_read() |
11 | dbs = DistributionBranchSet() |
12 | dbs.add_branch(db) |
13 | |
14 | === modified file 'import_dsc.py' |
15 | --- import_dsc.py 2011-06-28 08:41:44 +0000 |
16 | +++ import_dsc.py 2011-07-18 10:01:28 +0000 |
17 | @@ -277,25 +277,25 @@ |
18 | return str(version) |
19 | |
20 | def _has_version(self, branch, tag_name, md5=None): |
21 | - if branch.tags.has_tag(tag_name): |
22 | - revid = branch.tags.lookup_tag(tag_name) |
23 | - branch.lock_read() |
24 | - try: |
25 | - graph = branch.repository.get_graph() |
26 | - if not graph.is_ancestor(revid, branch.last_revision()): |
27 | - return False |
28 | - finally: |
29 | - branch.unlock() |
30 | - if md5 is None: |
31 | - return True |
32 | - rev = branch.repository.get_revision(revid) |
33 | - try: |
34 | - return rev.properties['deb-md5'] == md5 |
35 | - except KeyError: |
36 | - warning("tag %s present in branch, but there is no " |
37 | - "associated 'deb-md5' property" % tag_name) |
38 | - pass |
39 | - return False |
40 | + if not branch.tags.has_tag(tag_name): |
41 | + return False |
42 | + revid = branch.tags.lookup_tag(tag_name) |
43 | + branch.lock_read() |
44 | + try: |
45 | + graph = branch.repository.get_graph() |
46 | + if not graph.is_ancestor(revid, branch.last_revision()): |
47 | + return False |
48 | + finally: |
49 | + branch.unlock() |
50 | + if md5 is None: |
51 | + return True |
52 | + rev = branch.repository.get_revision(revid) |
53 | + try: |
54 | + return rev.properties['deb-md5'] == md5 |
55 | + except KeyError: |
56 | + warning("tag %s present in branch, but there is no " |
57 | + "associated 'deb-md5' property" % tag_name) |
58 | + return False |
59 | |
60 | def has_version(self, version, md5=None): |
61 | """Whether this branch contains the package version specified. |
62 | @@ -409,18 +409,6 @@ |
63 | return self.branch.tags.lookup_tag(ubuntu_tag_name) |
64 | return self.branch.tags.lookup_tag(tag_name) |
65 | |
66 | - def revid_of_upstream_version(self, package, version, tarballs=None): |
67 | - """Returns the revision id corresponding to the upstream version. |
68 | - |
69 | - :param version: the Version object to extract the upstream version |
70 | - from to retrieve the revid of. The upstream version must be |
71 | - present in the upstream branch. |
72 | - :return: the revision id corresponding to the upstream portion |
73 | - of the version |
74 | - """ |
75 | - return self.pristine_upstream_source.version_as_revision(package, version, |
76 | - tarballs) |
77 | - |
78 | def tag_version(self, version, revid=None): |
79 | """Tags the branch's last revision with the given version. |
80 | |
81 | @@ -506,6 +494,21 @@ |
82 | except KeyError: |
83 | return False |
84 | |
85 | + def can_pull_from_branch(self, branch, version, md5): |
86 | + if not branch.has_version(version, md5=md5): |
87 | + return False |
88 | + |
89 | + # Check that they haven't diverged |
90 | + branch.branch.lock_read() |
91 | + try: |
92 | + graph = branch.branch.repository.get_graph( |
93 | + self.branch.repository) |
94 | + return graph.is_ancestor(self.branch.last_revision(), |
95 | + branch.revid_of_version(version)) |
96 | + finally: |
97 | + branch.branch.unlock() |
98 | + |
99 | + |
100 | def branch_to_pull_version_from(self, version, md5): |
101 | """Checks whether this upload is a pull from a lesser branch. |
102 | |
103 | @@ -531,29 +534,11 @@ |
104 | self.branch.lock_read() |
105 | try: |
106 | for branch in reversed(self.get_lesser_branches()): |
107 | - if branch.has_version(version, md5=md5): |
108 | - # Check that they haven't diverged |
109 | - branch.branch.lock_read() |
110 | - try: |
111 | - graph = branch.branch.repository.get_graph( |
112 | - self.branch.repository) |
113 | - if graph.is_ancestor(self.branch.last_revision(), |
114 | - branch.revid_of_version(version)): |
115 | - return branch |
116 | - finally: |
117 | - branch.branch.unlock() |
118 | + if self.can_pull_from_branch(branch, version, md5): |
119 | + return branch |
120 | for branch in self.get_greater_branches(): |
121 | - if branch.has_version(version, md5=md5): |
122 | - # Check that they haven't diverged |
123 | - branch.branch.lock_read() |
124 | - try: |
125 | - graph = branch.branch.repository.get_graph( |
126 | - self.branch.repository) |
127 | - if graph.is_ancestor(self.branch.last_revision(), |
128 | - branch.revid_of_version(version)): |
129 | - return branch |
130 | - finally: |
131 | - branch.branch.unlock() |
132 | + if self.can_pull_from_branch(branch, version, md5): |
133 | + return branch |
134 | return None |
135 | finally: |
136 | self.branch.unlock() |
137 | @@ -581,7 +566,7 @@ |
138 | graph = other_up_branch.repository.get_graph( |
139 | up_branch.repository) |
140 | return graph.is_ancestor(up_branch.last_revision(), |
141 | - branch.revid_of_upstream_version(package, version)) |
142 | + branch.pristine_upstream_source.version_as_revision(package, version)) |
143 | finally: |
144 | other_up_branch.unlock() |
145 | finally: |
146 | @@ -695,7 +680,7 @@ |
147 | :param version: the upstream version string |
148 | """ |
149 | assert isinstance(version, str) |
150 | - pull_revision = pull_branch.revid_of_upstream_version(package, version) |
151 | + pull_revision = pull_branch.pristine_upstream_source.version_as_revision(package, version) |
152 | mutter("Pulling upstream part of %s from revision %s" % \ |
153 | (version, pull_revision)) |
154 | assert self.pristine_upstream_tree is not None, \ |
155 | @@ -753,7 +738,7 @@ |
156 | "present in the upstream branch") |
157 | |
158 | def get_parents_with_upstream(self, package, version, versions, |
159 | - force_upstream_parent=False): |
160 | + tarballs, force_upstream_parent=False): |
161 | """Get the list of parents including any upstream parents. |
162 | |
163 | Further to get_parents this method includes any upstream parents |
164 | @@ -765,7 +750,7 @@ |
165 | If force_upstream_parent is True then the upstream parent will |
166 | be included, even if another parent is already using that |
167 | upstream. This is for use in cases where the .orig.tar.gz |
168 | - is different in two ditributions. |
169 | + is different in two distributions. |
170 | |
171 | :param version: the Version that we are currently importing. |
172 | :param versions: the list of Versions that are ancestors of |
173 | @@ -789,8 +774,8 @@ |
174 | break |
175 | real_parents = [p[2] for p in parents] |
176 | if need_upstream_parent: |
177 | - parent_revid = self.revid_of_upstream_version(package, |
178 | - version.upstream_version) |
179 | + parent_revid = self.pristine_upstream_source.version_as_revision(package, |
180 | + version.upstream_version, tarballs) |
181 | if len(parents) > 0: |
182 | real_parents.insert(1, parent_revid) |
183 | else: |
184 | @@ -833,46 +818,48 @@ |
185 | % (version, upstream_part, str(upstream_parents))) |
186 | assert self.pristine_upstream_tree is not None, \ |
187 | "Can't import upstream with no tree" |
188 | - if len(upstream_parents) > 0: |
189 | - parent_revid = upstream_parents[0] |
190 | - else: |
191 | - parent_revid = NULL_REVISION |
192 | - self.pristine_upstream_tree.pull(self.pristine_upstream_tree.branch, |
193 | - overwrite=True, stop_revision=parent_revid) |
194 | other_branches = self.get_other_branches() |
195 | - upstream_trees = [o.pristine_upstream_branch.basis_tree() |
196 | - for o in other_branches] |
197 | - target_tree = None |
198 | - if upstream_branch is not None: |
199 | - if upstream_revision is None: |
200 | - upstream_revision = upstream_branch.last_revision() |
201 | - self.pristine_upstream_branch.fetch(upstream_branch, |
202 | - last_revision=upstream_revision) |
203 | - upstream_branch.tags.merge_to(self.pristine_upstream_branch.tags) |
204 | - upstream_parents.append(upstream_revision) |
205 | - target_tree = self.pristine_upstream_branch.repository.revision_tree( |
206 | - upstream_revision) |
207 | - if file_ids_from is not None: |
208 | - upstream_trees = file_ids_from + upstream_trees |
209 | - if self.tree: |
210 | - self_tree = self.tree |
211 | - self_tree.lock_write() # might also be upstream tree for dh_make |
212 | - else: |
213 | - self_tree = self.get_branch_tip_revtree() |
214 | - self_tree.lock_read() |
215 | - try: |
216 | - import_dir(self.pristine_upstream_tree, upstream_part, |
217 | - file_ids_from=[self_tree] + upstream_trees, |
218 | - target_tree=target_tree) |
219 | - finally: |
220 | - self_tree.unlock() |
221 | - revprops = {} |
222 | ret = [] |
223 | for (tarball, component, md5) in upstream_tarballs: |
224 | + upstream_trees = [o.pristine_upstream_branch.basis_tree() |
225 | + for o in other_branches] |
226 | + target_tree = None |
227 | + if upstream_branch is not None: |
228 | + if upstream_revision is None: |
229 | + upstream_revision = upstream_branch.last_revision() |
230 | + self.pristine_upstream_branch.fetch(upstream_branch, |
231 | + last_revision=upstream_revision) |
232 | + upstream_branch.tags.merge_to(self.pristine_upstream_branch.tags) |
233 | + upstream_parents.append(upstream_revision) |
234 | + target_tree = self.pristine_upstream_branch.repository.revision_tree( |
235 | + upstream_revision) |
236 | + if file_ids_from is not None: |
237 | + upstream_trees = file_ids_from + upstream_trees |
238 | + if self.tree: |
239 | + self_tree = self.tree |
240 | + self_tree.lock_write() # might also be upstream tree for dh_make |
241 | + else: |
242 | + self_tree = self.branch.basis_tree() |
243 | + self_tree.lock_read() |
244 | + if len(upstream_parents) > 0: |
245 | + parent_revid = upstream_parents[0] |
246 | + else: |
247 | + parent_revid = NULL_REVISION |
248 | + self.pristine_upstream_tree.pull(self.pristine_upstream_tree.branch, |
249 | + overwrite=True, stop_revision=parent_revid) |
250 | + if component is None: |
251 | + path = upstream_part |
252 | + else: |
253 | + path = os.path.join(upstream_part, component) |
254 | + try: |
255 | + import_dir(self.pristine_upstream_tree, path, |
256 | + file_ids_from=[self_tree] + upstream_trees, |
257 | + target_tree=target_tree) |
258 | + finally: |
259 | + self_tree.unlock() |
260 | (tag, revid) = self.pristine_upstream_source.import_component_tarball( |
261 | - package, version, self.pristine_upstream_tree, component, |
262 | - md5, tarball, author=author, timestamp=timestamp, |
263 | - parent_ids=upstream_parents) |
264 | + package, version, self.pristine_upstream_tree, upstream_parents, component, |
265 | + md5, tarball, author=author, timestamp=timestamp) |
266 | ret.append((component, tag, revid)) |
267 | self.branch.fetch(self.pristine_upstream_branch) |
268 | self.branch.tags.set_tag(tag, revid) |
269 | @@ -902,12 +889,8 @@ |
270 | finally: |
271 | shutil.rmtree(tarball_dir) |
272 | |
273 | - def get_branch_tip_revtree(self): |
274 | - return self.branch.repository.revision_tree( |
275 | - self.branch.last_revision()) |
276 | - |
277 | def _mark_native_config(self, native): |
278 | - poss_native_tree = self.get_branch_tip_revtree() |
279 | + poss_native_tree = self.branch.basis_tree() |
280 | current_native = self._is_tree_native(poss_native_tree) |
281 | current_config = self._default_config_for_tree(poss_native_tree) |
282 | dirname = os.path.join(self.tree.basedir, '.bzr-builddeb') |
283 | @@ -1069,7 +1052,7 @@ |
284 | pull_branch = pull_parents[1][0] |
285 | pull_version = pull_parents[1][1] |
286 | if not pull_branch.is_version_native(pull_version): |
287 | - pull_revid = pull_branch.revid_of_upstream_version( |
288 | + pull_revid = pull_branch.pristine_upstream_source.version_as_revision( |
289 | package, pull_version.upstream_version) |
290 | mutter("Initialising upstream from %s, version %s", |
291 | str(pull_branch), str(pull_version)) |
292 | @@ -1142,7 +1125,7 @@ |
293 | else: |
294 | mutter("We already have the needed upstream part") |
295 | parents = self.get_parents_with_upstream(package, version, versions, |
296 | - force_upstream_parent=imported_upstream) |
297 | + upstream_tarballs, force_upstream_parent=imported_upstream) |
298 | # Now we have the list of parents we need to import the .diff.gz |
299 | self.import_debian(debian_part, version, parents, md5, |
300 | timestamp=timestamp, file_ids_from=file_ids_from) |
301 | @@ -1307,7 +1290,7 @@ |
302 | if self.tree: |
303 | root_id = self.tree.path2id('') |
304 | else: |
305 | - tip = self.get_branch_tip_revtree() |
306 | + tip = self.branch.basis_tree() |
307 | tip.lock_read() |
308 | try: |
309 | root_id = tip.path2id('') |
310 | |
311 | === modified file 'tests/test_import_dsc.py' |
312 | --- tests/test_import_dsc.py 2011-06-28 08:41:44 +0000 |
313 | +++ tests/test_import_dsc.py 2011-07-18 10:01:28 +0000 |
314 | @@ -203,14 +203,14 @@ |
315 | db.tag_version(version) |
316 | self.assertEqual(db.revid_of_version(version), revid) |
317 | |
318 | - def test_revid_of_upstream_version(self): |
319 | + def test_upstream_version_as_revid(self): |
320 | db = self.db1 |
321 | tree = self.up_tree1 |
322 | version = "0.1" |
323 | revid = tree.commit("one") |
324 | db.tag_upstream_version(version) |
325 | self.assertEqual( |
326 | - db.revid_of_upstream_version("package", version), revid) |
327 | + db.pristine_upstream_source.version_as_revision("package", version), revid) |
328 | |
329 | def test_contained_versions(self): |
330 | db = self.db1 |
331 | @@ -401,13 +401,13 @@ |
332 | up_revid = self.up_tree1.commit("one") |
333 | db.tag_upstream_version(version1.upstream_version) |
334 | self.assertEqual( |
335 | - db.get_parents_with_upstream("package", version1, [version1]), |
336 | + db.get_parents_with_upstream("package", version1, [version1], None), |
337 | [up_revid]) |
338 | db = self.db2 |
339 | self.up_tree2.pull(self.up_tree1.branch) |
340 | db.tag_upstream_version(version1.upstream_version) |
341 | self.assertEqual( |
342 | - db.get_parents_with_upstream("package", version1, [version1]), |
343 | + db.get_parents_with_upstream("package", version1, [version1], None), |
344 | [up_revid]) |
345 | |
346 | def test_get_parents_with_upstream_second_version(self): |
347 | @@ -420,7 +420,7 @@ |
348 | db.tag_upstream_version(version1.upstream_version) |
349 | # No upstream parent |
350 | self.assertEqual(db.get_parents_with_upstream( |
351 | - "package", version2, [version2, version1]), [revid1]) |
352 | + "package", version2, [version2, version1], None), [revid1]) |
353 | |
354 | def test_get_parents_with_upstream_merge_from_lesser(self): |
355 | version1 = Version("0.1-1") |
356 | @@ -437,7 +437,7 @@ |
357 | versions = [version3, version1, version2] |
358 | # No upstream parent |
359 | self.assertEqual(self.db2.get_parents_with_upstream( |
360 | - "package", version3, versions), [revid2, revid1]) |
361 | + "package", version3, versions, None), [revid2, revid1]) |
362 | |
363 | def test_get_parents_with_upstream_merge_from_greater(self): |
364 | version1 = Version("0.1-1") |
365 | @@ -454,7 +454,7 @@ |
366 | versions = [version3, version2, version1] |
367 | # No upstream parent |
368 | self.assertEqual(self.db1.get_parents_with_upstream( |
369 | - "package", version3, versions), [revid1, revid2]) |
370 | + "package", version3, versions, None), [revid1, revid2]) |
371 | |
372 | def test_get_parents_with_upstream_new_upstream_import(self): |
373 | version1 = Version("0.1-1") |
374 | @@ -470,7 +470,7 @@ |
375 | versions = [version2, version1] |
376 | # Upstream parent as it is new upstream version |
377 | self.assertEqual(self.db2.get_parents_with_upstream( |
378 | - "package", version2, versions), [revid1, up_revid2]) |
379 | + "package", version2, versions, None), [revid1, up_revid2]) |
380 | |
381 | def test_get_parents_merge_new_upstream_from_lesser(self): |
382 | version1 = Version("0.1-1") |
383 | @@ -494,7 +494,7 @@ |
384 | versions = [version4, version3, version2, version1] |
385 | # no upstream parent as the lesser branch has already merged it |
386 | self.assertEqual(self.db2.get_parents_with_upstream( |
387 | - "package", version4, versions), [revid2, revid3]) |
388 | + "package", version4, versions, None), [revid2, revid3]) |
389 | |
390 | def test_get_parents_with_upstream_force_upstream(self): |
391 | version1 = Version("0.1-1") |
392 | @@ -509,7 +509,7 @@ |
393 | # a previous test checked that this wouldn't give an |
394 | # upstream parent, but we are requiring one. |
395 | self.assertEqual(self.db2.get_parents_with_upstream( |
396 | - "package", version2, versions, force_upstream_parent=True), |
397 | + "package", version2, versions, None, force_upstream_parent=True), |
398 | [revid1, up_revid2]) |
399 | |
400 | def test_get_parents_with_upstream_sync_when_diverged(self): |
401 | @@ -530,7 +530,7 @@ |
402 | # This is a sync but we are diverged so we should get two |
403 | # parents |
404 | self.assertEqual(self.db2.get_parents_with_upstream( |
405 | - "package", version3, versions), [revid2, revid3]) |
406 | + "package", version3, versions, None), [revid2, revid3]) |
407 | |
408 | def test_get_parents_with_upstream_sync_new_upstream(self): |
409 | version1 = Version("0.1-1") |
410 | @@ -553,7 +553,7 @@ |
411 | # parents. There should be no upstream as the synced |
412 | # version will already have it. |
413 | self.assertEqual(self.db2.get_parents_with_upstream( |
414 | - "package", version3, versions), [revid2, revid3]) |
415 | + "package", version3, versions, None), [revid2, revid3]) |
416 | |
417 | def test_get_parents_with_upstream_sync_new_upstream_force(self): |
418 | version1 = Version("0.1-1") |
419 | @@ -580,7 +580,7 @@ |
420 | # when we fake-sync, but we are forcing one here. |
421 | #TODO: should the upstream parent be second or third? |
422 | self.assertEqual(self.db2.get_parents_with_upstream( |
423 | - "package", version3, versions, force_upstream_parent=True), |
424 | + "package", version3, versions, None, force_upstream_parent=True), |
425 | [revid2, up_revid3, revid3]) |
426 | |
427 | def test_branch_to_pull_version_from(self): |
428 | @@ -700,7 +700,7 @@ |
429 | self.assertEqual(self.tree2.branch.last_revision(), revid) |
430 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) |
431 | self.assertEqual(self.db2.revid_of_version(version), revid) |
432 | - self.assertEqual(self.db2.revid_of_upstream_version( |
433 | + self.assertEqual(self.db2.pristine_upstream_source.version_as_revision( |
434 | "package", version.upstream_version), up_revid) |
435 | |
436 | def test_pull_from_lesser_branch_with_upstream(self): |
437 | @@ -716,7 +716,7 @@ |
438 | self.assertEqual(self.tree2.branch.last_revision(), revid) |
439 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) |
440 | self.assertEqual(self.db2.revid_of_version(version), revid) |
441 | - self.assertEqual(self.db2.revid_of_upstream_version( |
442 | + self.assertEqual(self.db2.pristine_upstream_source.version_as_revision( |
443 | "package", version.upstream_version), up_revid) |
444 | |
445 | def test_pull_upstream_from_branch(self): |
446 | @@ -727,7 +727,7 @@ |
447 | self.assertNotEqual(self.up_tree2.branch.last_revision(), up_revid) |
448 | self.db2.pull_upstream_from_branch(self.db1, "package", version) |
449 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) |
450 | - self.assertEqual(self.db2.revid_of_upstream_version("package", version), |
451 | + self.assertEqual(self.db2.pristine_upstream_source.version_as_revision("package", version), |
452 | up_revid) |
453 | |
454 | def check_changes(self, changes, added=[], removed=[], modified=[], |
455 | @@ -784,7 +784,7 @@ |
456 | branch = tree.branch |
457 | rh = branch.revision_history() |
458 | self.assertEqual(len(rh), 1) |
459 | - self.assertEqual(self.db1.revid_of_upstream_version( |
460 | + self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( |
461 | "package", version.upstream_version), rh[0]) |
462 | rev = branch.repository.get_revision(rh[0]) |
463 | self.assertEqual(rev.message, |
464 | @@ -823,7 +823,7 @@ |
465 | rh = branch.revision_history() |
466 | self.assertEqual(len(rh), 2) |
467 | self.assertEqual( |
468 | - self.db1.revid_of_upstream_version("package", version2.upstream_version), rh[1]) |
469 | + self.db1.pristine_upstream_source.version_as_revision("package", version2.upstream_version), rh[1]) |
470 | rev = branch.repository.get_revision(rh[1]) |
471 | self.assertEqual(rev.message, |
472 | "Import upstream version %s" % str(version2.upstream_version)) |
473 | @@ -854,7 +854,7 @@ |
474 | branch = tree.branch |
475 | rh = branch.revision_history() |
476 | self.assertEqual(len(rh), 1) |
477 | - self.assertEqual(self.db1.revid_of_upstream_version( |
478 | + self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( |
479 | "package", version.upstream_version), rh[0]) |
480 | rev = branch.repository.get_revision(rh[0]) |
481 | self.assertEqual(rev.message, |
482 | @@ -882,7 +882,7 @@ |
483 | branch = tree.branch |
484 | rh = branch.revision_history() |
485 | self.assertEqual(len(rh), 1) |
486 | - self.assertEqual(self.db1.revid_of_upstream_version( |
487 | + self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( |
488 | "package", version.upstream_version), rh[0]) |
489 | rev = branch.repository.get_revision(rh[0]) |
490 | self.assertEqual(rev.message, |
491 | @@ -916,7 +916,7 @@ |
492 | branch = tree.branch |
493 | rh = branch.revision_history() |
494 | self.assertEqual(len(rh), 1) |
495 | - self.assertEqual(self.db1.revid_of_upstream_version( |
496 | + self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( |
497 | "package", version.upstream_version), rh[0]) |
498 | rev = branch.repository.get_revision(rh[0]) |
499 | self.assertEqual(rev.message, |
500 | @@ -1356,7 +1356,7 @@ |
501 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) |
502 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) |
503 | self.assertEqual( |
504 | - self.db1.revid_of_upstream_version("package", version1.upstream_version), |
505 | + self.db1.pristine_upstream_source.version_as_revision("package", version1.upstream_version), |
506 | up_rh1[0]) |
507 | self.tree1.lock_read() |
508 | self.addCleanup(self.tree1.unlock) |
509 | @@ -1409,10 +1409,10 @@ |
510 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) |
511 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) |
512 | self.assertEqual( |
513 | - self.db1.revid_of_upstream_version("package", version1.upstream_version), |
514 | + self.db1.pristine_upstream_source.version_as_revision("package", version1.upstream_version), |
515 | up_rh1[0]) |
516 | self.assertEqual( |
517 | - self.db1.revid_of_upstream_version("package", version3.upstream_version), |
518 | + self.db1.pristine_upstream_source.version_as_revision("package", version3.upstream_version), |
519 | up_rh1[1]) |
520 | self.tree1.lock_read() |
521 | self.addCleanup(self.tree1.unlock) |
522 | @@ -1464,10 +1464,10 @@ |
523 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) |
524 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) |
525 | self.assertEqual( |
526 | - self.db1.revid_of_upstream_version("package", version1.upstream_version), |
527 | + self.db1.pristine_upstream_source.version_as_revision("package", version1.upstream_version), |
528 | up_rh1[0]) |
529 | self.assertEqual( |
530 | - self.db1.revid_of_upstream_version("package", version3.upstream_version), |
531 | + self.db1.pristine_upstream_source.version_as_revision("package", version3.upstream_version), |
532 | up_rh1[1]) |
533 | self.tree1.lock_read() |
534 | self.addCleanup(self.tree1.unlock) |
535 | |
536 | === modified file 'upstream/pristinetar.py' |
537 | --- upstream/pristinetar.py 2011-06-28 08:41:44 +0000 |
538 | +++ upstream/pristinetar.py 2011-07-18 10:01:28 +0000 |
539 | @@ -156,9 +156,29 @@ |
540 | self.branch.tags.set_tag(tag_name, revid) |
541 | return tag_name, revid |
542 | |
543 | - def import_component_tarball(self, package, version, tree, component=None, |
544 | - md5=None, tarball=None, author=None, timestamp=None, |
545 | - parent_ids=None): |
546 | + def import_tarballs(self, package, version, tree, parent_ids, tarballs, |
547 | + timestamp=None, author=None): |
548 | + """Import the upstream tarballs. |
549 | + |
550 | + :param package: Package name |
551 | + :param version: Package version |
552 | + :param path: Path with tree to import |
553 | + :param parent_ids: Parent revisions |
554 | + :param tarballs: List of (path, component, md5) |
555 | + :param timestamp: Optional timestamp for new commits |
556 | + :param author: Optional author for new commits |
557 | + :return: List of tuples with (component, tag, revid) |
558 | + """ |
559 | + ret = [] |
560 | + for (tarball, component, md5) in tarballs: |
561 | + (tag, revid) = self.import_component_tarball( |
562 | + package, version, tree, parent_ids, component, |
563 | + md5, tarball, author=author, timestamp=timestamp) |
564 | + ret.append((component, tag, revid)) |
565 | + return ret |
566 | + |
567 | + def import_component_tarball(self, package, version, tree, parent_ids, |
568 | + component=None, md5=None, tarball=None, author=None, timestamp=None): |
569 | """Import a tarball. |
570 | |
571 | :param package: Package name |
572 | @@ -217,10 +237,7 @@ |
573 | def fetch_tarballs(self, package, version, target_dir): |
574 | return [self.fetch_component_tarball(package, version, None, target_dir)] |
575 | |
576 | - def _has_version_component(self, tag_name, md5=None): |
577 | - if not self.branch.tags.has_tag(tag_name): |
578 | - return False |
579 | - revid = self.branch.tags.lookup_tag(tag_name) |
580 | + def _has_revision(self, revid, md5=None): |
581 | self.branch.lock_read() |
582 | try: |
583 | graph = self.branch.repository.get_graph() |
584 | @@ -234,8 +251,9 @@ |
585 | try: |
586 | return rev.properties['deb-md5'] == md5 |
587 | except KeyError: |
588 | - warning("tag %s present in branch, but there is no " |
589 | - "associated 'deb-md5' property" % tag_name) |
590 | + warning("tag present in branch, but there is no " |
591 | + "associated 'deb-md5' property in associated " |
592 | + "revision %s", revid) |
593 | return True |
594 | |
595 | def version_as_revision(self, package, version, tarballs=None): |
596 | @@ -244,13 +262,19 @@ |
597 | elif len(tarballs) > 1: |
598 | raise MultipleUpstreamTarballsNotSupported() |
599 | else: |
600 | - return self.version_component_as_revision(package, version, tarballs[0][1]) |
601 | + return self.version_component_as_revision(package, version, tarballs[0][1], |
602 | + tarballs[0][2]) |
603 | |
604 | - def version_component_as_revision(self, package, version, component, tarballs=None): |
605 | + def version_component_as_revision(self, package, version, component, md5=None): |
606 | assert isinstance(version, str) |
607 | for tag_name in self.possible_tag_names(version, component=component): |
608 | - if self._has_version_component(tag_name, tarballs): |
609 | - return self.branch.tags.lookup_tag(tag_name) |
610 | + try: |
611 | + revid = self.branch.tags.lookup_tag(tag_name) |
612 | + except NoSuchTag: |
613 | + continue |
614 | + else: |
615 | + if self._has_revision(revid, md5=md5): |
616 | + return revid |
617 | tag_name = self.tag_name(version, component=component) |
618 | try: |
619 | return self.branch.tags.lookup_tag(tag_name) |
620 | @@ -269,8 +293,13 @@ |
621 | def has_version_component(self, package, version, component, md5=None): |
622 | assert isinstance(version, str), str(type(version)) |
623 | for tag_name in self.possible_tag_names(version, component=component): |
624 | - if self._has_version_component(tag_name, md5=md5): |
625 | - return True |
626 | + try: |
627 | + revid = self.branch.tags.lookup_tag(tag_name) |
628 | + except NoSuchTag: |
629 | + continue |
630 | + else: |
631 | + if self._has_revision(revid, md5=md5): |
632 | + return True |
633 | return False |
634 | |
635 | def possible_tag_names(self, version, component): |