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
1=== modified file 'cmds.py'
2--- cmds.py 2012-01-02 18:01:36 +0000
3+++ cmds.py 2012-01-02 22:05:24 +0000
4@@ -82,6 +82,48 @@
5 type=str)
6
7
8+def _get_changelog_info(tree, last_version=None, package=None, distribution=None):
9+ from bzrlib.plugins.builddeb.util import (
10+ find_changelog,
11+ find_last_distribution,
12+ lookup_distribution,
13+ )
14+ from bzrlib.plugins.builddeb.errors import (
15+ MissingChangelogError,
16+ )
17+ current_version = last_version
18+ try:
19+ (changelog, top_level) = find_changelog(tree, False, max_blocks=2)
20+ if last_version is None:
21+ current_version = changelog.version.upstream_version
22+ if package is None:
23+ package = changelog.package
24+ if distribution is None:
25+ distribution = find_last_distribution(changelog)
26+ if distribution is not None:
27+ note(gettext("Using distribution %s") % distribution)
28+ except MissingChangelogError:
29+ top_level = False
30+ changelog = None
31+ if distribution is None:
32+ note("No distribution specified, and no changelog, "
33+ "assuming 'debian'")
34+ distribution = "debian"
35+ if package is None:
36+ raise BzrCommandError("You did not specify --package, and "
37+ "there is no changelog from which to determine the "
38+ "package name, which is needed to know the name to "
39+ "give the .orig.tar.gz. Please specify --package.")
40+ distribution = distribution.lower()
41+ distribution_name = lookup_distribution(distribution)
42+ if distribution_name is None:
43+ raise BzrCommandError(gettext("Unknown target distribution: %s") \
44+ % distribution)
45+ return (current_version, package, distribution, distribution_name,
46+ changelog, top_level)
47+
48+
49+
50 class cmd_builddeb(Command):
51 """Builds a Debian package from a branch.
52
53@@ -633,46 +675,6 @@
54 return self._fetch_tarball(package, version, orig_dir,
55 locations, v3)
56
57- def _get_changelog_info(self, tree, last_version, package, distribution):
58- from bzrlib.plugins.builddeb.util import (
59- find_changelog,
60- find_last_distribution,
61- lookup_distribution,
62- )
63- from bzrlib.plugins.builddeb.errors import (
64- MissingChangelogError,
65- )
66- current_version = last_version
67- try:
68- (changelog, top_level) = find_changelog(tree, False, max_blocks=2)
69- if last_version is None:
70- current_version = changelog.version.upstream_version
71- if package is None:
72- package = changelog.package
73- if distribution is None:
74- distribution = find_last_distribution(changelog)
75- if distribution is not None:
76- note(gettext("Using distribution %s") % distribution)
77- except MissingChangelogError:
78- top_level = False
79- changelog = None
80- if distribution is None:
81- note("No distribution specified, and no changelog, "
82- "assuming 'debian'")
83- distribution = "debian"
84- if package is None:
85- raise BzrCommandError("You did not specify --package, and "
86- "there is no changelog from which to determine the "
87- "package name, which is needed to know the name to "
88- "give the .orig.tar.gz. Please specify --package.")
89- distribution = distribution.lower()
90- distribution_name = lookup_distribution(distribution)
91- if distribution_name is None:
92- raise BzrCommandError(gettext("Unknown target distribution: %s") \
93- % distribution)
94- return (current_version, package, distribution, distribution_name,
95- changelog, top_level)
96-
97 def run(self, location=None, upstream_branch=None, version=None,
98 distribution=None, package=None,
99 directory=".", revision=None, merge_type=None,
100@@ -710,7 +712,7 @@
101 "command.")
102 config = debuild_config(tree, tree)
103 (current_version, package, distribution, distribution_name,
104- changelog, top_level) = self._get_changelog_info(tree, last_version,
105+ changelog, top_level) = _get_changelog_info(tree, last_version,
106 package, distribution)
107 contains_upstream_source = tree_contains_upstream_source(tree)
108 if changelog is None:
109@@ -1160,10 +1162,25 @@
110 from bzrlib.plugins.builddeb.hooks import run_hook
111 from bzrlib.plugins.builddeb.util import (
112 find_changelog,
113+ guess_build_type,
114+ tree_contains_upstream_source,
115 )
116 t = WorkingTree.open_containing('.')[0]
117+ self.add_cleanup(t.lock_read().unlock)
118 config = debuild_config(t, t)
119- if config.build_type != BUILD_TYPE_MERGE:
120+ (current_version, package, distribution, distribution_name,
121+ changelog, top_level) = _get_changelog_info(t)
122+ contains_upstream_source = tree_contains_upstream_source(t)
123+ if changelog is None:
124+ changelog_version = None
125+ else:
126+ changelog_version = changelog.version
127+ build_type = config.build_type
128+ if build_type is None:
129+ build_type = guess_build_type(t, changelog_version,
130+ contains_upstream_source)
131+
132+ if build_type != BUILD_TYPE_MERGE:
133 raise BzrCommandError(gettext("This command only works for merge "
134 "mode packages. See /usr/share/doc/bzr-builddeb"
135 "/user_manual/merge.html for more information."))

Subscribers

People subscribed via source and target branches