Merge lp:~jelmer/bzr-builddeb/fix-bd-do-build-type-guessing into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 681
Proposed branch: lp:~jelmer/bzr-builddeb/fix-bd-do-build-type-guessing
Merge into: lp:bzr-builddeb
Diff against target: 135 lines (+59/-42)
1 file modified
cmds.py (+59/-42)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/fix-bd-do-build-type-guessing
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+87294@code.launchpad.net

Description of the change

Fix build_type guessing for 'bzr bd-do'.

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
=== modified file 'cmds.py'
--- cmds.py 2012-01-02 18:01:36 +0000
+++ cmds.py 2012-01-02 22:05:24 +0000
@@ -82,6 +82,48 @@
82 type=str)82 type=str)
8383
8484
85def _get_changelog_info(tree, last_version=None, package=None, distribution=None):
86 from bzrlib.plugins.builddeb.util import (
87 find_changelog,
88 find_last_distribution,
89 lookup_distribution,
90 )
91 from bzrlib.plugins.builddeb.errors import (
92 MissingChangelogError,
93 )
94 current_version = last_version
95 try:
96 (changelog, top_level) = find_changelog(tree, False, max_blocks=2)
97 if last_version is None:
98 current_version = changelog.version.upstream_version
99 if package is None:
100 package = changelog.package
101 if distribution is None:
102 distribution = find_last_distribution(changelog)
103 if distribution is not None:
104 note(gettext("Using distribution %s") % distribution)
105 except MissingChangelogError:
106 top_level = False
107 changelog = None
108 if distribution is None:
109 note("No distribution specified, and no changelog, "
110 "assuming 'debian'")
111 distribution = "debian"
112 if package is None:
113 raise BzrCommandError("You did not specify --package, and "
114 "there is no changelog from which to determine the "
115 "package name, which is needed to know the name to "
116 "give the .orig.tar.gz. Please specify --package.")
117 distribution = distribution.lower()
118 distribution_name = lookup_distribution(distribution)
119 if distribution_name is None:
120 raise BzrCommandError(gettext("Unknown target distribution: %s") \
121 % distribution)
122 return (current_version, package, distribution, distribution_name,
123 changelog, top_level)
124
125
126
85class cmd_builddeb(Command):127class cmd_builddeb(Command):
86 """Builds a Debian package from a branch.128 """Builds a Debian package from a branch.
87129
@@ -633,46 +675,6 @@
633 return self._fetch_tarball(package, version, orig_dir,675 return self._fetch_tarball(package, version, orig_dir,
634 locations, v3)676 locations, v3)
635677
636 def _get_changelog_info(self, tree, last_version, package, distribution):
637 from bzrlib.plugins.builddeb.util import (
638 find_changelog,
639 find_last_distribution,
640 lookup_distribution,
641 )
642 from bzrlib.plugins.builddeb.errors import (
643 MissingChangelogError,
644 )
645 current_version = last_version
646 try:
647 (changelog, top_level) = find_changelog(tree, False, max_blocks=2)
648 if last_version is None:
649 current_version = changelog.version.upstream_version
650 if package is None:
651 package = changelog.package
652 if distribution is None:
653 distribution = find_last_distribution(changelog)
654 if distribution is not None:
655 note(gettext("Using distribution %s") % distribution)
656 except MissingChangelogError:
657 top_level = False
658 changelog = None
659 if distribution is None:
660 note("No distribution specified, and no changelog, "
661 "assuming 'debian'")
662 distribution = "debian"
663 if package is None:
664 raise BzrCommandError("You did not specify --package, and "
665 "there is no changelog from which to determine the "
666 "package name, which is needed to know the name to "
667 "give the .orig.tar.gz. Please specify --package.")
668 distribution = distribution.lower()
669 distribution_name = lookup_distribution(distribution)
670 if distribution_name is None:
671 raise BzrCommandError(gettext("Unknown target distribution: %s") \
672 % distribution)
673 return (current_version, package, distribution, distribution_name,
674 changelog, top_level)
675
676 def run(self, location=None, upstream_branch=None, version=None,678 def run(self, location=None, upstream_branch=None, version=None,
677 distribution=None, package=None,679 distribution=None, package=None,
678 directory=".", revision=None, merge_type=None,680 directory=".", revision=None, merge_type=None,
@@ -710,7 +712,7 @@
710 "command.")712 "command.")
711 config = debuild_config(tree, tree)713 config = debuild_config(tree, tree)
712 (current_version, package, distribution, distribution_name,714 (current_version, package, distribution, distribution_name,
713 changelog, top_level) = self._get_changelog_info(tree, last_version,715 changelog, top_level) = _get_changelog_info(tree, last_version,
714 package, distribution)716 package, distribution)
715 contains_upstream_source = tree_contains_upstream_source(tree)717 contains_upstream_source = tree_contains_upstream_source(tree)
716 if changelog is None:718 if changelog is None:
@@ -1160,10 +1162,25 @@
1160 from bzrlib.plugins.builddeb.hooks import run_hook1162 from bzrlib.plugins.builddeb.hooks import run_hook
1161 from bzrlib.plugins.builddeb.util import (1163 from bzrlib.plugins.builddeb.util import (
1162 find_changelog,1164 find_changelog,
1165 guess_build_type,
1166 tree_contains_upstream_source,
1163 )1167 )
1164 t = WorkingTree.open_containing('.')[0]1168 t = WorkingTree.open_containing('.')[0]
1169 self.add_cleanup(t.lock_read().unlock)
1165 config = debuild_config(t, t)1170 config = debuild_config(t, t)
1166 if config.build_type != BUILD_TYPE_MERGE:1171 (current_version, package, distribution, distribution_name,
1172 changelog, top_level) = _get_changelog_info(t)
1173 contains_upstream_source = tree_contains_upstream_source(t)
1174 if changelog is None:
1175 changelog_version = None
1176 else:
1177 changelog_version = changelog.version
1178 build_type = config.build_type
1179 if build_type is None:
1180 build_type = guess_build_type(t, changelog_version,
1181 contains_upstream_source)
1182
1183 if build_type != BUILD_TYPE_MERGE:
1167 raise BzrCommandError(gettext("This command only works for merge "1184 raise BzrCommandError(gettext("This command only works for merge "
1168 "mode packages. See /usr/share/doc/bzr-builddeb"1185 "mode packages. See /usr/share/doc/bzr-builddeb"
1169 "/user_manual/merge.html for more information."))1186 "/user_manual/merge.html for more information."))

Subscribers

People subscribed via source and target branches