Merge lp:~jelmer/bzr-builddeb/commands-are-lazy into lp:bzr-builddeb

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
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+85468@code.launchpad.net

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
Vincent Ladeuil (vila) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmds.py'
--- cmds.py 2011-12-03 01:24:37 +0000
+++ cmds.py 2011-12-13 11:42:23 +0000
@@ -47,7 +47,6 @@
47 NoWorkingTree,47 NoWorkingTree,
48 )48 )
49from bzrlib.option import Option49from bzrlib.option import Option
50from bzrlib.tag import _merge_tags_if_possible
51from bzrlib.trace import note, warning50from bzrlib.trace import note, warning
52from bzrlib.workingtree import WorkingTree51from bzrlib.workingtree import WorkingTree
5352
@@ -55,12 +54,8 @@
55 default_build_dir,54 default_build_dir,
56 default_orig_dir,55 default_orig_dir,
57 default_result_dir,56 default_result_dir,
58 dh_make,
59 gettext,57 gettext,
60 )58 )
61from bzrlib.plugins.builddeb.builder import (
62 DebBuild,
63 )
64from bzrlib.plugins.builddeb.config import (59from bzrlib.plugins.builddeb.config import (
65 BUILD_TYPE_MERGE,60 BUILD_TYPE_MERGE,
66 BUILD_TYPE_NATIVE,61 BUILD_TYPE_NATIVE,
@@ -75,51 +70,24 @@
75 StrictBuildFailed,70 StrictBuildFailed,
76 )71 )
77from bzrlib.plugins.builddeb.hooks import run_hook72from bzrlib.plugins.builddeb.hooks import run_hook
78from bzrlib.plugins.builddeb.import_dsc import (
79 DistributionBranch,
80 DistributionBranchSet,
81 DscCache,
82 DscComp,
83 )
84from bzrlib.plugins.builddeb.merge_package import fix_ancestry_as_needed
85from bzrlib.plugins.builddeb.source_distiller import (
86 FullSourceDistiller,
87 MergeModeDistiller,
88 NativeSourceDistiller,
89 )
90from bzrlib.plugins.builddeb.upstream import (
91 AptSource,
92 DebianRulesSource,
93 SelfSplitSource,
94 TarfileSource,
95 UScanSource,
96 UpstreamProvider,
97 )
98from bzrlib.plugins.builddeb.upstream.branch import (
99 LazyUpstreamBranchSource,
100 UpstreamBranchSource,
101 )
102from bzrlib.plugins.builddeb.upstream.pristinetar import (
103 PristineTarSource,
104 )
105from bzrlib.plugins.builddeb.util import (73from bzrlib.plugins.builddeb.util import (
106 FORMAT_3_0_QUILT,74 FORMAT_3_0_QUILT,
107 FORMAT_3_0_NATIVE,75 FORMAT_3_0_NATIVE,
108 component_from_orig_tarball,76 component_from_orig_tarball,
109 debuild_config,77 debuild_config,
110 dget_changes,78 dget_changes,
111 find_changelog,79 find_changelog,
112 find_last_distribution,80 find_last_distribution,
113 find_previous_upload,81 find_previous_upload,
114 get_source_format,82 get_source_format,
115 guess_build_type,83 guess_build_type,
116 lookup_distribution,84 lookup_distribution,
117 md5sum_filename,85 md5sum_filename,
118 open_file,86 open_file,
119 open_file_via_transport,87 open_file_via_transport,
120 tarball_name,88 tarball_name,
121 tree_contains_upstream_source,89 tree_contains_upstream_source,
122 )90 )
12391
124dont_purge_opt = Option('dont-purge',92dont_purge_opt = Option('dont-purge',
125 help="Don't purge the build directory after building.")93 help="Don't purge the build directory after building.")
@@ -312,6 +280,9 @@
312280
313 def _get_upstream_branch(self, export_upstream, export_upstream_revision,281 def _get_upstream_branch(self, export_upstream, export_upstream_revision,
314 config, version):282 config, version):
283 from bzrlib.plugins.builddeb.upstream.branch import (
284 LazyUpstreamBranchSource,
285 )
315 upstream_source = LazyUpstreamBranchSource(export_upstream,286 upstream_source = LazyUpstreamBranchSource(export_upstream,
316 config=config)287 config=config)
317 if export_upstream_revision:288 if export_upstream_revision:
@@ -327,6 +298,26 @@
327 quick=False, reuse=False, native=None,298 quick=False, reuse=False, native=None,
328 source=False, revision=None, result=None, package_merge=None,299 source=False, revision=None, result=None, package_merge=None,
329 strict=False):300 strict=False):
301 from bzrlib.plugins.builddeb.source_distiller import (
302 FullSourceDistiller,
303 MergeModeDistiller,
304 NativeSourceDistiller,
305 )
306 from bzrlib.plugins.builddeb.builder import DebBuild
307 from bzrlib.plugins.builddeb.upstream.branch import (
308 LazyUpstreamBranchSource,
309 )
310 from bzrlib.plugins.builddeb.upstream import (
311 AptSource,
312 DebianRulesSource,
313 SelfSplitSource,
314 UScanSource,
315 UpstreamProvider,
316 )
317 from bzrlib.plugins.builddeb.upstream.pristinetar import (
318 PristineTarSource,
319 )
320
330 if result is not None:321 if result is not None:
331 warning(gettext("--result is deprecated, use --result-dir instead"))322 warning(gettext("--result is deprecated, use --result-dir instead"))
332 location, build_options, source = self._branch_and_build_options(323 location, build_options, source = self._branch_and_build_options(
@@ -476,6 +467,15 @@
476 takes_args = ["version?"]467 takes_args = ["version?"]
477468
478 def run(self, directory='.', version=None):469 def run(self, directory='.', version=None):
470 from bzrlib.plugins.builddeb.upstream import (
471 AptSource,
472 DebianRulesSource,
473 UScanSource,
474 UpstreamProvider,
475 )
476 from bzrlib.plugins.builddeb.upstream.pristinetar import (
477 PristineTarSource,
478 )
479 tree = WorkingTree.open_containing(directory)[0]479 tree = WorkingTree.open_containing(directory)[0]
480 config = debuild_config(tree, tree)480 config = debuild_config(tree, tree)
481481
@@ -594,6 +594,10 @@
594 def _do_merge(self, tree, tarball_filenames, package, version,594 def _do_merge(self, tree, tarball_filenames, package, version,
595 current_version, upstream_branch, upstream_revisions, merge_type,595 current_version, upstream_branch, upstream_revisions, merge_type,
596 force):596 force):
597 from bzrlib.plugins.builddeb.import_dsc import (
598 DistributionBranch,
599 DistributionBranchSet,
600 )
597 db = DistributionBranch(tree.branch, tree.branch, tree=tree)601 db = DistributionBranch(tree.branch, tree.branch, tree=tree)
598 dbs = DistributionBranchSet()602 dbs = DistributionBranchSet()
599 dbs.add_branch(db)603 dbs.add_branch(db)
@@ -673,6 +677,10 @@
673 distribution=None, package=None,677 distribution=None, package=None,
674 directory=".", revision=None, merge_type=None,678 directory=".", revision=None, merge_type=None,
675 last_version=None, force=None, snapshot=False, launchpad=False):679 last_version=None, force=None, snapshot=False, launchpad=False):
680 from bzrlib.plugins.builddeb.upstream.branch import (
681 UpstreamBranchSource,
682 )
683
676 tree, _ = WorkingTree.open_containing(directory)684 tree, _ = WorkingTree.open_containing(directory)
677 tree.lock_write()685 tree.lock_write()
678 try:686 try:
@@ -783,7 +791,8 @@
783 "'export-upstream-revision' in the configuration." %791 "'export-upstream-revision' in the configuration." %
784 (version, upstream_branch_source))792 (version, upstream_branch_source))
785 if need_upstream_tarball:793 if need_upstream_tarball:
786 target_dir = tempfile.mkdtemp() # FIXME: Cleanup?794 target_dir = tempfile.mkdtemp()
795 self.add_cleanup(shutil.rmtree, target_dir)
787 try:796 try:
788 locations = primary_upstream_source.fetch_tarballs(797 locations = primary_upstream_source.fetch_tarballs(
789 package, version, target_dir, components=[None])798 package, version, target_dir, components=[None])
@@ -859,6 +868,10 @@
859 takes_options = [filename_opt]868 takes_options = [filename_opt]
860869
861 def import_many(self, db, files_list, orig_target):870 def import_many(self, db, files_list, orig_target):
871 from bzrlib.plugins.builddeb.import_dsc import (
872 DscCache,
873 DscComp,
874 )
862 cache = DscCache()875 cache = DscCache()
863 files_list.sort(cmp=DscComp(cache).cmp)876 files_list.sort(cmp=DscComp(cache).cmp)
864 if not os.path.exists(orig_target):877 if not os.path.exists(orig_target):
@@ -882,6 +895,10 @@
882 db.import_package(os.path.join(orig_target, filename))895 db.import_package(os.path.join(orig_target, filename))
883896
884 def run(self, files_list, file=None):897 def run(self, files_list, file=None):
898 from bzrlib.plugins.builddeb.import_dsc import (
899 DistributionBranch,
900 DistributionBranchSet,
901 )
885 try:902 try:
886 tree = WorkingTree.open_containing('.')[0]903 tree = WorkingTree.open_containing('.')[0]
887 except NotBranchError:904 except NotBranchError:
@@ -988,6 +1005,10 @@
988 takes_args = ['version', 'location', 'upstream_branch?']1005 takes_args = ['version', 'location', 'upstream_branch?']
9891006
990 def run(self, version, location, upstream_branch=None, revision=None):1007 def run(self, version, location, upstream_branch=None, revision=None):
1008 from bzrlib.plugins.builddeb.import_dsc import (
1009 DistributionBranch,
1010 DistributionBranchSet,
1011 )
991 # TODO: search for similarity etc.1012 # TODO: search for similarity etc.
992 version = version.encode('utf8')1013 version = version.encode('utf8')
993 branch, _ = Branch.open_containing('.')1014 branch, _ = Branch.open_containing('.')
@@ -1080,6 +1101,21 @@
1080 aliases = ['bd-do']1101 aliases = ['bd-do']
10811102
1082 def run(self, command_list=None):1103 def run(self, command_list=None):
1104 from bzrlib.plugins.builddeb.source_distiller import (
1105 MergeModeDistiller,
1106 )
1107 from bzrlib.plugins.builddeb.builder import (
1108 DebBuild,
1109 )
1110 from bzrlib.plugins.builddeb.upstream import (
1111 AptSource,
1112 DebianRulesSource,
1113 UScanSource,
1114 UpstreamProvider,
1115 )
1116 from bzrlib.plugins.builddeb.upstream.pristinetar import (
1117 PristineTarSource,
1118 )
1083 t = WorkingTree.open_containing('.')[0]1119 t = WorkingTree.open_containing('.')[0]
1084 config = debuild_config(t, t)1120 config = debuild_config(t, t)
1085 if config.build_type != BUILD_TYPE_MERGE:1121 if config.build_type != BUILD_TYPE_MERGE:
@@ -1163,6 +1199,10 @@
1163 takes_options = [merge_opt, force]1199 takes_options = [merge_opt, force]
11641200
1165 def run(self, merge=None, force=None):1201 def run(self, merge=None, force=None):
1202 from bzrlib.plugins.builddeb.import_dsc import (
1203 DistributionBranch,
1204 DistributionBranchSet,
1205 )
1166 t = WorkingTree.open_containing('.')[0]1206 t = WorkingTree.open_containing('.')[0]
1167 t.lock_write()1207 t.lock_write()
1168 try:1208 try:
@@ -1208,6 +1248,8 @@
1208 takes_args = ['source']1248 takes_args = ['source']
12091249
1210 def run(self, source, revision=None):1250 def run(self, source, revision=None):
1251 from bzrlib.tag import _merge_tags_if_possible
1252 from bzrlib.plugins.builddeb.merge_package import fix_ancestry_as_needed
1211 source_branch = None1253 source_branch = None
1212 # Get the target branch.1254 # Get the target branch.
1213 try:1255 try:
@@ -1287,6 +1329,7 @@
1287 takes_options = [bzr_only_opt, v3_opt]1329 takes_options = [bzr_only_opt, v3_opt]
12881330
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):
1332 from bzrlib.plugins.builddeb import dh_make
1290 tree = dh_make.import_upstream(tarball, package_name,1333 tree = dh_make.import_upstream(tarball, package_name,
1291 version.encode("utf-8"), use_v3=v3)1334 version.encode("utf-8"), use_v3=v3)
1292 if not bzr_only:1335 if not bzr_only:

Subscribers

People subscribed via source and target branches