Merge lp:~jelmer/bzr-builddeb/commands-are-lazy into lp:bzr-builddeb
- commands-are-lazy
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Merged |
---|---|
Approved by: | Vincent Ladeuil |
Approved revision: | 663 |
Merged at revision: | 660 |
Proposed branch: | lp:~jelmer/bzr-builddeb/commands-are-lazy |
Merge into: | lp:bzr-builddeb |
Diff against target: |
261 lines (+93/-50) 1 file modified
cmds.py (+93/-50) |
To merge this branch: | bzr merge lp:~jelmer/bzr-builddeb/commands-are-lazy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil | Approve | ||
Review via email:
|
Commit message
Description of the change
Defer a bunch of imports in cmds.py. This gets us some way towards fixing bug 903650.
Also, clean up temporary directories created by merge-upstream.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Vincent Ladeuil (vila) : | # |
review:
Approve
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-12-03 01:24:37 +0000 | |||
3 | +++ cmds.py 2011-12-13 11:42:23 +0000 | |||
4 | @@ -47,7 +47,6 @@ | |||
5 | 47 | NoWorkingTree, | 47 | NoWorkingTree, |
6 | 48 | ) | 48 | ) |
7 | 49 | from bzrlib.option import Option | 49 | from bzrlib.option import Option |
8 | 50 | from bzrlib.tag import _merge_tags_if_possible | ||
9 | 51 | from bzrlib.trace import note, warning | 50 | from bzrlib.trace import note, warning |
10 | 52 | from bzrlib.workingtree import WorkingTree | 51 | from bzrlib.workingtree import WorkingTree |
11 | 53 | 52 | ||
12 | @@ -55,12 +54,8 @@ | |||
13 | 55 | default_build_dir, | 54 | default_build_dir, |
14 | 56 | default_orig_dir, | 55 | default_orig_dir, |
15 | 57 | default_result_dir, | 56 | default_result_dir, |
16 | 58 | dh_make, | ||
17 | 59 | gettext, | 57 | gettext, |
18 | 60 | ) | 58 | ) |
19 | 61 | from bzrlib.plugins.builddeb.builder import ( | ||
20 | 62 | DebBuild, | ||
21 | 63 | ) | ||
22 | 64 | from bzrlib.plugins.builddeb.config import ( | 59 | from bzrlib.plugins.builddeb.config import ( |
23 | 65 | BUILD_TYPE_MERGE, | 60 | BUILD_TYPE_MERGE, |
24 | 66 | BUILD_TYPE_NATIVE, | 61 | BUILD_TYPE_NATIVE, |
25 | @@ -75,51 +70,24 @@ | |||
26 | 75 | StrictBuildFailed, | 70 | StrictBuildFailed, |
27 | 76 | ) | 71 | ) |
28 | 77 | from bzrlib.plugins.builddeb.hooks import run_hook | 72 | from bzrlib.plugins.builddeb.hooks import run_hook |
29 | 78 | from bzrlib.plugins.builddeb.import_dsc import ( | ||
30 | 79 | DistributionBranch, | ||
31 | 80 | DistributionBranchSet, | ||
32 | 81 | DscCache, | ||
33 | 82 | DscComp, | ||
34 | 83 | ) | ||
35 | 84 | from bzrlib.plugins.builddeb.merge_package import fix_ancestry_as_needed | ||
36 | 85 | from bzrlib.plugins.builddeb.source_distiller import ( | ||
37 | 86 | FullSourceDistiller, | ||
38 | 87 | MergeModeDistiller, | ||
39 | 88 | NativeSourceDistiller, | ||
40 | 89 | ) | ||
41 | 90 | from bzrlib.plugins.builddeb.upstream import ( | ||
42 | 91 | AptSource, | ||
43 | 92 | DebianRulesSource, | ||
44 | 93 | SelfSplitSource, | ||
45 | 94 | TarfileSource, | ||
46 | 95 | UScanSource, | ||
47 | 96 | UpstreamProvider, | ||
48 | 97 | ) | ||
49 | 98 | from bzrlib.plugins.builddeb.upstream.branch import ( | ||
50 | 99 | LazyUpstreamBranchSource, | ||
51 | 100 | UpstreamBranchSource, | ||
52 | 101 | ) | ||
53 | 102 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( | ||
54 | 103 | PristineTarSource, | ||
55 | 104 | ) | ||
56 | 105 | from bzrlib.plugins.builddeb.util import ( | 73 | from bzrlib.plugins.builddeb.util import ( |
74 | 106 | FORMAT_3_0_QUILT, | 74 | FORMAT_3_0_QUILT, |
75 | 107 | FORMAT_3_0_NATIVE, | 75 | FORMAT_3_0_NATIVE, |
76 | 108 | component_from_orig_tarball, | 76 | component_from_orig_tarball, |
77 | 109 | debuild_config, | 77 | debuild_config, |
78 | 110 | dget_changes, | 78 | dget_changes, |
79 | 111 | find_changelog, | 79 | find_changelog, |
80 | 112 | find_last_distribution, | 80 | find_last_distribution, |
81 | 113 | find_previous_upload, | 81 | find_previous_upload, |
82 | 114 | get_source_format, | 82 | get_source_format, |
83 | 115 | guess_build_type, | 83 | guess_build_type, |
84 | 116 | lookup_distribution, | 84 | lookup_distribution, |
85 | 117 | md5sum_filename, | 85 | md5sum_filename, |
86 | 118 | open_file, | 86 | open_file, |
87 | 119 | open_file_via_transport, | 87 | open_file_via_transport, |
88 | 120 | tarball_name, | 88 | tarball_name, |
89 | 121 | tree_contains_upstream_source, | 89 | tree_contains_upstream_source, |
90 | 122 | ) | 90 | ) |
91 | 123 | 91 | ||
92 | 124 | dont_purge_opt = Option('dont-purge', | 92 | dont_purge_opt = Option('dont-purge', |
93 | 125 | help="Don't purge the build directory after building.") | 93 | help="Don't purge the build directory after building.") |
94 | @@ -312,6 +280,9 @@ | |||
95 | 312 | 280 | ||
96 | 313 | def _get_upstream_branch(self, export_upstream, export_upstream_revision, | 281 | def _get_upstream_branch(self, export_upstream, export_upstream_revision, |
97 | 314 | config, version): | 282 | config, version): |
98 | 283 | from bzrlib.plugins.builddeb.upstream.branch import ( | ||
99 | 284 | LazyUpstreamBranchSource, | ||
100 | 285 | ) | ||
101 | 315 | upstream_source = LazyUpstreamBranchSource(export_upstream, | 286 | upstream_source = LazyUpstreamBranchSource(export_upstream, |
102 | 316 | config=config) | 287 | config=config) |
103 | 317 | if export_upstream_revision: | 288 | if export_upstream_revision: |
104 | @@ -327,6 +298,26 @@ | |||
105 | 327 | quick=False, reuse=False, native=None, | 298 | quick=False, reuse=False, native=None, |
106 | 328 | source=False, revision=None, result=None, package_merge=None, | 299 | source=False, revision=None, result=None, package_merge=None, |
107 | 329 | strict=False): | 300 | strict=False): |
108 | 301 | from bzrlib.plugins.builddeb.source_distiller import ( | ||
109 | 302 | FullSourceDistiller, | ||
110 | 303 | MergeModeDistiller, | ||
111 | 304 | NativeSourceDistiller, | ||
112 | 305 | ) | ||
113 | 306 | from bzrlib.plugins.builddeb.builder import DebBuild | ||
114 | 307 | from bzrlib.plugins.builddeb.upstream.branch import ( | ||
115 | 308 | LazyUpstreamBranchSource, | ||
116 | 309 | ) | ||
117 | 310 | from bzrlib.plugins.builddeb.upstream import ( | ||
118 | 311 | AptSource, | ||
119 | 312 | DebianRulesSource, | ||
120 | 313 | SelfSplitSource, | ||
121 | 314 | UScanSource, | ||
122 | 315 | UpstreamProvider, | ||
123 | 316 | ) | ||
124 | 317 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( | ||
125 | 318 | PristineTarSource, | ||
126 | 319 | ) | ||
127 | 320 | |||
128 | 330 | if result is not None: | 321 | if result is not None: |
129 | 331 | warning(gettext("--result is deprecated, use --result-dir instead")) | 322 | warning(gettext("--result is deprecated, use --result-dir instead")) |
130 | 332 | location, build_options, source = self._branch_and_build_options( | 323 | location, build_options, source = self._branch_and_build_options( |
131 | @@ -476,6 +467,15 @@ | |||
132 | 476 | takes_args = ["version?"] | 467 | takes_args = ["version?"] |
133 | 477 | 468 | ||
134 | 478 | def run(self, directory='.', version=None): | 469 | def run(self, directory='.', version=None): |
135 | 470 | from bzrlib.plugins.builddeb.upstream import ( | ||
136 | 471 | AptSource, | ||
137 | 472 | DebianRulesSource, | ||
138 | 473 | UScanSource, | ||
139 | 474 | UpstreamProvider, | ||
140 | 475 | ) | ||
141 | 476 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( | ||
142 | 477 | PristineTarSource, | ||
143 | 478 | ) | ||
144 | 479 | tree = WorkingTree.open_containing(directory)[0] | 479 | tree = WorkingTree.open_containing(directory)[0] |
145 | 480 | config = debuild_config(tree, tree) | 480 | config = debuild_config(tree, tree) |
146 | 481 | 481 | ||
147 | @@ -594,6 +594,10 @@ | |||
148 | 594 | def _do_merge(self, tree, tarball_filenames, package, version, | 594 | def _do_merge(self, tree, tarball_filenames, package, version, |
149 | 595 | current_version, upstream_branch, upstream_revisions, merge_type, | 595 | current_version, upstream_branch, upstream_revisions, merge_type, |
150 | 596 | force): | 596 | force): |
151 | 597 | from bzrlib.plugins.builddeb.import_dsc import ( | ||
152 | 598 | DistributionBranch, | ||
153 | 599 | DistributionBranchSet, | ||
154 | 600 | ) | ||
155 | 597 | db = DistributionBranch(tree.branch, tree.branch, tree=tree) | 601 | db = DistributionBranch(tree.branch, tree.branch, tree=tree) |
156 | 598 | dbs = DistributionBranchSet() | 602 | dbs = DistributionBranchSet() |
157 | 599 | dbs.add_branch(db) | 603 | dbs.add_branch(db) |
158 | @@ -673,6 +677,10 @@ | |||
159 | 673 | distribution=None, package=None, | 677 | distribution=None, package=None, |
160 | 674 | directory=".", revision=None, merge_type=None, | 678 | directory=".", revision=None, merge_type=None, |
161 | 675 | last_version=None, force=None, snapshot=False, launchpad=False): | 679 | last_version=None, force=None, snapshot=False, launchpad=False): |
162 | 680 | from bzrlib.plugins.builddeb.upstream.branch import ( | ||
163 | 681 | UpstreamBranchSource, | ||
164 | 682 | ) | ||
165 | 683 | |||
166 | 676 | tree, _ = WorkingTree.open_containing(directory) | 684 | tree, _ = WorkingTree.open_containing(directory) |
167 | 677 | tree.lock_write() | 685 | tree.lock_write() |
168 | 678 | try: | 686 | try: |
169 | @@ -783,7 +791,8 @@ | |||
170 | 783 | "'export-upstream-revision' in the configuration." % | 791 | "'export-upstream-revision' in the configuration." % |
171 | 784 | (version, upstream_branch_source)) | 792 | (version, upstream_branch_source)) |
172 | 785 | if need_upstream_tarball: | 793 | if need_upstream_tarball: |
174 | 786 | target_dir = tempfile.mkdtemp() # FIXME: Cleanup? | 794 | target_dir = tempfile.mkdtemp() |
175 | 795 | self.add_cleanup(shutil.rmtree, target_dir) | ||
176 | 787 | try: | 796 | try: |
177 | 788 | locations = primary_upstream_source.fetch_tarballs( | 797 | locations = primary_upstream_source.fetch_tarballs( |
178 | 789 | package, version, target_dir, components=[None]) | 798 | package, version, target_dir, components=[None]) |
179 | @@ -859,6 +868,10 @@ | |||
180 | 859 | takes_options = [filename_opt] | 868 | takes_options = [filename_opt] |
181 | 860 | 869 | ||
182 | 861 | def import_many(self, db, files_list, orig_target): | 870 | def import_many(self, db, files_list, orig_target): |
183 | 871 | from bzrlib.plugins.builddeb.import_dsc import ( | ||
184 | 872 | DscCache, | ||
185 | 873 | DscComp, | ||
186 | 874 | ) | ||
187 | 862 | cache = DscCache() | 875 | cache = DscCache() |
188 | 863 | files_list.sort(cmp=DscComp(cache).cmp) | 876 | files_list.sort(cmp=DscComp(cache).cmp) |
189 | 864 | if not os.path.exists(orig_target): | 877 | if not os.path.exists(orig_target): |
190 | @@ -882,6 +895,10 @@ | |||
191 | 882 | db.import_package(os.path.join(orig_target, filename)) | 895 | db.import_package(os.path.join(orig_target, filename)) |
192 | 883 | 896 | ||
193 | 884 | def run(self, files_list, file=None): | 897 | def run(self, files_list, file=None): |
194 | 898 | from bzrlib.plugins.builddeb.import_dsc import ( | ||
195 | 899 | DistributionBranch, | ||
196 | 900 | DistributionBranchSet, | ||
197 | 901 | ) | ||
198 | 885 | try: | 902 | try: |
199 | 886 | tree = WorkingTree.open_containing('.')[0] | 903 | tree = WorkingTree.open_containing('.')[0] |
200 | 887 | except NotBranchError: | 904 | except NotBranchError: |
201 | @@ -988,6 +1005,10 @@ | |||
202 | 988 | takes_args = ['version', 'location', 'upstream_branch?'] | 1005 | takes_args = ['version', 'location', 'upstream_branch?'] |
203 | 989 | 1006 | ||
204 | 990 | def run(self, version, location, upstream_branch=None, revision=None): | 1007 | def run(self, version, location, upstream_branch=None, revision=None): |
205 | 1008 | from bzrlib.plugins.builddeb.import_dsc import ( | ||
206 | 1009 | DistributionBranch, | ||
207 | 1010 | DistributionBranchSet, | ||
208 | 1011 | ) | ||
209 | 991 | # TODO: search for similarity etc. | 1012 | # TODO: search for similarity etc. |
210 | 992 | version = version.encode('utf8') | 1013 | version = version.encode('utf8') |
211 | 993 | branch, _ = Branch.open_containing('.') | 1014 | branch, _ = Branch.open_containing('.') |
212 | @@ -1080,6 +1101,21 @@ | |||
213 | 1080 | aliases = ['bd-do'] | 1101 | aliases = ['bd-do'] |
214 | 1081 | 1102 | ||
215 | 1082 | def run(self, command_list=None): | 1103 | def run(self, command_list=None): |
216 | 1104 | from bzrlib.plugins.builddeb.source_distiller import ( | ||
217 | 1105 | MergeModeDistiller, | ||
218 | 1106 | ) | ||
219 | 1107 | from bzrlib.plugins.builddeb.builder import ( | ||
220 | 1108 | DebBuild, | ||
221 | 1109 | ) | ||
222 | 1110 | from bzrlib.plugins.builddeb.upstream import ( | ||
223 | 1111 | AptSource, | ||
224 | 1112 | DebianRulesSource, | ||
225 | 1113 | UScanSource, | ||
226 | 1114 | UpstreamProvider, | ||
227 | 1115 | ) | ||
228 | 1116 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( | ||
229 | 1117 | PristineTarSource, | ||
230 | 1118 | ) | ||
231 | 1083 | t = WorkingTree.open_containing('.')[0] | 1119 | t = WorkingTree.open_containing('.')[0] |
232 | 1084 | config = debuild_config(t, t) | 1120 | config = debuild_config(t, t) |
233 | 1085 | if config.build_type != BUILD_TYPE_MERGE: | 1121 | if config.build_type != BUILD_TYPE_MERGE: |
234 | @@ -1163,6 +1199,10 @@ | |||
235 | 1163 | takes_options = [merge_opt, force] | 1199 | takes_options = [merge_opt, force] |
236 | 1164 | 1200 | ||
237 | 1165 | def run(self, merge=None, force=None): | 1201 | def run(self, merge=None, force=None): |
238 | 1202 | from bzrlib.plugins.builddeb.import_dsc import ( | ||
239 | 1203 | DistributionBranch, | ||
240 | 1204 | DistributionBranchSet, | ||
241 | 1205 | ) | ||
242 | 1166 | t = WorkingTree.open_containing('.')[0] | 1206 | t = WorkingTree.open_containing('.')[0] |
243 | 1167 | t.lock_write() | 1207 | t.lock_write() |
244 | 1168 | try: | 1208 | try: |
245 | @@ -1208,6 +1248,8 @@ | |||
246 | 1208 | takes_args = ['source'] | 1248 | takes_args = ['source'] |
247 | 1209 | 1249 | ||
248 | 1210 | def run(self, source, revision=None): | 1250 | def run(self, source, revision=None): |
249 | 1251 | from bzrlib.tag import _merge_tags_if_possible | ||
250 | 1252 | from bzrlib.plugins.builddeb.merge_package import fix_ancestry_as_needed | ||
251 | 1211 | source_branch = None | 1253 | source_branch = None |
252 | 1212 | # Get the target branch. | 1254 | # Get the target branch. |
253 | 1213 | try: | 1255 | try: |
254 | @@ -1287,6 +1329,7 @@ | |||
255 | 1287 | takes_options = [bzr_only_opt, v3_opt] | 1329 | takes_options = [bzr_only_opt, v3_opt] |
256 | 1288 | 1330 | ||
257 | 1289 | def run(self, package_name, version, tarball, bzr_only=None, v3=None): | 1331 | def run(self, package_name, version, tarball, bzr_only=None, v3=None): |
258 | 1332 | from bzrlib.plugins.builddeb import dh_make | ||
259 | 1290 | tree = dh_make.import_upstream(tarball, package_name, | 1333 | tree = dh_make.import_upstream(tarball, package_name, |
260 | 1291 | version.encode("utf-8"), use_v3=v3) | 1334 | version.encode("utf-8"), use_v3=v3) |
261 | 1292 | if not bzr_only: | 1335 | if not bzr_only: |