[Pkg-bazaar-commits] ./bzr-builddeb/trunk r350: Look past UNRELEASED changelog entries in merge-upstream. Thanks Jelmer.
James Westby
james.westby at canonical.com
Wed Jul 15 18:17:12 UTC 2009
------------------------------------------------------------
revno: 350
author: Jelmer Vernooij <jelmer at samba.org>
committer: James Westby <james.westby at canonical.com>
branch nick: trunk
timestamp: Wed 2009-07-15 19:17:12 +0100
message:
Look past UNRELEASED changelog entries in merge-upstream. Thanks Jelmer.
modified:
cmds.py
tests/test_util.py
util.py
-------------- next part --------------
=== modified file 'cmds.py'
--- a/cmds.py 2009-07-04 20:47:57 +0000
+++ b/cmds.py 2009-07-15 18:17:12 +0000
@@ -77,6 +77,7 @@
from bzrlib.plugins.builddeb.upstream import UpstreamProvider
from bzrlib.plugins.builddeb.util import (find_changelog,
get_export_upstream_revision,
+ find_last_distribution,
lookup_distribution,
suite_to_distribution,
tarball_name,
@@ -504,19 +505,20 @@
raise BzrCommandError("No location specified to merge")
changelog = None
try:
- changelog = find_changelog(tree, False)[0]
+ changelog = find_changelog(tree, False, max_blocks=2)[0]
current_version = changelog.version
if package is None:
package = changelog.package
if distribution is None:
- distribution = changelog.distributions.split(" ")[0]
- info("Using distribution %s" % distribution)
+ distribution = find_last_distribution(changelog)
+ if distribution is not None:
+ info("Using distribution %s" % distribution)
except MissingChangelogError:
current_version = None
- if distribution is None:
- info("No distribution specified, and no changelog, "
- "assuming 'debian'")
- distribution = "debian"
+ if distribution is None:
+ info("No distribution specified, and no changelog, "
+ "assuming 'debian'")
+ distribution = "debian"
if package is None:
raise BzrCommandError("You did not specify --package, and "
=== modified file 'tests/test_util.py'
--- a/tests/test_util.py 2009-03-11 07:23:20 +0000
+++ b/tests/test_util.py 2009-07-15 18:17:12 +0000
@@ -37,6 +37,7 @@
find_bugs_fixed,
find_changelog,
find_extra_authors,
+ find_last_distribution,
find_thanks,
get_commit_info_from_changelog,
get_snapshot_revision,
@@ -597,3 +598,33 @@
return self.ubuntu_bug_to_debian_bugs[ubuntu_bug]
except KeyError:
return []
+
+
+class FindLastDistributionTests(TestCase):
+
+ def create_changelog(self, *distributions):
+ changelog = Changelog()
+ changes = [" [ A. Hacker ]", " * Something"]
+ author = "J. Maintainer <maint at example.com"
+ for distro in distributions:
+ changelog.new_block(changes=changes, author=author,
+ distributions=distro)
+ return changelog
+
+ def test_first(self):
+ changelog = self.create_changelog("unstable")
+ self.assertEquals("unstable", find_last_distribution(changelog))
+
+ def test_second(self):
+ changelog = self.create_changelog("unstable", "UNRELEASED")
+ self.assertEquals("UNRELEASED", changelog.distributions)
+ self.assertEquals("unstable", find_last_distribution(changelog))
+
+ def test_empty(self):
+ changelog = self.create_changelog()
+ self.assertEquals(None, find_last_distribution(changelog))
+
+ def test_only_unreleased(self):
+ changelog = self.create_changelog("UNRELEASED")
+ self.assertEquals(None, find_last_distribution(changelog))
+
=== modified file 'util.py'
--- a/util.py 2009-07-04 19:17:28 +0000
+++ b/util.py 2009-07-15 18:17:12 +0000
@@ -63,16 +63,16 @@
shutil.copy(path, todir)
-def find_changelog(t, merge):
+def find_changelog(t, merge, max_blocks=1):
"""Find the changelog in the given tree.
First looks for 'debian/changelog'. If "merge" is true will also
look for 'changelog'.
- The returned changelog is created with 'max_blocks=1' and
- 'allow_empty_author=True'. The first to try and prevent old broken
- changelog entries from causing the command to fail, and the
- second as some people do this but still want to build.
+ The returned changelog is created with 'allow_empty_author=True'
+ as some people do this but still want to build.
+ 'max_blocks' defaults to 1 to try and prevent old broken
+ changelog entries from causing the command to fail,
"larstiq" is a subset of "merge" mode. It indicates that the
'.bzr' dir is at the same level as 'changelog' etc., rather
@@ -80,6 +80,7 @@
:param t: the Tree to look in.
:param merge: whether this is a "merge" package.
+ :param max_blocks: Number of max_blocks to parse (defaults to 1)
:return: (changelog, larstiq) where changelog is the Changelog,
and larstiq is a boolean indicating whether the file is at
'changelog' if merge was given, False otherwise.
@@ -115,7 +116,7 @@
t.unlock()
changelog = Changelog()
try:
- changelog.parse_changelog(contents, max_blocks=1, allow_empty_author=True)
+ changelog.parse_changelog(contents, max_blocks=max_blocks, allow_empty_author=True)
except ChangelogParseError, e:
raise UnparseableChangelog(str(e))
return changelog, larstiq
@@ -412,3 +413,17 @@
thanks = find_thanks(changes)
message = "\n".join(changes)
return (message, authors, thanks, bugs)
+
+
+def find_last_distribution(changelog):
+ """Find the last changelog that was used in a changelog.
+
+ This will skip stanzas with the 'UNRELEASED' distribution.
+
+ :param changelog: Changelog to analyze
+ """
+ for block in changelog._blocks:
+ distribution = block.distributions.split(" ")[0]
+ if distribution != "UNRELEASED":
+ return distribution
+ return None
More information about the Pkg-bazaar-commits
mailing list