Merge lp:~jelmer/bzr-builddeb/merge-1 into lp:~bzr-builddeb-hackers/bzr-builddeb/trunk-old

Proposed by Jelmer Vernooij
Status: Merged
Merge reported by: James Westby
Merged at revision: not available
Proposed branch: lp:~jelmer/bzr-builddeb/merge-1
Merge into: lp:~bzr-builddeb-hackers/bzr-builddeb/trunk-old
Diff against target: None lines
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/merge-1
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+5564@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

The attached patch makes bzr-builddeb look past the first changelog
entry that contains UNRELEASED and makes it use the next entry's
distribution instead.

Cheers,

Jelmer

Revision history for this message
James Westby (james-w) wrote :

Merged, thanks.

James

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 2009-03-04 13:05:56 +0000
3+++ cmds.py 2009-04-15 13:15:21 +0000
4@@ -75,6 +75,7 @@
5 )
6 from bzrlib.plugins.builddeb.upstream import UpstreamProvider
7 from bzrlib.plugins.builddeb.util import (find_changelog,
8+ find_last_distribution,
9 lookup_distribution,
10 suite_to_distribution,
11 tarball_name,
12@@ -503,19 +504,20 @@
13 raise BzrCommandError("No location specified to merge")
14 changelog = None
15 try:
16- changelog = find_changelog(tree, False)[0]
17+ changelog = find_changelog(tree, False, max_blocks=2)[0]
18 current_version = changelog.version
19 if package is None:
20 package = changelog.package
21 if distribution is None:
22- distribution = changelog.distributions.split(" ")[0]
23- info("Using distribution %s" % distribution)
24+ distribution = find_last_distribution(changelog)
25+ if distribution is not None:
26+ info("Using distribution %s" % distribution)
27 except MissingChangelogError:
28 current_version = None
29- if distribution is None:
30- info("No distribution specified, and no changelog, "
31- "assuming 'debian'")
32- distribution = "debian"
33+ if distribution is None:
34+ info("No distribution specified, and no changelog, "
35+ "assuming 'debian'")
36+ distribution = "debian"
37
38 if package is None:
39 raise BzrCommandError("You did not specify --package, and "
40
41=== modified file 'tests/test_util.py'
42--- tests/test_util.py 2009-03-11 07:23:20 +0000
43+++ tests/test_util.py 2009-04-15 13:12:47 +0000
44@@ -37,6 +37,7 @@
45 find_bugs_fixed,
46 find_changelog,
47 find_extra_authors,
48+ find_last_distribution,
49 find_thanks,
50 get_commit_info_from_changelog,
51 get_snapshot_revision,
52@@ -597,3 +598,33 @@
53 return self.ubuntu_bug_to_debian_bugs[ubuntu_bug]
54 except KeyError:
55 return []
56+
57+
58+class FindLastDistributionTests(TestCase):
59+
60+ def create_changelog(self, *distributions):
61+ changelog = Changelog()
62+ changes = [" [ A. Hacker ]", " * Something"]
63+ author = "J. Maintainer <maint@example.com"
64+ for distro in distributions:
65+ changelog.new_block(changes=changes, author=author,
66+ distributions=distro)
67+ return changelog
68+
69+ def test_first(self):
70+ changelog = self.create_changelog("unstable")
71+ self.assertEquals("unstable", find_last_distribution(changelog))
72+
73+ def test_second(self):
74+ changelog = self.create_changelog("unstable", "UNRELEASED")
75+ self.assertEquals("UNRELEASED", changelog.distributions)
76+ self.assertEquals("unstable", find_last_distribution(changelog))
77+
78+ def test_empty(self):
79+ changelog = self.create_changelog()
80+ self.assertEquals(None, find_last_distribution(changelog))
81+
82+ def test_only_unreleased(self):
83+ changelog = self.create_changelog("UNRELEASED")
84+ self.assertEquals(None, find_last_distribution(changelog))
85+
86
87=== modified file 'util.py'
88--- util.py 2009-03-11 07:23:20 +0000
89+++ util.py 2009-04-15 13:12:47 +0000
90@@ -63,16 +63,16 @@
91 shutil.copy(path, todir)
92
93
94-def find_changelog(t, merge):
95+def find_changelog(t, merge, max_blocks=1):
96 """Find the changelog in the given tree.
97
98 First looks for 'debian/changelog'. If "merge" is true will also
99 look for 'changelog'.
100
101- The returned changelog is created with 'max_blocks=1' and
102- 'allow_empty_author=True'. The first to try and prevent old broken
103- changelog entries from causing the command to fail, and the
104- second as some people do this but still want to build.
105+ The returned changelog is created with 'allow_empty_author=True'
106+ as some people do this but still want to build.
107+ 'max_blocks' defaults to 1 to try and prevent old broken
108+ changelog entries from causing the command to fail,
109
110 "larstiq" is a subset of "merge" mode. It indicates that the
111 '.bzr' dir is at the same level as 'changelog' etc., rather
112@@ -80,6 +80,7 @@
113
114 :param t: the Tree to look in.
115 :param merge: whether this is a "merge" package.
116+ :param max_blocks: Number of max_blocks to parse (defaults to 1)
117 :return: (changelog, larstiq) where changelog is the Changelog,
118 and larstiq is a boolean indicating whether the file is at
119 'changelog' if merge was given, False otherwise.
120@@ -115,7 +116,7 @@
121 t.unlock()
122 changelog = Changelog()
123 try:
124- changelog.parse_changelog(contents, max_blocks=1, allow_empty_author=True)
125+ changelog.parse_changelog(contents, max_blocks=max_blocks, allow_empty_author=True)
126 except ChangelogParseError, e:
127 raise UnparseableChangelog(str(e))
128 return changelog, larstiq
129@@ -398,3 +399,17 @@
130 thanks = find_thanks(changes)
131 message = "\n".join(changes)
132 return (message, authors, thanks, bugs)
133+
134+
135+def find_last_distribution(changelog):
136+ """Find the last changelog that was used in a changelog.
137+
138+ This will skip stanzas with the 'UNRELEASED' distribution.
139+
140+ :param changelog: Changelog to analyze
141+ """
142+ for block in changelog._blocks:
143+ distribution = block.distributions.split(" ")[0]
144+ if distribution != "UNRELEASED":
145+ return distribution
146+ return None

Subscribers

People subscribed via source and target branches