Merge lp:~jelmer/bzr-builddeb/some-refactoring into lp:bzr-builddeb
- some-refactoring
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Merged |
---|---|
Approved by: | James Westby |
Approved revision: | 645 |
Merged at revision: | 644 |
Proposed branch: | lp:~jelmer/bzr-builddeb/some-refactoring |
Merge into: | lp:bzr-builddeb |
Diff against target: |
231 lines (+57/-64) 2 files modified
import_dsc.py (+56/-64) upstream/pristinetar.py (+1/-0) |
To merge this branch: | bzr merge lp:~jelmer/bzr-builddeb/some-refactoring |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby | Approve | ||
Review via email: mp+82279@code.launchpad.net |
Commit message
Description of the change
Simplify some things in import_dsc.py.
Also, set the 'debcomponent' property - it seems like this might come in handy in the future.
Support multiple upstream tarballs in pull_upstream_
To post a comment you must log in.
Revision history for this message
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-11-08 10:23:38 +0000 | |||
3 | +++ import_dsc.py 2011-11-15 14:15:29 +0000 | |||
4 | @@ -70,6 +70,7 @@ | |||
5 | 70 | FORMAT_3_0_QUILT, | 70 | FORMAT_3_0_QUILT, |
6 | 71 | FORMAT_3_0_NATIVE, | 71 | FORMAT_3_0_NATIVE, |
7 | 72 | component_from_orig_tarball, | 72 | component_from_orig_tarball, |
8 | 73 | export, | ||
9 | 73 | extract_orig_tarballs, | 74 | extract_orig_tarballs, |
10 | 74 | get_commit_info_from_changelog, | 75 | get_commit_info_from_changelog, |
11 | 75 | md5sum_filename, | 76 | md5sum_filename, |
12 | @@ -110,6 +111,7 @@ | |||
13 | 110 | def get_transport(self, name): | 111 | def get_transport(self, name): |
14 | 111 | return self.transport_cache[name] | 112 | return self.transport_cache[name] |
15 | 112 | 113 | ||
16 | 114 | |||
17 | 113 | class DscComp(object): | 115 | class DscComp(object): |
18 | 114 | 116 | ||
19 | 115 | def __init__(self, cache): | 117 | def __init__(self, cache): |
20 | @@ -127,7 +129,6 @@ | |||
21 | 127 | return -1 | 129 | return -1 |
22 | 128 | 130 | ||
23 | 129 | 131 | ||
24 | 130 | |||
25 | 131 | class DistributionBranchSet(object): | 132 | class DistributionBranchSet(object): |
26 | 132 | """A collection of DistributionBranches with an ordering. | 133 | """A collection of DistributionBranches with an ordering. |
27 | 133 | 134 | ||
28 | @@ -194,6 +195,21 @@ | |||
29 | 194 | return self._branch_list[index+1:] | 195 | return self._branch_list[index+1:] |
30 | 195 | 196 | ||
31 | 196 | 197 | ||
32 | 198 | def checkout_upstream_version(tree, package, version, revisions): | ||
33 | 199 | """Checkout an upstream version from the pristine tar source. | ||
34 | 200 | |||
35 | 201 | """ | ||
36 | 202 | tree.update(revision=revisions[None]) | ||
37 | 203 | parent_ids = [] | ||
38 | 204 | for component in sorted(revisions.keys()): | ||
39 | 205 | revid = revisions[component] | ||
40 | 206 | if component is not None: | ||
41 | 207 | component_tree = tree.branch.repository.revision_tree(revid) | ||
42 | 208 | export(component_tree, os.path.join(tree.basedir, component), format='dir') | ||
43 | 209 | parent_ids.append(revid) | ||
44 | 210 | tree.set_parent_ids(parent_ids) | ||
45 | 211 | |||
46 | 212 | |||
47 | 197 | class DistributionBranch(object): | 213 | class DistributionBranch(object): |
48 | 198 | """A DistributionBranch is a representation of one line of development. | 214 | """A DistributionBranch is a representation of one line of development. |
49 | 199 | 215 | ||
50 | @@ -647,30 +663,16 @@ | |||
51 | 647 | self.revid_of_version(last_contained_version))] | 663 | self.revid_of_version(last_contained_version))] |
52 | 648 | else: | 664 | else: |
53 | 649 | mutter("We don't have any of those versions") | 665 | mutter("We don't have any of those versions") |
55 | 650 | for branch in reversed(self.get_lesser_branches()): | 666 | for branch in list(reversed(self.get_lesser_branches())) + self.get_greater_branches(): |
56 | 651 | merged, missing_versions = \ | 667 | merged, missing_versions = \ |
57 | 652 | branch.contained_versions(missing_versions) | 668 | branch.contained_versions(missing_versions) |
58 | 653 | if merged: | 669 | if merged: |
59 | 654 | revid = branch.revid_of_version(merged[0]) | 670 | revid = branch.revid_of_version(merged[0]) |
60 | 655 | parents.append((branch, merged[0], revid)) | 671 | parents.append((branch, merged[0], revid)) |
62 | 656 | mutter("Adding merge from lesser of %s for version %s" | 672 | mutter("Adding merge from related branch of %s for version %s" |
63 | 657 | % (revid, str(merged[0]))) | 673 | % (revid, str(merged[0]))) |
64 | 658 | #FIXME: should this really be here? | 674 | #FIXME: should this really be here? |
80 | 659 | branch.branch.tags.merge_to(self.branch.tags) | 675 | self._fetch_from_branch(branch, revid) |
66 | 660 | self.branch.fetch(branch.branch, | ||
67 | 661 | last_revision=revid) | ||
68 | 662 | for branch in self.get_greater_branches(): | ||
69 | 663 | merged, missing_versions = \ | ||
70 | 664 | branch.contained_versions(missing_versions) | ||
71 | 665 | if merged: | ||
72 | 666 | revid = branch.revid_of_version(merged[0]) | ||
73 | 667 | parents.append((branch, merged[0], revid)) | ||
74 | 668 | mutter("Adding merge from greater of %s for version %s" | ||
75 | 669 | % (revid, str(merged[0]))) | ||
76 | 670 | #FIXME: should this really be here? | ||
77 | 671 | branch.branch.tags.merge_to(self.branch.tags) | ||
78 | 672 | self.branch.fetch(branch.branch, | ||
79 | 673 | last_revision=revid) | ||
81 | 674 | return parents | 676 | return parents |
82 | 675 | 677 | ||
83 | 676 | def pull_upstream_from_branch(self, pull_branch, package, version): | 678 | def pull_upstream_from_branch(self, pull_branch, package, version): |
84 | @@ -691,18 +693,18 @@ | |||
85 | 691 | assert isinstance(version, str) | 693 | assert isinstance(version, str) |
86 | 692 | pull_revisions = pull_branch.pristine_upstream_source.version_as_revisions( | 694 | pull_revisions = pull_branch.pristine_upstream_source.version_as_revisions( |
87 | 693 | package, version) | 695 | package, version) |
100 | 694 | if pull_revisions.keys() != [None]: | 696 | for (component, pull_revision) in pull_revisions.iteritems(): |
101 | 695 | raise MultipleUpstreamTarballsNotSupported() | 697 | mutter("Fetching upstream part %s of %s from revision %s" % \ |
102 | 696 | pull_revision = pull_revisions[None] | 698 | (component, version, pull_revision)) |
103 | 697 | mutter("Pulling upstream part of %s from revision %s" % \ | 699 | assert self.pristine_upstream_tree is not None, \ |
104 | 698 | (version, pull_revision)) | 700 | "Can't pull upstream with no tree" |
105 | 699 | assert self.pristine_upstream_tree is not None, \ | 701 | self.pristine_upstream_branch.pull(pull_branch.pristine_upstream_branch, |
106 | 700 | "Can't pull upstream with no tree" | 702 | stop_revision=pull_revision) |
107 | 701 | self.pristine_upstream_tree.pull(pull_branch.pristine_upstream_branch, | 703 | self.pristine_upstream_source.tag_version(version, pull_revision) |
108 | 702 | stop_revision=pull_revision) | 704 | self.branch.fetch(self.pristine_upstream_branch, last_revision=pull_revision) |
109 | 703 | self.pristine_upstream_source.tag_version(version, pull_revision) | 705 | self.pristine_upstream_branch.tags.merge_to(self.branch.tags) |
110 | 704 | self.branch.fetch(self.pristine_upstream_branch, last_revision=pull_revision) | 706 | checkout_upstream_version(self.pristine_upstream_tree, |
111 | 705 | self.pristine_upstream_branch.tags.merge_to(self.branch.tags) | 707 | package, version, pull_revisions) |
112 | 706 | 708 | ||
113 | 707 | def pull_version_from_branch(self, pull_branch, package, version, native=False): | 709 | def pull_version_from_branch(self, pull_branch, package, version, native=False): |
114 | 708 | """Pull a version from a particular branch. | 710 | """Pull a version from a particular branch. |
115 | @@ -800,13 +802,14 @@ | |||
116 | 800 | real_parents = [upstream_revids[component]] | 802 | real_parents = [upstream_revids[component]] |
117 | 801 | return real_parents | 803 | return real_parents |
118 | 802 | 804 | ||
120 | 803 | def _fetch_upstream_to_branch(self, revid): | 805 | def _fetch_upstream_to_branch(self, imported_revids): |
121 | 804 | """Fetch the revision from the upstream branch in to the packaging one. | 806 | """Fetch the revision from the upstream branch in to the packaging one. |
122 | 805 | """ | 807 | """ |
123 | 806 | # Make sure we see any revisions added by the upstream branch | 808 | # Make sure we see any revisions added by the upstream branch |
124 | 807 | # since self.tree was locked. | 809 | # since self.tree was locked. |
125 | 808 | self.branch.repository.refresh_data() | 810 | self.branch.repository.refresh_data() |
127 | 809 | self.branch.fetch(self.pristine_upstream_branch, last_revision=revid) | 811 | for (component, tag, revid) in imported_revids: |
128 | 812 | self.branch.fetch(self.pristine_upstream_branch, last_revision=revid) | ||
129 | 810 | self.pristine_upstream_branch.tags.merge_to(self.branch.tags) | 813 | self.pristine_upstream_branch.tags.merge_to(self.branch.tags) |
130 | 811 | 814 | ||
131 | 812 | def import_upstream(self, upstream_part, package, version, upstream_parents, | 815 | def import_upstream(self, upstream_part, package, version, upstream_parents, |
132 | @@ -1100,6 +1103,13 @@ | |||
133 | 1100 | cl.parse_changelog(open(cl_filename).read(), strict=False) | 1103 | cl.parse_changelog(open(cl_filename).read(), strict=False) |
134 | 1101 | return cl | 1104 | return cl |
135 | 1102 | 1105 | ||
136 | 1106 | def _fetch_from_branch(self, branch, revid): | ||
137 | 1107 | branch.branch.tags.merge_to(self.branch.tags) | ||
138 | 1108 | self.branch.fetch(branch.branch, last_revision=revid) | ||
139 | 1109 | if self.pristine_upstream_branch.last_revision() == NULL_REVISION: | ||
140 | 1110 | self.pristine_upstream_tree.pull(branch.pristine_upstream_branch) | ||
141 | 1111 | branch.pristine_upstream_branch.tags.merge_to(self.pristine_upstream_branch.tags) | ||
142 | 1112 | |||
143 | 1103 | def _import_normal_package(self, package, version, versions, debian_part, md5, | 1113 | def _import_normal_package(self, package, version, versions, debian_part, md5, |
144 | 1104 | upstream_part, upstream_tarballs, timestamp=None, author=None, | 1114 | upstream_part, upstream_tarballs, timestamp=None, author=None, |
145 | 1105 | file_ids_from=None, pull_debian=True): | 1115 | file_ids_from=None, pull_debian=True): |
146 | @@ -1145,13 +1155,13 @@ | |||
147 | 1145 | # from another branch: | 1155 | # from another branch: |
148 | 1146 | upstream_parents = self.upstream_parents(package, versions, | 1156 | upstream_parents = self.upstream_parents(package, versions, |
149 | 1147 | version.upstream_version) | 1157 | version.upstream_version) |
151 | 1148 | for (component, tag, revid) in self.import_upstream(upstream_part, | 1158 | imported_revids = self.import_upstream(upstream_part, |
152 | 1149 | package, version.upstream_version, | 1159 | package, version.upstream_version, |
153 | 1150 | upstream_parents, | 1160 | upstream_parents, |
154 | 1151 | upstream_tarballs=upstream_tarballs, | 1161 | upstream_tarballs=upstream_tarballs, |
155 | 1152 | timestamp=timestamp, author=author, | 1162 | timestamp=timestamp, author=author, |
158 | 1153 | file_ids_from=file_ids_from): | 1163 | file_ids_from=file_ids_from) |
159 | 1154 | self._fetch_upstream_to_branch(revid) | 1164 | self._fetch_upstream_to_branch(imported_revids) |
160 | 1155 | else: | 1165 | else: |
161 | 1156 | mutter("We already have the needed upstream part") | 1166 | mutter("We already have the needed upstream part") |
162 | 1157 | parents = self.get_parents_with_upstream(package, version, versions, | 1167 | parents = self.get_parents_with_upstream(package, version, versions, |
163 | @@ -1167,32 +1177,14 @@ | |||
164 | 1167 | else: | 1177 | else: |
165 | 1168 | parents = [self.revid_of_version(last_contained_version)] | 1178 | parents = [self.revid_of_version(last_contained_version)] |
166 | 1169 | missing_versions = self.missing_versions(versions) | 1179 | missing_versions = self.missing_versions(versions) |
193 | 1170 | for branch in reversed(self.get_lesser_branches()): | 1180 | for branch in list(reversed(self.get_lesser_branches())) + self.get_greater_branches(): |
194 | 1171 | merged, missing_versions = \ | 1181 | merged, missing_versions = \ |
195 | 1172 | branch.contained_versions(missing_versions) | 1182 | branch.contained_versions(missing_versions) |
196 | 1173 | if merged: | 1183 | if merged: |
197 | 1174 | revid = branch.revid_of_version(merged[0]) | 1184 | revid = branch.revid_of_version(merged[0]) |
198 | 1175 | parents.append(revid) | 1185 | parents.append(revid) |
199 | 1176 | #FIXME: should this really be here? | 1186 | #FIXME: should this really be here? |
200 | 1177 | branch.branch.tags.merge_to(self.branch.tags) | 1187 | self._fetch_from_branch(branch, revid) |
175 | 1178 | self.branch.fetch(branch.branch, | ||
176 | 1179 | last_revision=revid) | ||
177 | 1180 | if self.pristine_upstream_branch.last_revision() == NULL_REVISION: | ||
178 | 1181 | self.pristine_upstream_tree.pull(branch.pristine_upstream_branch) | ||
179 | 1182 | branch.pristine_upstream_branch.tags.merge_to(self.pristine_upstream_branch.tags) | ||
180 | 1183 | for branch in self.get_greater_branches(): | ||
181 | 1184 | merged, missing_versions = \ | ||
182 | 1185 | branch.contained_versions(missing_versions) | ||
183 | 1186 | if merged: | ||
184 | 1187 | revid = branch.revid_of_version(merged[0]) | ||
185 | 1188 | parents.append(revid) | ||
186 | 1189 | #FIXME: should this really be here? | ||
187 | 1190 | branch.branch.tags.merge_to(self.branch.tags) | ||
188 | 1191 | self.branch.fetch(branch.branch, | ||
189 | 1192 | last_revision=revid) | ||
190 | 1193 | if self.pristine_upstream_branch.last_revision() == NULL_REVISION: | ||
191 | 1194 | self.pristine_upstream_tree.pull(branch.pristine_upstream_branch) | ||
192 | 1195 | branch.pristine_upstream_branch.tags.merge_to(self.pristine_upstream_branch.tags) | ||
201 | 1196 | if (self.branch.last_revision() != NULL_REVISION | 1188 | if (self.branch.last_revision() != NULL_REVISION |
202 | 1197 | and not self.branch.last_revision() in parents): | 1189 | and not self.branch.last_revision() in parents): |
203 | 1198 | parents.insert(0, self.branch.last_revision()) | 1190 | parents.insert(0, self.branch.last_revision()) |
204 | @@ -1393,12 +1385,12 @@ | |||
205 | 1393 | parents = { None: [] } | 1385 | parents = { None: [] } |
206 | 1394 | if self.pristine_upstream_branch.last_revision() != NULL_REVISION: | 1386 | if self.pristine_upstream_branch.last_revision() != NULL_REVISION: |
207 | 1395 | parents = { None: [self.pristine_upstream_branch.last_revision()] } | 1387 | parents = { None: [self.pristine_upstream_branch.last_revision()] } |
209 | 1396 | for (component, tag, revid) in self.import_upstream(tarball_dir, | 1388 | imported_revids = self.import_upstream(tarball_dir, |
210 | 1397 | package, version, parents, | 1389 | package, version, parents, |
211 | 1398 | upstream_tarballs=upstream_tarballs, | 1390 | upstream_tarballs=upstream_tarballs, |
212 | 1399 | upstream_branch=upstream_branch, | 1391 | upstream_branch=upstream_branch, |
215 | 1400 | upstream_revisions=upstream_revisions): | 1392 | upstream_revisions=upstream_revisions) |
216 | 1401 | self._fetch_upstream_to_branch(revid) | 1393 | self._fetch_upstream_to_branch(imported_revids) |
217 | 1402 | finally: | 1394 | finally: |
218 | 1403 | shutil.rmtree(tarball_dir) | 1395 | shutil.rmtree(tarball_dir) |
219 | 1404 | if self.branch.last_revision() != NULL_REVISION: | 1396 | if self.branch.last_revision() != NULL_REVISION: |
220 | 1405 | 1397 | ||
221 | === modified file 'upstream/pristinetar.py' | |||
222 | --- upstream/pristinetar.py 2011-11-08 10:10:05 +0000 | |||
223 | +++ upstream/pristinetar.py 2011-11-15 14:15:29 +0000 | |||
224 | @@ -204,6 +204,7 @@ | |||
225 | 204 | message = "Import upstream version %s" % (version,) | 204 | message = "Import upstream version %s" % (version,) |
226 | 205 | if component is not None: | 205 | if component is not None: |
227 | 206 | message += ", component %s" % component | 206 | message += ", component %s" % component |
228 | 207 | revprops["deb-component"] = component | ||
229 | 207 | if len(parent_ids) == 0: | 208 | if len(parent_ids) == 0: |
230 | 208 | base_revid = _mod_revision.NULL_REVISION | 209 | base_revid = _mod_revision.NULL_REVISION |
231 | 209 | else: | 210 | else: |