Merge lp:~jelmer/bzr-builddeb/multi-tarball-pt7 into lp:bzr-builddeb
- multi-tarball-pt7
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Merged |
---|---|
Approved by: | James Westby |
Approved revision: | 596 |
Merged at revision: | 585 |
Proposed branch: | lp:~jelmer/bzr-builddeb/multi-tarball-pt7 |
Merge into: | lp:bzr-builddeb |
Diff against target: |
481 lines (+93/-99) 3 files modified
import_dsc.py (+46/-61) tests/test_import_dsc.py (+26/-26) upstream/pristinetar.py (+21/-12) |
To merge this branch: | bzr merge lp:~jelmer/bzr-builddeb/multi-tarball-pt7 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby | Approve | ||
Review via email:
|
Commit message
Description of the change
More work towards supporting multiple upstream tarballs.
This mainly simplifies some code, and makes us look directly at
pristine_
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
James Westby (james-w) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'import_dsc.py' | |||
2 | --- import_dsc.py 2011-06-28 08:41:44 +0000 | |||
3 | +++ import_dsc.py 2011-07-17 22:29:31 +0000 | |||
4 | @@ -277,25 +277,25 @@ | |||
5 | 277 | return str(version) | 277 | return str(version) |
6 | 278 | 278 | ||
7 | 279 | def _has_version(self, branch, tag_name, md5=None): | 279 | def _has_version(self, branch, tag_name, md5=None): |
27 | 280 | if branch.tags.has_tag(tag_name): | 280 | if not branch.tags.has_tag(tag_name): |
28 | 281 | revid = branch.tags.lookup_tag(tag_name) | 281 | return False |
29 | 282 | branch.lock_read() | 282 | revid = branch.tags.lookup_tag(tag_name) |
30 | 283 | try: | 283 | branch.lock_read() |
31 | 284 | graph = branch.repository.get_graph() | 284 | try: |
32 | 285 | if not graph.is_ancestor(revid, branch.last_revision()): | 285 | graph = branch.repository.get_graph() |
33 | 286 | return False | 286 | if not graph.is_ancestor(revid, branch.last_revision()): |
34 | 287 | finally: | 287 | return False |
35 | 288 | branch.unlock() | 288 | finally: |
36 | 289 | if md5 is None: | 289 | branch.unlock() |
37 | 290 | return True | 290 | if md5 is None: |
38 | 291 | rev = branch.repository.get_revision(revid) | 291 | return True |
39 | 292 | try: | 292 | rev = branch.repository.get_revision(revid) |
40 | 293 | return rev.properties['deb-md5'] == md5 | 293 | try: |
41 | 294 | except KeyError: | 294 | return rev.properties['deb-md5'] == md5 |
42 | 295 | warning("tag %s present in branch, but there is no " | 295 | except KeyError: |
43 | 296 | "associated 'deb-md5' property" % tag_name) | 296 | warning("tag %s present in branch, but there is no " |
44 | 297 | pass | 297 | "associated 'deb-md5' property" % tag_name) |
45 | 298 | return False | 298 | return False |
46 | 299 | 299 | ||
47 | 300 | def has_version(self, version, md5=None): | 300 | def has_version(self, version, md5=None): |
48 | 301 | """Whether this branch contains the package version specified. | 301 | """Whether this branch contains the package version specified. |
49 | @@ -409,18 +409,6 @@ | |||
50 | 409 | return self.branch.tags.lookup_tag(ubuntu_tag_name) | 409 | return self.branch.tags.lookup_tag(ubuntu_tag_name) |
51 | 410 | return self.branch.tags.lookup_tag(tag_name) | 410 | return self.branch.tags.lookup_tag(tag_name) |
52 | 411 | 411 | ||
53 | 412 | def revid_of_upstream_version(self, package, version, tarballs=None): | ||
54 | 413 | """Returns the revision id corresponding to the upstream version. | ||
55 | 414 | |||
56 | 415 | :param version: the Version object to extract the upstream version | ||
57 | 416 | from to retrieve the revid of. The upstream version must be | ||
58 | 417 | present in the upstream branch. | ||
59 | 418 | :return: the revision id corresponding to the upstream portion | ||
60 | 419 | of the version | ||
61 | 420 | """ | ||
62 | 421 | return self.pristine_upstream_source.version_as_revision(package, version, | ||
63 | 422 | tarballs) | ||
64 | 423 | |||
65 | 424 | def tag_version(self, version, revid=None): | 412 | def tag_version(self, version, revid=None): |
66 | 425 | """Tags the branch's last revision with the given version. | 413 | """Tags the branch's last revision with the given version. |
67 | 426 | 414 | ||
68 | @@ -506,6 +494,21 @@ | |||
69 | 506 | except KeyError: | 494 | except KeyError: |
70 | 507 | return False | 495 | return False |
71 | 508 | 496 | ||
72 | 497 | def can_pull_from_branch(self, branch, version, md5): | ||
73 | 498 | if not branch.has_version(version, md5=md5): | ||
74 | 499 | return False | ||
75 | 500 | |||
76 | 501 | # Check that they haven't diverged | ||
77 | 502 | branch.branch.lock_read() | ||
78 | 503 | try: | ||
79 | 504 | graph = branch.branch.repository.get_graph( | ||
80 | 505 | self.branch.repository) | ||
81 | 506 | return graph.is_ancestor(self.branch.last_revision(), | ||
82 | 507 | branch.revid_of_version(version)) | ||
83 | 508 | finally: | ||
84 | 509 | branch.branch.unlock() | ||
85 | 510 | |||
86 | 511 | |||
87 | 509 | def branch_to_pull_version_from(self, version, md5): | 512 | def branch_to_pull_version_from(self, version, md5): |
88 | 510 | """Checks whether this upload is a pull from a lesser branch. | 513 | """Checks whether this upload is a pull from a lesser branch. |
89 | 511 | 514 | ||
90 | @@ -531,29 +534,11 @@ | |||
91 | 531 | self.branch.lock_read() | 534 | self.branch.lock_read() |
92 | 532 | try: | 535 | try: |
93 | 533 | for branch in reversed(self.get_lesser_branches()): | 536 | for branch in reversed(self.get_lesser_branches()): |
105 | 534 | if branch.has_version(version, md5=md5): | 537 | if self.can_pull_from_branch(branch, version, md5): |
106 | 535 | # Check that they haven't diverged | 538 | return branch |
96 | 536 | branch.branch.lock_read() | ||
97 | 537 | try: | ||
98 | 538 | graph = branch.branch.repository.get_graph( | ||
99 | 539 | self.branch.repository) | ||
100 | 540 | if graph.is_ancestor(self.branch.last_revision(), | ||
101 | 541 | branch.revid_of_version(version)): | ||
102 | 542 | return branch | ||
103 | 543 | finally: | ||
104 | 544 | branch.branch.unlock() | ||
107 | 545 | for branch in self.get_greater_branches(): | 539 | for branch in self.get_greater_branches(): |
119 | 546 | if branch.has_version(version, md5=md5): | 540 | if self.can_pull_from_branch(branch, version, md5): |
120 | 547 | # Check that they haven't diverged | 541 | return branch |
110 | 548 | branch.branch.lock_read() | ||
111 | 549 | try: | ||
112 | 550 | graph = branch.branch.repository.get_graph( | ||
113 | 551 | self.branch.repository) | ||
114 | 552 | if graph.is_ancestor(self.branch.last_revision(), | ||
115 | 553 | branch.revid_of_version(version)): | ||
116 | 554 | return branch | ||
117 | 555 | finally: | ||
118 | 556 | branch.branch.unlock() | ||
121 | 557 | return None | 542 | return None |
122 | 558 | finally: | 543 | finally: |
123 | 559 | self.branch.unlock() | 544 | self.branch.unlock() |
124 | @@ -581,7 +566,7 @@ | |||
125 | 581 | graph = other_up_branch.repository.get_graph( | 566 | graph = other_up_branch.repository.get_graph( |
126 | 582 | up_branch.repository) | 567 | up_branch.repository) |
127 | 583 | return graph.is_ancestor(up_branch.last_revision(), | 568 | return graph.is_ancestor(up_branch.last_revision(), |
129 | 584 | branch.revid_of_upstream_version(package, version)) | 569 | branch.pristine_upstream_source.version_as_revision(package, version)) |
130 | 585 | finally: | 570 | finally: |
131 | 586 | other_up_branch.unlock() | 571 | other_up_branch.unlock() |
132 | 587 | finally: | 572 | finally: |
133 | @@ -695,7 +680,7 @@ | |||
134 | 695 | :param version: the upstream version string | 680 | :param version: the upstream version string |
135 | 696 | """ | 681 | """ |
136 | 697 | assert isinstance(version, str) | 682 | assert isinstance(version, str) |
138 | 698 | pull_revision = pull_branch.revid_of_upstream_version(package, version) | 683 | pull_revision = pull_branch.pristine_upstream_source.version_as_revision(package, version) |
139 | 699 | mutter("Pulling upstream part of %s from revision %s" % \ | 684 | mutter("Pulling upstream part of %s from revision %s" % \ |
140 | 700 | (version, pull_revision)) | 685 | (version, pull_revision)) |
141 | 701 | assert self.pristine_upstream_tree is not None, \ | 686 | assert self.pristine_upstream_tree is not None, \ |
142 | @@ -753,7 +738,7 @@ | |||
143 | 753 | "present in the upstream branch") | 738 | "present in the upstream branch") |
144 | 754 | 739 | ||
145 | 755 | def get_parents_with_upstream(self, package, version, versions, | 740 | def get_parents_with_upstream(self, package, version, versions, |
147 | 756 | force_upstream_parent=False): | 741 | tarballs, force_upstream_parent=False): |
148 | 757 | """Get the list of parents including any upstream parents. | 742 | """Get the list of parents including any upstream parents. |
149 | 758 | 743 | ||
150 | 759 | Further to get_parents this method includes any upstream parents | 744 | Further to get_parents this method includes any upstream parents |
151 | @@ -765,7 +750,7 @@ | |||
152 | 765 | If force_upstream_parent is True then the upstream parent will | 750 | If force_upstream_parent is True then the upstream parent will |
153 | 766 | be included, even if another parent is already using that | 751 | be included, even if another parent is already using that |
154 | 767 | upstream. This is for use in cases where the .orig.tar.gz | 752 | upstream. This is for use in cases where the .orig.tar.gz |
156 | 768 | is different in two ditributions. | 753 | is different in two distributions. |
157 | 769 | 754 | ||
158 | 770 | :param version: the Version that we are currently importing. | 755 | :param version: the Version that we are currently importing. |
159 | 771 | :param versions: the list of Versions that are ancestors of | 756 | :param versions: the list of Versions that are ancestors of |
160 | @@ -789,8 +774,8 @@ | |||
161 | 789 | break | 774 | break |
162 | 790 | real_parents = [p[2] for p in parents] | 775 | real_parents = [p[2] for p in parents] |
163 | 791 | if need_upstream_parent: | 776 | if need_upstream_parent: |
166 | 792 | parent_revid = self.revid_of_upstream_version(package, | 777 | parent_revid = self.pristine_upstream_source.version_as_revision(package, |
167 | 793 | version.upstream_version) | 778 | version.upstream_version, tarballs) |
168 | 794 | if len(parents) > 0: | 779 | if len(parents) > 0: |
169 | 795 | real_parents.insert(1, parent_revid) | 780 | real_parents.insert(1, parent_revid) |
170 | 796 | else: | 781 | else: |
171 | @@ -1069,7 +1054,7 @@ | |||
172 | 1069 | pull_branch = pull_parents[1][0] | 1054 | pull_branch = pull_parents[1][0] |
173 | 1070 | pull_version = pull_parents[1][1] | 1055 | pull_version = pull_parents[1][1] |
174 | 1071 | if not pull_branch.is_version_native(pull_version): | 1056 | if not pull_branch.is_version_native(pull_version): |
176 | 1072 | pull_revid = pull_branch.revid_of_upstream_version( | 1057 | pull_revid = pull_branch.pristine_upstream_source.version_as_revision( |
177 | 1073 | package, pull_version.upstream_version) | 1058 | package, pull_version.upstream_version) |
178 | 1074 | mutter("Initialising upstream from %s, version %s", | 1059 | mutter("Initialising upstream from %s, version %s", |
179 | 1075 | str(pull_branch), str(pull_version)) | 1060 | str(pull_branch), str(pull_version)) |
180 | @@ -1142,7 +1127,7 @@ | |||
181 | 1142 | else: | 1127 | else: |
182 | 1143 | mutter("We already have the needed upstream part") | 1128 | mutter("We already have the needed upstream part") |
183 | 1144 | parents = self.get_parents_with_upstream(package, version, versions, | 1129 | parents = self.get_parents_with_upstream(package, version, versions, |
185 | 1145 | force_upstream_parent=imported_upstream) | 1130 | upstream_tarballs, force_upstream_parent=imported_upstream) |
186 | 1146 | # Now we have the list of parents we need to import the .diff.gz | 1131 | # Now we have the list of parents we need to import the .diff.gz |
187 | 1147 | self.import_debian(debian_part, version, parents, md5, | 1132 | self.import_debian(debian_part, version, parents, md5, |
188 | 1148 | timestamp=timestamp, file_ids_from=file_ids_from) | 1133 | timestamp=timestamp, file_ids_from=file_ids_from) |
189 | 1149 | 1134 | ||
190 | === modified file 'tests/test_import_dsc.py' | |||
191 | --- tests/test_import_dsc.py 2011-06-28 08:41:44 +0000 | |||
192 | +++ tests/test_import_dsc.py 2011-07-17 22:29:31 +0000 | |||
193 | @@ -203,14 +203,14 @@ | |||
194 | 203 | db.tag_version(version) | 203 | db.tag_version(version) |
195 | 204 | self.assertEqual(db.revid_of_version(version), revid) | 204 | self.assertEqual(db.revid_of_version(version), revid) |
196 | 205 | 205 | ||
198 | 206 | def test_revid_of_upstream_version(self): | 206 | def test_upstream_version_as_revid(self): |
199 | 207 | db = self.db1 | 207 | db = self.db1 |
200 | 208 | tree = self.up_tree1 | 208 | tree = self.up_tree1 |
201 | 209 | version = "0.1" | 209 | version = "0.1" |
202 | 210 | revid = tree.commit("one") | 210 | revid = tree.commit("one") |
203 | 211 | db.tag_upstream_version(version) | 211 | db.tag_upstream_version(version) |
204 | 212 | self.assertEqual( | 212 | self.assertEqual( |
206 | 213 | db.revid_of_upstream_version("package", version), revid) | 213 | db.pristine_upstream_source.version_as_revision("package", version), revid) |
207 | 214 | 214 | ||
208 | 215 | def test_contained_versions(self): | 215 | def test_contained_versions(self): |
209 | 216 | db = self.db1 | 216 | db = self.db1 |
210 | @@ -401,13 +401,13 @@ | |||
211 | 401 | up_revid = self.up_tree1.commit("one") | 401 | up_revid = self.up_tree1.commit("one") |
212 | 402 | db.tag_upstream_version(version1.upstream_version) | 402 | db.tag_upstream_version(version1.upstream_version) |
213 | 403 | self.assertEqual( | 403 | self.assertEqual( |
215 | 404 | db.get_parents_with_upstream("package", version1, [version1]), | 404 | db.get_parents_with_upstream("package", version1, [version1], None), |
216 | 405 | [up_revid]) | 405 | [up_revid]) |
217 | 406 | db = self.db2 | 406 | db = self.db2 |
218 | 407 | self.up_tree2.pull(self.up_tree1.branch) | 407 | self.up_tree2.pull(self.up_tree1.branch) |
219 | 408 | db.tag_upstream_version(version1.upstream_version) | 408 | db.tag_upstream_version(version1.upstream_version) |
220 | 409 | self.assertEqual( | 409 | self.assertEqual( |
222 | 410 | db.get_parents_with_upstream("package", version1, [version1]), | 410 | db.get_parents_with_upstream("package", version1, [version1], None), |
223 | 411 | [up_revid]) | 411 | [up_revid]) |
224 | 412 | 412 | ||
225 | 413 | def test_get_parents_with_upstream_second_version(self): | 413 | def test_get_parents_with_upstream_second_version(self): |
226 | @@ -420,7 +420,7 @@ | |||
227 | 420 | db.tag_upstream_version(version1.upstream_version) | 420 | db.tag_upstream_version(version1.upstream_version) |
228 | 421 | # No upstream parent | 421 | # No upstream parent |
229 | 422 | self.assertEqual(db.get_parents_with_upstream( | 422 | self.assertEqual(db.get_parents_with_upstream( |
231 | 423 | "package", version2, [version2, version1]), [revid1]) | 423 | "package", version2, [version2, version1], None), [revid1]) |
232 | 424 | 424 | ||
233 | 425 | def test_get_parents_with_upstream_merge_from_lesser(self): | 425 | def test_get_parents_with_upstream_merge_from_lesser(self): |
234 | 426 | version1 = Version("0.1-1") | 426 | version1 = Version("0.1-1") |
235 | @@ -437,7 +437,7 @@ | |||
236 | 437 | versions = [version3, version1, version2] | 437 | versions = [version3, version1, version2] |
237 | 438 | # No upstream parent | 438 | # No upstream parent |
238 | 439 | self.assertEqual(self.db2.get_parents_with_upstream( | 439 | self.assertEqual(self.db2.get_parents_with_upstream( |
240 | 440 | "package", version3, versions), [revid2, revid1]) | 440 | "package", version3, versions, None), [revid2, revid1]) |
241 | 441 | 441 | ||
242 | 442 | def test_get_parents_with_upstream_merge_from_greater(self): | 442 | def test_get_parents_with_upstream_merge_from_greater(self): |
243 | 443 | version1 = Version("0.1-1") | 443 | version1 = Version("0.1-1") |
244 | @@ -454,7 +454,7 @@ | |||
245 | 454 | versions = [version3, version2, version1] | 454 | versions = [version3, version2, version1] |
246 | 455 | # No upstream parent | 455 | # No upstream parent |
247 | 456 | self.assertEqual(self.db1.get_parents_with_upstream( | 456 | self.assertEqual(self.db1.get_parents_with_upstream( |
249 | 457 | "package", version3, versions), [revid1, revid2]) | 457 | "package", version3, versions, None), [revid1, revid2]) |
250 | 458 | 458 | ||
251 | 459 | def test_get_parents_with_upstream_new_upstream_import(self): | 459 | def test_get_parents_with_upstream_new_upstream_import(self): |
252 | 460 | version1 = Version("0.1-1") | 460 | version1 = Version("0.1-1") |
253 | @@ -470,7 +470,7 @@ | |||
254 | 470 | versions = [version2, version1] | 470 | versions = [version2, version1] |
255 | 471 | # Upstream parent as it is new upstream version | 471 | # Upstream parent as it is new upstream version |
256 | 472 | self.assertEqual(self.db2.get_parents_with_upstream( | 472 | self.assertEqual(self.db2.get_parents_with_upstream( |
258 | 473 | "package", version2, versions), [revid1, up_revid2]) | 473 | "package", version2, versions, None), [revid1, up_revid2]) |
259 | 474 | 474 | ||
260 | 475 | def test_get_parents_merge_new_upstream_from_lesser(self): | 475 | def test_get_parents_merge_new_upstream_from_lesser(self): |
261 | 476 | version1 = Version("0.1-1") | 476 | version1 = Version("0.1-1") |
262 | @@ -494,7 +494,7 @@ | |||
263 | 494 | versions = [version4, version3, version2, version1] | 494 | versions = [version4, version3, version2, version1] |
264 | 495 | # no upstream parent as the lesser branch has already merged it | 495 | # no upstream parent as the lesser branch has already merged it |
265 | 496 | self.assertEqual(self.db2.get_parents_with_upstream( | 496 | self.assertEqual(self.db2.get_parents_with_upstream( |
267 | 497 | "package", version4, versions), [revid2, revid3]) | 497 | "package", version4, versions, None), [revid2, revid3]) |
268 | 498 | 498 | ||
269 | 499 | def test_get_parents_with_upstream_force_upstream(self): | 499 | def test_get_parents_with_upstream_force_upstream(self): |
270 | 500 | version1 = Version("0.1-1") | 500 | version1 = Version("0.1-1") |
271 | @@ -509,7 +509,7 @@ | |||
272 | 509 | # a previous test checked that this wouldn't give an | 509 | # a previous test checked that this wouldn't give an |
273 | 510 | # upstream parent, but we are requiring one. | 510 | # upstream parent, but we are requiring one. |
274 | 511 | self.assertEqual(self.db2.get_parents_with_upstream( | 511 | self.assertEqual(self.db2.get_parents_with_upstream( |
276 | 512 | "package", version2, versions, force_upstream_parent=True), | 512 | "package", version2, versions, None, force_upstream_parent=True), |
277 | 513 | [revid1, up_revid2]) | 513 | [revid1, up_revid2]) |
278 | 514 | 514 | ||
279 | 515 | def test_get_parents_with_upstream_sync_when_diverged(self): | 515 | def test_get_parents_with_upstream_sync_when_diverged(self): |
280 | @@ -530,7 +530,7 @@ | |||
281 | 530 | # This is a sync but we are diverged so we should get two | 530 | # This is a sync but we are diverged so we should get two |
282 | 531 | # parents | 531 | # parents |
283 | 532 | self.assertEqual(self.db2.get_parents_with_upstream( | 532 | self.assertEqual(self.db2.get_parents_with_upstream( |
285 | 533 | "package", version3, versions), [revid2, revid3]) | 533 | "package", version3, versions, None), [revid2, revid3]) |
286 | 534 | 534 | ||
287 | 535 | def test_get_parents_with_upstream_sync_new_upstream(self): | 535 | def test_get_parents_with_upstream_sync_new_upstream(self): |
288 | 536 | version1 = Version("0.1-1") | 536 | version1 = Version("0.1-1") |
289 | @@ -553,7 +553,7 @@ | |||
290 | 553 | # parents. There should be no upstream as the synced | 553 | # parents. There should be no upstream as the synced |
291 | 554 | # version will already have it. | 554 | # version will already have it. |
292 | 555 | self.assertEqual(self.db2.get_parents_with_upstream( | 555 | self.assertEqual(self.db2.get_parents_with_upstream( |
294 | 556 | "package", version3, versions), [revid2, revid3]) | 556 | "package", version3, versions, None), [revid2, revid3]) |
295 | 557 | 557 | ||
296 | 558 | def test_get_parents_with_upstream_sync_new_upstream_force(self): | 558 | def test_get_parents_with_upstream_sync_new_upstream_force(self): |
297 | 559 | version1 = Version("0.1-1") | 559 | version1 = Version("0.1-1") |
298 | @@ -580,7 +580,7 @@ | |||
299 | 580 | # when we fake-sync, but we are forcing one here. | 580 | # when we fake-sync, but we are forcing one here. |
300 | 581 | #TODO: should the upstream parent be second or third? | 581 | #TODO: should the upstream parent be second or third? |
301 | 582 | self.assertEqual(self.db2.get_parents_with_upstream( | 582 | self.assertEqual(self.db2.get_parents_with_upstream( |
303 | 583 | "package", version3, versions, force_upstream_parent=True), | 583 | "package", version3, versions, None, force_upstream_parent=True), |
304 | 584 | [revid2, up_revid3, revid3]) | 584 | [revid2, up_revid3, revid3]) |
305 | 585 | 585 | ||
306 | 586 | def test_branch_to_pull_version_from(self): | 586 | def test_branch_to_pull_version_from(self): |
307 | @@ -700,7 +700,7 @@ | |||
308 | 700 | self.assertEqual(self.tree2.branch.last_revision(), revid) | 700 | self.assertEqual(self.tree2.branch.last_revision(), revid) |
309 | 701 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) | 701 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) |
310 | 702 | self.assertEqual(self.db2.revid_of_version(version), revid) | 702 | self.assertEqual(self.db2.revid_of_version(version), revid) |
312 | 703 | self.assertEqual(self.db2.revid_of_upstream_version( | 703 | self.assertEqual(self.db2.pristine_upstream_source.version_as_revision( |
313 | 704 | "package", version.upstream_version), up_revid) | 704 | "package", version.upstream_version), up_revid) |
314 | 705 | 705 | ||
315 | 706 | def test_pull_from_lesser_branch_with_upstream(self): | 706 | def test_pull_from_lesser_branch_with_upstream(self): |
316 | @@ -716,7 +716,7 @@ | |||
317 | 716 | self.assertEqual(self.tree2.branch.last_revision(), revid) | 716 | self.assertEqual(self.tree2.branch.last_revision(), revid) |
318 | 717 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) | 717 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) |
319 | 718 | self.assertEqual(self.db2.revid_of_version(version), revid) | 718 | self.assertEqual(self.db2.revid_of_version(version), revid) |
321 | 719 | self.assertEqual(self.db2.revid_of_upstream_version( | 719 | self.assertEqual(self.db2.pristine_upstream_source.version_as_revision( |
322 | 720 | "package", version.upstream_version), up_revid) | 720 | "package", version.upstream_version), up_revid) |
323 | 721 | 721 | ||
324 | 722 | def test_pull_upstream_from_branch(self): | 722 | def test_pull_upstream_from_branch(self): |
325 | @@ -727,7 +727,7 @@ | |||
326 | 727 | self.assertNotEqual(self.up_tree2.branch.last_revision(), up_revid) | 727 | self.assertNotEqual(self.up_tree2.branch.last_revision(), up_revid) |
327 | 728 | self.db2.pull_upstream_from_branch(self.db1, "package", version) | 728 | self.db2.pull_upstream_from_branch(self.db1, "package", version) |
328 | 729 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) | 729 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) |
330 | 730 | self.assertEqual(self.db2.revid_of_upstream_version("package", version), | 730 | self.assertEqual(self.db2.pristine_upstream_source.version_as_revision("package", version), |
331 | 731 | up_revid) | 731 | up_revid) |
332 | 732 | 732 | ||
333 | 733 | def check_changes(self, changes, added=[], removed=[], modified=[], | 733 | def check_changes(self, changes, added=[], removed=[], modified=[], |
334 | @@ -784,7 +784,7 @@ | |||
335 | 784 | branch = tree.branch | 784 | branch = tree.branch |
336 | 785 | rh = branch.revision_history() | 785 | rh = branch.revision_history() |
337 | 786 | self.assertEqual(len(rh), 1) | 786 | self.assertEqual(len(rh), 1) |
339 | 787 | self.assertEqual(self.db1.revid_of_upstream_version( | 787 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( |
340 | 788 | "package", version.upstream_version), rh[0]) | 788 | "package", version.upstream_version), rh[0]) |
341 | 789 | rev = branch.repository.get_revision(rh[0]) | 789 | rev = branch.repository.get_revision(rh[0]) |
342 | 790 | self.assertEqual(rev.message, | 790 | self.assertEqual(rev.message, |
343 | @@ -823,7 +823,7 @@ | |||
344 | 823 | rh = branch.revision_history() | 823 | rh = branch.revision_history() |
345 | 824 | self.assertEqual(len(rh), 2) | 824 | self.assertEqual(len(rh), 2) |
346 | 825 | self.assertEqual( | 825 | self.assertEqual( |
348 | 826 | self.db1.revid_of_upstream_version("package", version2.upstream_version), rh[1]) | 826 | self.db1.pristine_upstream_source.version_as_revision("package", version2.upstream_version), rh[1]) |
349 | 827 | rev = branch.repository.get_revision(rh[1]) | 827 | rev = branch.repository.get_revision(rh[1]) |
350 | 828 | self.assertEqual(rev.message, | 828 | self.assertEqual(rev.message, |
351 | 829 | "Import upstream version %s" % str(version2.upstream_version)) | 829 | "Import upstream version %s" % str(version2.upstream_version)) |
352 | @@ -854,7 +854,7 @@ | |||
353 | 854 | branch = tree.branch | 854 | branch = tree.branch |
354 | 855 | rh = branch.revision_history() | 855 | rh = branch.revision_history() |
355 | 856 | self.assertEqual(len(rh), 1) | 856 | self.assertEqual(len(rh), 1) |
357 | 857 | self.assertEqual(self.db1.revid_of_upstream_version( | 857 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( |
358 | 858 | "package", version.upstream_version), rh[0]) | 858 | "package", version.upstream_version), rh[0]) |
359 | 859 | rev = branch.repository.get_revision(rh[0]) | 859 | rev = branch.repository.get_revision(rh[0]) |
360 | 860 | self.assertEqual(rev.message, | 860 | self.assertEqual(rev.message, |
361 | @@ -882,7 +882,7 @@ | |||
362 | 882 | branch = tree.branch | 882 | branch = tree.branch |
363 | 883 | rh = branch.revision_history() | 883 | rh = branch.revision_history() |
364 | 884 | self.assertEqual(len(rh), 1) | 884 | self.assertEqual(len(rh), 1) |
366 | 885 | self.assertEqual(self.db1.revid_of_upstream_version( | 885 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( |
367 | 886 | "package", version.upstream_version), rh[0]) | 886 | "package", version.upstream_version), rh[0]) |
368 | 887 | rev = branch.repository.get_revision(rh[0]) | 887 | rev = branch.repository.get_revision(rh[0]) |
369 | 888 | self.assertEqual(rev.message, | 888 | self.assertEqual(rev.message, |
370 | @@ -916,7 +916,7 @@ | |||
371 | 916 | branch = tree.branch | 916 | branch = tree.branch |
372 | 917 | rh = branch.revision_history() | 917 | rh = branch.revision_history() |
373 | 918 | self.assertEqual(len(rh), 1) | 918 | self.assertEqual(len(rh), 1) |
375 | 919 | self.assertEqual(self.db1.revid_of_upstream_version( | 919 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( |
376 | 920 | "package", version.upstream_version), rh[0]) | 920 | "package", version.upstream_version), rh[0]) |
377 | 921 | rev = branch.repository.get_revision(rh[0]) | 921 | rev = branch.repository.get_revision(rh[0]) |
378 | 922 | self.assertEqual(rev.message, | 922 | self.assertEqual(rev.message, |
379 | @@ -1356,7 +1356,7 @@ | |||
380 | 1356 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) | 1356 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) |
381 | 1357 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) | 1357 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) |
382 | 1358 | self.assertEqual( | 1358 | self.assertEqual( |
384 | 1359 | self.db1.revid_of_upstream_version("package", version1.upstream_version), | 1359 | self.db1.pristine_upstream_source.version_as_revision("package", version1.upstream_version), |
385 | 1360 | up_rh1[0]) | 1360 | up_rh1[0]) |
386 | 1361 | self.tree1.lock_read() | 1361 | self.tree1.lock_read() |
387 | 1362 | self.addCleanup(self.tree1.unlock) | 1362 | self.addCleanup(self.tree1.unlock) |
388 | @@ -1409,10 +1409,10 @@ | |||
389 | 1409 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) | 1409 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) |
390 | 1410 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) | 1410 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) |
391 | 1411 | self.assertEqual( | 1411 | self.assertEqual( |
393 | 1412 | self.db1.revid_of_upstream_version("package", version1.upstream_version), | 1412 | self.db1.pristine_upstream_source.version_as_revision("package", version1.upstream_version), |
394 | 1413 | up_rh1[0]) | 1413 | up_rh1[0]) |
395 | 1414 | self.assertEqual( | 1414 | self.assertEqual( |
397 | 1415 | self.db1.revid_of_upstream_version("package", version3.upstream_version), | 1415 | self.db1.pristine_upstream_source.version_as_revision("package", version3.upstream_version), |
398 | 1416 | up_rh1[1]) | 1416 | up_rh1[1]) |
399 | 1417 | self.tree1.lock_read() | 1417 | self.tree1.lock_read() |
400 | 1418 | self.addCleanup(self.tree1.unlock) | 1418 | self.addCleanup(self.tree1.unlock) |
401 | @@ -1464,10 +1464,10 @@ | |||
402 | 1464 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) | 1464 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) |
403 | 1465 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) | 1465 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) |
404 | 1466 | self.assertEqual( | 1466 | self.assertEqual( |
406 | 1467 | self.db1.revid_of_upstream_version("package", version1.upstream_version), | 1467 | self.db1.pristine_upstream_source.version_as_revision("package", version1.upstream_version), |
407 | 1468 | up_rh1[0]) | 1468 | up_rh1[0]) |
408 | 1469 | self.assertEqual( | 1469 | self.assertEqual( |
410 | 1470 | self.db1.revid_of_upstream_version("package", version3.upstream_version), | 1470 | self.db1.pristine_upstream_source.version_as_revision("package", version3.upstream_version), |
411 | 1471 | up_rh1[1]) | 1471 | up_rh1[1]) |
412 | 1472 | self.tree1.lock_read() | 1472 | self.tree1.lock_read() |
413 | 1473 | self.addCleanup(self.tree1.unlock) | 1473 | self.addCleanup(self.tree1.unlock) |
414 | 1474 | 1474 | ||
415 | === modified file 'upstream/pristinetar.py' | |||
416 | --- upstream/pristinetar.py 2011-06-28 08:41:44 +0000 | |||
417 | +++ upstream/pristinetar.py 2011-07-17 22:29:31 +0000 | |||
418 | @@ -217,10 +217,7 @@ | |||
419 | 217 | def fetch_tarballs(self, package, version, target_dir): | 217 | def fetch_tarballs(self, package, version, target_dir): |
420 | 218 | return [self.fetch_component_tarball(package, version, None, target_dir)] | 218 | return [self.fetch_component_tarball(package, version, None, target_dir)] |
421 | 219 | 219 | ||
426 | 220 | def _has_version_component(self, tag_name, md5=None): | 220 | def _has_revision(self, revid, md5=None): |
423 | 221 | if not self.branch.tags.has_tag(tag_name): | ||
424 | 222 | return False | ||
425 | 223 | revid = self.branch.tags.lookup_tag(tag_name) | ||
427 | 224 | self.branch.lock_read() | 221 | self.branch.lock_read() |
428 | 225 | try: | 222 | try: |
429 | 226 | graph = self.branch.repository.get_graph() | 223 | graph = self.branch.repository.get_graph() |
430 | @@ -234,8 +231,9 @@ | |||
431 | 234 | try: | 231 | try: |
432 | 235 | return rev.properties['deb-md5'] == md5 | 232 | return rev.properties['deb-md5'] == md5 |
433 | 236 | except KeyError: | 233 | except KeyError: |
436 | 237 | warning("tag %s present in branch, but there is no " | 234 | warning("tag present in branch, but there is no " |
437 | 238 | "associated 'deb-md5' property" % tag_name) | 235 | "associated 'deb-md5' property in associated " |
438 | 236 | "revision %s", revid) | ||
439 | 239 | return True | 237 | return True |
440 | 240 | 238 | ||
441 | 241 | def version_as_revision(self, package, version, tarballs=None): | 239 | def version_as_revision(self, package, version, tarballs=None): |
442 | @@ -244,13 +242,19 @@ | |||
443 | 244 | elif len(tarballs) > 1: | 242 | elif len(tarballs) > 1: |
444 | 245 | raise MultipleUpstreamTarballsNotSupported() | 243 | raise MultipleUpstreamTarballsNotSupported() |
445 | 246 | else: | 244 | else: |
447 | 247 | return self.version_component_as_revision(package, version, tarballs[0][1]) | 245 | return self.version_component_as_revision(package, version, tarballs[0][1], |
448 | 246 | tarballs[0][2]) | ||
449 | 248 | 247 | ||
451 | 249 | def version_component_as_revision(self, package, version, component, tarballs=None): | 248 | def version_component_as_revision(self, package, version, component, md5=None): |
452 | 250 | assert isinstance(version, str) | 249 | assert isinstance(version, str) |
453 | 251 | for tag_name in self.possible_tag_names(version, component=component): | 250 | for tag_name in self.possible_tag_names(version, component=component): |
456 | 252 | if self._has_version_component(tag_name, tarballs): | 251 | try: |
457 | 253 | return self.branch.tags.lookup_tag(tag_name) | 252 | revid = self.branch.tags.lookup_tag(tag_name) |
458 | 253 | except NoSuchTag: | ||
459 | 254 | continue | ||
460 | 255 | else: | ||
461 | 256 | if self._has_revision(revid, md5=md5): | ||
462 | 257 | return revid | ||
463 | 254 | tag_name = self.tag_name(version, component=component) | 258 | tag_name = self.tag_name(version, component=component) |
464 | 255 | try: | 259 | try: |
465 | 256 | return self.branch.tags.lookup_tag(tag_name) | 260 | return self.branch.tags.lookup_tag(tag_name) |
466 | @@ -269,8 +273,13 @@ | |||
467 | 269 | def has_version_component(self, package, version, component, md5=None): | 273 | def has_version_component(self, package, version, component, md5=None): |
468 | 270 | assert isinstance(version, str), str(type(version)) | 274 | assert isinstance(version, str), str(type(version)) |
469 | 271 | for tag_name in self.possible_tag_names(version, component=component): | 275 | for tag_name in self.possible_tag_names(version, component=component): |
472 | 272 | if self._has_version_component(tag_name, md5=md5): | 276 | try: |
473 | 273 | return True | 277 | revid = self.branch.tags.lookup_tag(tag_name) |
474 | 278 | except NoSuchTag: | ||
475 | 279 | continue | ||
476 | 280 | else: | ||
477 | 281 | if self._has_revision(revid, md5=md5): | ||
478 | 282 | return True | ||
479 | 274 | return False | 283 | return False |
480 | 275 | 284 | ||
481 | 276 | def possible_tag_names(self, version, component): | 285 | def possible_tag_names(self, version, component): |