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
=== modified file 'cmds.py'
--- cmds.py 2009-03-04 13:05:56 +0000
+++ cmds.py 2009-04-15 13:15:21 +0000
@@ -75,6 +75,7 @@
75 )75 )
76from bzrlib.plugins.builddeb.upstream import UpstreamProvider76from bzrlib.plugins.builddeb.upstream import UpstreamProvider
77from bzrlib.plugins.builddeb.util import (find_changelog,77from bzrlib.plugins.builddeb.util import (find_changelog,
78 find_last_distribution,
78 lookup_distribution,79 lookup_distribution,
79 suite_to_distribution,80 suite_to_distribution,
80 tarball_name,81 tarball_name,
@@ -503,19 +504,20 @@
503 raise BzrCommandError("No location specified to merge")504 raise BzrCommandError("No location specified to merge")
504 changelog = None505 changelog = None
505 try:506 try:
506 changelog = find_changelog(tree, False)[0]507 changelog = find_changelog(tree, False, max_blocks=2)[0]
507 current_version = changelog.version508 current_version = changelog.version
508 if package is None:509 if package is None:
509 package = changelog.package510 package = changelog.package
510 if distribution is None:511 if distribution is None:
511 distribution = changelog.distributions.split(" ")[0]512 distribution = find_last_distribution(changelog)
512 info("Using distribution %s" % distribution)513 if distribution is not None:
514 info("Using distribution %s" % distribution)
513 except MissingChangelogError:515 except MissingChangelogError:
514 current_version = None516 current_version = None
515 if distribution is None:517 if distribution is None:
516 info("No distribution specified, and no changelog, "518 info("No distribution specified, and no changelog, "
517 "assuming 'debian'")519 "assuming 'debian'")
518 distribution = "debian"520 distribution = "debian"
519521
520 if package is None:522 if package is None:
521 raise BzrCommandError("You did not specify --package, and "523 raise BzrCommandError("You did not specify --package, and "
522524
=== modified file 'tests/test_util.py'
--- tests/test_util.py 2009-03-11 07:23:20 +0000
+++ tests/test_util.py 2009-04-15 13:12:47 +0000
@@ -37,6 +37,7 @@
37 find_bugs_fixed,37 find_bugs_fixed,
38 find_changelog,38 find_changelog,
39 find_extra_authors,39 find_extra_authors,
40 find_last_distribution,
40 find_thanks,41 find_thanks,
41 get_commit_info_from_changelog,42 get_commit_info_from_changelog,
42 get_snapshot_revision,43 get_snapshot_revision,
@@ -597,3 +598,33 @@
597 return self.ubuntu_bug_to_debian_bugs[ubuntu_bug]598 return self.ubuntu_bug_to_debian_bugs[ubuntu_bug]
598 except KeyError:599 except KeyError:
599 return []600 return []
601
602
603class FindLastDistributionTests(TestCase):
604
605 def create_changelog(self, *distributions):
606 changelog = Changelog()
607 changes = [" [ A. Hacker ]", " * Something"]
608 author = "J. Maintainer <maint@example.com"
609 for distro in distributions:
610 changelog.new_block(changes=changes, author=author,
611 distributions=distro)
612 return changelog
613
614 def test_first(self):
615 changelog = self.create_changelog("unstable")
616 self.assertEquals("unstable", find_last_distribution(changelog))
617
618 def test_second(self):
619 changelog = self.create_changelog("unstable", "UNRELEASED")
620 self.assertEquals("UNRELEASED", changelog.distributions)
621 self.assertEquals("unstable", find_last_distribution(changelog))
622
623 def test_empty(self):
624 changelog = self.create_changelog()
625 self.assertEquals(None, find_last_distribution(changelog))
626
627 def test_only_unreleased(self):
628 changelog = self.create_changelog("UNRELEASED")
629 self.assertEquals(None, find_last_distribution(changelog))
630
600631
=== modified file 'util.py'
--- util.py 2009-03-11 07:23:20 +0000
+++ util.py 2009-04-15 13:12:47 +0000
@@ -63,16 +63,16 @@
63 shutil.copy(path, todir)63 shutil.copy(path, todir)
6464
6565
66def find_changelog(t, merge):66def find_changelog(t, merge, max_blocks=1):
67 """Find the changelog in the given tree.67 """Find the changelog in the given tree.
6868
69 First looks for 'debian/changelog'. If "merge" is true will also69 First looks for 'debian/changelog'. If "merge" is true will also
70 look for 'changelog'.70 look for 'changelog'.
7171
72 The returned changelog is created with 'max_blocks=1' and72 The returned changelog is created with 'allow_empty_author=True'
73 'allow_empty_author=True'. The first to try and prevent old broken73 as some people do this but still want to build.
74 changelog entries from causing the command to fail, and the74 'max_blocks' defaults to 1 to try and prevent old broken
75 second as some people do this but still want to build.75 changelog entries from causing the command to fail,
7676
77 "larstiq" is a subset of "merge" mode. It indicates that the77 "larstiq" is a subset of "merge" mode. It indicates that the
78 '.bzr' dir is at the same level as 'changelog' etc., rather78 '.bzr' dir is at the same level as 'changelog' etc., rather
@@ -80,6 +80,7 @@
8080
81 :param t: the Tree to look in.81 :param t: the Tree to look in.
82 :param merge: whether this is a "merge" package.82 :param merge: whether this is a "merge" package.
83 :param max_blocks: Number of max_blocks to parse (defaults to 1)
83 :return: (changelog, larstiq) where changelog is the Changelog,84 :return: (changelog, larstiq) where changelog is the Changelog,
84 and larstiq is a boolean indicating whether the file is at85 and larstiq is a boolean indicating whether the file is at
85 'changelog' if merge was given, False otherwise.86 'changelog' if merge was given, False otherwise.
@@ -115,7 +116,7 @@
115 t.unlock()116 t.unlock()
116 changelog = Changelog()117 changelog = Changelog()
117 try:118 try:
118 changelog.parse_changelog(contents, max_blocks=1, allow_empty_author=True)119 changelog.parse_changelog(contents, max_blocks=max_blocks, allow_empty_author=True)
119 except ChangelogParseError, e:120 except ChangelogParseError, e:
120 raise UnparseableChangelog(str(e))121 raise UnparseableChangelog(str(e))
121 return changelog, larstiq122 return changelog, larstiq
@@ -398,3 +399,17 @@
398 thanks = find_thanks(changes)399 thanks = find_thanks(changes)
399 message = "\n".join(changes)400 message = "\n".join(changes)
400 return (message, authors, thanks, bugs)401 return (message, authors, thanks, bugs)
402
403
404def find_last_distribution(changelog):
405 """Find the last changelog that was used in a changelog.
406
407 This will skip stanzas with the 'UNRELEASED' distribution.
408
409 :param changelog: Changelog to analyze
410 """
411 for block in changelog._blocks:
412 distribution = block.distributions.split(" ")[0]
413 if distribution != "UNRELEASED":
414 return distribution
415 return None

Subscribers

People subscribed via source and target branches