Merge lp:~jelmer/bzr-builddeb/defer-imports into lp:bzr-builddeb
- defer-imports
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 676 | ||||
Proposed branch: | lp:~jelmer/bzr-builddeb/defer-imports | ||||
Merge into: | lp:bzr-builddeb | ||||
Diff against target: |
283 lines (+87/-42) 2 files modified
cmds.py (+84/-41) debian/changelog (+3/-1) |
||||
To merge this branch: | bzr merge lp:~jelmer/bzr-builddeb/defer-imports | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby | Approve | ||
Review via email: mp+87272@code.launchpad.net |
Commit message
Description of the change
Defer imports in cmds - this helps speed up commands like "bzr bash-completion", which iterate over all commands.
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 'cmds.py' | |||
2 | --- cmds.py 2011-12-16 14:55:04 +0000 | |||
3 | +++ cmds.py 2012-01-02 17:08:23 +0000 | |||
4 | @@ -21,18 +21,9 @@ | |||
5 | 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
6 | 22 | # | 22 | # |
7 | 23 | 23 | ||
8 | 24 | import commands | ||
9 | 25 | import os | 24 | import os |
10 | 26 | import shutil | 25 | import shutil |
11 | 27 | import subprocess | ||
12 | 28 | import tempfile | 26 | import tempfile |
13 | 29 | import urlparse | ||
14 | 30 | |||
15 | 31 | try: | ||
16 | 32 | from debian.changelog import Version | ||
17 | 33 | except ImportError: | ||
18 | 34 | # Prior to 0.1.15 the debian module was called debian_bundle | ||
19 | 35 | from debian_bundle.changelog import Version | ||
20 | 36 | 27 | ||
21 | 37 | from bzrlib import ( | 28 | from bzrlib import ( |
22 | 38 | urlutils, | 29 | urlutils, |
23 | @@ -61,32 +52,8 @@ | |||
24 | 61 | BUILD_TYPE_NATIVE, | 52 | BUILD_TYPE_NATIVE, |
25 | 62 | BUILD_TYPE_SPLIT, | 53 | BUILD_TYPE_SPLIT, |
26 | 63 | ) | 54 | ) |
27 | 64 | from bzrlib.plugins.builddeb.errors import ( | ||
28 | 65 | BuildFailedError, | ||
29 | 66 | DchError, | ||
30 | 67 | MissingChangelogError, | ||
31 | 68 | NoPreviousUpload, | ||
32 | 69 | PackageVersionNotPresent, | ||
33 | 70 | StrictBuildFailed, | ||
34 | 71 | ) | ||
35 | 72 | from bzrlib.plugins.builddeb.hooks import run_hook | ||
36 | 73 | from bzrlib.plugins.builddeb.util import ( | 55 | from bzrlib.plugins.builddeb.util import ( |
37 | 74 | FORMAT_3_0_QUILT, | ||
38 | 75 | FORMAT_3_0_NATIVE, | ||
39 | 76 | component_from_orig_tarball, | ||
40 | 77 | debuild_config, | 56 | debuild_config, |
41 | 78 | dget_changes, | ||
42 | 79 | find_changelog, | ||
43 | 80 | find_last_distribution, | ||
44 | 81 | find_previous_upload, | ||
45 | 82 | get_source_format, | ||
46 | 83 | guess_build_type, | ||
47 | 84 | lookup_distribution, | ||
48 | 85 | md5sum_filename, | ||
49 | 86 | open_file, | ||
50 | 87 | open_file_via_transport, | ||
51 | 88 | tarball_name, | ||
52 | 89 | tree_contains_upstream_source, | ||
53 | 90 | ) | 57 | ) |
54 | 91 | 58 | ||
55 | 92 | dont_purge_opt = Option('dont-purge', | 59 | dont_purge_opt = Option('dont-purge', |
56 | @@ -189,6 +156,7 @@ | |||
57 | 189 | result_compat_opt, package_merge_opt] | 156 | result_compat_opt, package_merge_opt] |
58 | 190 | 157 | ||
59 | 191 | def _get_tree_and_branch(self, location): | 158 | def _get_tree_and_branch(self, location): |
60 | 159 | import urlparse | ||
61 | 192 | if location is None: | 160 | if location is None: |
62 | 193 | location = "." | 161 | location = "." |
63 | 194 | is_local = urlparse.urlsplit(location)[0] in ('', 'file') | 162 | is_local = urlparse.urlsplit(location)[0] in ('', 'file') |
64 | @@ -298,12 +266,18 @@ | |||
65 | 298 | quick=False, reuse=False, native=None, | 266 | quick=False, reuse=False, native=None, |
66 | 299 | source=False, revision=None, result=None, package_merge=None, | 267 | source=False, revision=None, result=None, package_merge=None, |
67 | 300 | strict=False): | 268 | strict=False): |
68 | 269 | import commands | ||
69 | 301 | from bzrlib.plugins.builddeb.source_distiller import ( | 270 | from bzrlib.plugins.builddeb.source_distiller import ( |
70 | 302 | FullSourceDistiller, | 271 | FullSourceDistiller, |
71 | 303 | MergeModeDistiller, | 272 | MergeModeDistiller, |
72 | 304 | NativeSourceDistiller, | 273 | NativeSourceDistiller, |
73 | 305 | ) | 274 | ) |
74 | 306 | from bzrlib.plugins.builddeb.builder import DebBuild | 275 | from bzrlib.plugins.builddeb.builder import DebBuild |
75 | 276 | from bzrlib.plugins.builddeb.errors import ( | ||
76 | 277 | NoPreviousUpload, | ||
77 | 278 | StrictBuildFailed | ||
78 | 279 | ) | ||
79 | 280 | from bzrlib.plugins.builddeb.hooks import run_hook | ||
80 | 307 | from bzrlib.plugins.builddeb.upstream.branch import ( | 281 | from bzrlib.plugins.builddeb.upstream.branch import ( |
81 | 308 | LazyUpstreamBranchSource, | 282 | LazyUpstreamBranchSource, |
82 | 309 | ) | 283 | ) |
83 | @@ -317,6 +291,13 @@ | |||
84 | 317 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( | 291 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( |
85 | 318 | PristineTarSource, | 292 | PristineTarSource, |
86 | 319 | ) | 293 | ) |
87 | 294 | from bzrlib.plugins.builddeb.util import ( | ||
88 | 295 | dget_changes, | ||
89 | 296 | find_changelog, | ||
90 | 297 | find_previous_upload, | ||
91 | 298 | guess_build_type, | ||
92 | 299 | tree_contains_upstream_source, | ||
93 | 300 | ) | ||
94 | 320 | 301 | ||
95 | 321 | if result is not None: | 302 | if result is not None: |
96 | 322 | warning(gettext("--result is deprecated, use --result-dir instead")) | 303 | warning(gettext("--result is deprecated, use --result-dir instead")) |
97 | @@ -476,6 +457,9 @@ | |||
98 | 476 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( | 457 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( |
99 | 477 | PristineTarSource, | 458 | PristineTarSource, |
100 | 478 | ) | 459 | ) |
101 | 460 | from bzrlib.plugins.builddeb.util import ( | ||
102 | 461 | find_changelog, | ||
103 | 462 | ) | ||
104 | 479 | tree = WorkingTree.open_containing(directory)[0] | 463 | tree = WorkingTree.open_containing(directory)[0] |
105 | 480 | config = debuild_config(tree, tree) | 464 | config = debuild_config(tree, tree) |
106 | 481 | 465 | ||
107 | @@ -582,6 +566,9 @@ | |||
108 | 582 | changelog): | 566 | changelog): |
109 | 583 | from bzrlib.plugins.builddeb.merge_upstream import ( | 567 | from bzrlib.plugins.builddeb.merge_upstream import ( |
110 | 584 | changelog_add_new_version) | 568 | changelog_add_new_version) |
111 | 569 | from bzrlib.plugins.builddeb.errors import ( | ||
112 | 570 | DchError, | ||
113 | 571 | ) | ||
114 | 585 | try: | 572 | try: |
115 | 586 | changelog_add_new_version(tree, version, distribution_name, | 573 | changelog_add_new_version(tree, version, distribution_name, |
116 | 587 | changelog, package) | 574 | changelog, package) |
117 | @@ -598,6 +585,9 @@ | |||
118 | 598 | DistributionBranch, | 585 | DistributionBranch, |
119 | 599 | DistributionBranchSet, | 586 | DistributionBranchSet, |
120 | 600 | ) | 587 | ) |
121 | 588 | from bzrlib.plugins.builddeb.util import ( | ||
122 | 589 | component_from_orig_tarball, | ||
123 | 590 | ) | ||
124 | 601 | db = DistributionBranch(tree.branch, tree.branch, tree=tree) | 591 | db = DistributionBranch(tree.branch, tree.branch, tree=tree) |
125 | 602 | dbs = DistributionBranchSet() | 592 | dbs = DistributionBranchSet() |
126 | 603 | dbs.add_branch(db) | 593 | dbs.add_branch(db) |
127 | @@ -611,6 +601,7 @@ | |||
128 | 611 | 601 | ||
129 | 612 | def _fetch_tarball(self, package, version, orig_dir, locations, v3): | 602 | def _fetch_tarball(self, package, version, orig_dir, locations, v3): |
130 | 613 | from bzrlib.plugins.builddeb.repack_tarball import repack_tarball | 603 | from bzrlib.plugins.builddeb.repack_tarball import repack_tarball |
131 | 604 | from bzrlib.plugins.builddeb.util import tarball_name | ||
132 | 614 | ret = [] | 605 | ret = [] |
133 | 615 | format = None | 606 | format = None |
134 | 616 | for location in locations: | 607 | for location in locations: |
135 | @@ -642,6 +633,14 @@ | |||
136 | 642 | locations, v3) | 633 | locations, v3) |
137 | 643 | 634 | ||
138 | 644 | def _get_changelog_info(self, tree, last_version, package, distribution): | 635 | def _get_changelog_info(self, tree, last_version, package, distribution): |
139 | 636 | from bzrlib.plugins.builddeb.util import ( | ||
140 | 637 | find_changelog, | ||
141 | 638 | find_last_distribution, | ||
142 | 639 | lookup_distribution, | ||
143 | 640 | ) | ||
144 | 641 | from bzrlib.plugins.builddeb.errors import ( | ||
145 | 642 | MissingChangelogError, | ||
146 | 643 | ) | ||
147 | 645 | current_version = last_version | 644 | current_version = last_version |
148 | 646 | try: | 645 | try: |
149 | 647 | (changelog, top_level) = find_changelog(tree, False, max_blocks=2) | 646 | (changelog, top_level) = find_changelog(tree, False, max_blocks=2) |
150 | @@ -677,13 +676,28 @@ | |||
151 | 677 | distribution=None, package=None, | 676 | distribution=None, package=None, |
152 | 678 | directory=".", revision=None, merge_type=None, | 677 | directory=".", revision=None, merge_type=None, |
153 | 679 | last_version=None, force=None, snapshot=False, launchpad=False): | 678 | last_version=None, force=None, snapshot=False, launchpad=False): |
154 | 679 | try: | ||
155 | 680 | from debian.changelog import Version | ||
156 | 681 | except ImportError: | ||
157 | 682 | # Prior to 0.1.15 the debian module was called debian_bundle | ||
158 | 683 | from debian_bundle.changelog import Version | ||
159 | 684 | |||
160 | 685 | from bzrlib.plugins.builddeb.errors import PackageVersionNotPresent | ||
161 | 686 | from bzrlib.plugins.builddeb.hooks import run_hook | ||
162 | 680 | from bzrlib.plugins.builddeb.upstream import ( | 687 | from bzrlib.plugins.builddeb.upstream import ( |
166 | 681 | TarfileSource, | 688 | TarfileSource, |
167 | 682 | UScanSource, | 689 | UScanSource, |
168 | 683 | ) | 690 | ) |
169 | 684 | from bzrlib.plugins.builddeb.upstream.branch import ( | 691 | from bzrlib.plugins.builddeb.upstream.branch import ( |
172 | 685 | UpstreamBranchSource, | 692 | UpstreamBranchSource, |
173 | 686 | ) | 693 | ) |
174 | 694 | from bzrlib.plugins.builddeb.util import ( | ||
175 | 695 | FORMAT_3_0_QUILT, | ||
176 | 696 | FORMAT_3_0_NATIVE, | ||
177 | 697 | get_source_format, | ||
178 | 698 | guess_build_type, | ||
179 | 699 | tree_contains_upstream_source, | ||
180 | 700 | ) | ||
181 | 687 | 701 | ||
182 | 688 | tree, _ = WorkingTree.open_containing(directory) | 702 | tree, _ = WorkingTree.open_containing(directory) |
183 | 689 | tree.lock_write() | 703 | tree.lock_write() |
184 | @@ -873,9 +887,12 @@ | |||
185 | 873 | 887 | ||
186 | 874 | def import_many(self, db, files_list, orig_target): | 888 | def import_many(self, db, files_list, orig_target): |
187 | 875 | from bzrlib.plugins.builddeb.import_dsc import ( | 889 | from bzrlib.plugins.builddeb.import_dsc import ( |
191 | 876 | DscCache, | 890 | DscCache, |
192 | 877 | DscComp, | 891 | DscComp, |
193 | 878 | ) | 892 | ) |
194 | 893 | from bzrlib.plugins.builddeb.util import ( | ||
195 | 894 | open_file_via_transport, | ||
196 | 895 | ) | ||
197 | 879 | cache = DscCache() | 896 | cache = DscCache() |
198 | 880 | files_list.sort(cmp=DscComp(cache).cmp) | 897 | files_list.sort(cmp=DscComp(cache).cmp) |
199 | 881 | if not os.path.exists(orig_target): | 898 | if not os.path.exists(orig_target): |
200 | @@ -899,10 +916,17 @@ | |||
201 | 899 | db.import_package(os.path.join(orig_target, filename)) | 916 | db.import_package(os.path.join(orig_target, filename)) |
202 | 900 | 917 | ||
203 | 901 | def run(self, files_list, file=None): | 918 | def run(self, files_list, file=None): |
204 | 919 | from bzrlib.plugins.builddeb.errors import ( | ||
205 | 920 | MissingChangelogError, | ||
206 | 921 | ) | ||
207 | 902 | from bzrlib.plugins.builddeb.import_dsc import ( | 922 | from bzrlib.plugins.builddeb.import_dsc import ( |
208 | 903 | DistributionBranch, | 923 | DistributionBranch, |
209 | 904 | DistributionBranchSet, | 924 | DistributionBranchSet, |
210 | 905 | ) | 925 | ) |
211 | 926 | from bzrlib.plugins.builddeb.util import ( | ||
212 | 927 | find_changelog, | ||
213 | 928 | open_file, | ||
214 | 929 | ) | ||
215 | 906 | try: | 930 | try: |
216 | 907 | tree = WorkingTree.open_containing('.')[0] | 931 | tree = WorkingTree.open_containing('.')[0] |
217 | 908 | except NotBranchError: | 932 | except NotBranchError: |
218 | @@ -1009,10 +1033,18 @@ | |||
219 | 1009 | takes_args = ['version', 'location', 'upstream_branch?'] | 1033 | takes_args = ['version', 'location', 'upstream_branch?'] |
220 | 1010 | 1034 | ||
221 | 1011 | def run(self, version, location, upstream_branch=None, revision=None): | 1035 | def run(self, version, location, upstream_branch=None, revision=None): |
222 | 1036 | try: | ||
223 | 1037 | from debian.changelog import Version | ||
224 | 1038 | except ImportError: | ||
225 | 1039 | # Prior to 0.1.15 the debian module was called debian_bundle | ||
226 | 1040 | from debian_bundle.changelog import Version | ||
227 | 1012 | from bzrlib.plugins.builddeb.import_dsc import ( | 1041 | from bzrlib.plugins.builddeb.import_dsc import ( |
228 | 1013 | DistributionBranch, | 1042 | DistributionBranch, |
229 | 1014 | DistributionBranchSet, | 1043 | DistributionBranchSet, |
230 | 1015 | ) | 1044 | ) |
231 | 1045 | from bzrlib.plugins.builddeb.util import ( | ||
232 | 1046 | md5sum_filename, | ||
233 | 1047 | ) | ||
234 | 1016 | # TODO: search for similarity etc. | 1048 | # TODO: search for similarity etc. |
235 | 1017 | version = version.encode('utf8') | 1049 | version = version.encode('utf8') |
236 | 1018 | branch, _ = Branch.open_containing('.') | 1050 | branch, _ = Branch.open_containing('.') |
237 | @@ -1105,6 +1137,10 @@ | |||
238 | 1105 | aliases = ['bd-do'] | 1137 | aliases = ['bd-do'] |
239 | 1106 | 1138 | ||
240 | 1107 | def run(self, command_list=None): | 1139 | def run(self, command_list=None): |
241 | 1140 | import subprocess | ||
242 | 1141 | from bzrlib.plugins.builddeb.errors import ( | ||
243 | 1142 | BuildFailedError, | ||
244 | 1143 | ) | ||
245 | 1108 | from bzrlib.plugins.builddeb.source_distiller import ( | 1144 | from bzrlib.plugins.builddeb.source_distiller import ( |
246 | 1109 | MergeModeDistiller, | 1145 | MergeModeDistiller, |
247 | 1110 | ) | 1146 | ) |
248 | @@ -1120,6 +1156,10 @@ | |||
249 | 1120 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( | 1156 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( |
250 | 1121 | PristineTarSource, | 1157 | PristineTarSource, |
251 | 1122 | ) | 1158 | ) |
252 | 1159 | from bzrlib.plugins.builddeb.hooks import run_hook | ||
253 | 1160 | from bzrlib.plugins.builddeb.util import ( | ||
254 | 1161 | find_changelog, | ||
255 | 1162 | ) | ||
256 | 1123 | t = WorkingTree.open_containing('.')[0] | 1163 | t = WorkingTree.open_containing('.')[0] |
257 | 1124 | config = debuild_config(t, t) | 1164 | config = debuild_config(t, t) |
258 | 1125 | if config.build_type != BUILD_TYPE_MERGE: | 1165 | if config.build_type != BUILD_TYPE_MERGE: |
259 | @@ -1207,6 +1247,9 @@ | |||
260 | 1207 | DistributionBranch, | 1247 | DistributionBranch, |
261 | 1208 | DistributionBranchSet, | 1248 | DistributionBranchSet, |
262 | 1209 | ) | 1249 | ) |
263 | 1250 | from bzrlib.plugins.builddeb.util import ( | ||
264 | 1251 | find_changelog, | ||
265 | 1252 | ) | ||
266 | 1210 | t = WorkingTree.open_containing('.')[0] | 1253 | t = WorkingTree.open_containing('.')[0] |
267 | 1211 | t.lock_write() | 1254 | t.lock_write() |
268 | 1212 | try: | 1255 | try: |
269 | 1213 | 1256 | ||
270 | === modified file 'debian/changelog' | |||
271 | --- debian/changelog 2011-12-17 16:43:38 +0000 | |||
272 | +++ debian/changelog 2012-01-02 17:08:23 +0000 | |||
273 | @@ -1,8 +1,10 @@ | |||
274 | 1 | bzr-builddeb (2.8.1) UNRELEASED; urgency=low | 1 | bzr-builddeb (2.8.1) UNRELEASED; urgency=low |
275 | 2 | 2 | ||
276 | 3 | * New revision specifier 'upstream:'. LP: #905728 | 3 | * New revision specifier 'upstream:'. LP: #905728 |
277 | 4 | * Imports are now deferred in command definitions, to speed up | ||
278 | 5 | commands like 'bzr bash-completion'. LP: #903650 | ||
279 | 4 | 6 | ||
281 | 5 | -- Jelmer Vernooij <jelmer@debian.org> Sat, 17 Dec 2011 17:41:19 +0100 | 7 | -- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Jan 2012 17:57:33 +0100 |
282 | 6 | 8 | ||
283 | 7 | bzr-builddeb (2.8.0) unstable; urgency=low | 9 | bzr-builddeb (2.8.0) unstable; urgency=low |
284 | 8 | 10 |