Merge lp:~jelmer/bzr-builddeb/first-release into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Approved by: James Westby
Approved revision: 596
Merged at revision: 592
Proposed branch: lp:~jelmer/bzr-builddeb/first-release
Merge into: lp:bzr-builddeb
Diff against target: 171 lines (+61/-15)
7 files modified
cmds.py (+5/-4)
debian/changelog (+7/-0)
merge_upstream.py (+6/-2)
tests/blackbox/test_merge_upstream.py (+8/-0)
tests/test_merge_upstream.py (+23/-3)
tests/test_util.py (+7/-0)
util.py (+5/-6)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/first-release
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+68591@code.launchpad.net

Description of the change

When merging an upstream tarball into an empty branch, default to normal mode.
(#776528)

When creating a changelog file, version it.

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 2011-07-19 16:02:34 +0000
3+++ cmds.py 2011-07-20 19:31:15 +0000
4@@ -650,13 +650,14 @@
5 changelog, larstiq) = self._get_changelog_info(tree, last_version,
6 package, distribution)
7 contains_upstream_source = tree_contains_upstream_source(tree)
8- build_type = config.build_type
9- if build_type is None:
10+ if changelog is None:
11 changelog_version = None
12 else:
13 changelog_version = changelog.version
14- build_type = guess_build_type(tree, changelog_version,
15- contains_upstream_source)
16+ build_type = config.build_type
17+ if build_type is None:
18+ build_type = guess_build_type(tree, changelog_version,
19+ contains_upstream_source)
20 need_upstream_tarball = (build_type != BUILD_TYPE_MERGE)
21 if build_type == BUILD_TYPE_NATIVE:
22 raise BzrCommandError("Merge upstream in native mode is not "
23
24=== modified file 'debian/changelog'
25--- debian/changelog 2011-07-19 19:24:09 +0000
26+++ debian/changelog 2011-07-20 19:31:15 +0000
27@@ -1,3 +1,10 @@
28+bzr-builddeb (2.7.7) UNRELEASED; urgency=low
29+
30+ * Build type now defaults to normal mode when used in an empty tree.
31+ LP: #776528
32+
33+ -- Jelmer Vernooij <jelmer@debian.org> Wed, 20 Jul 2011 21:27:48 +0200
34+
35 bzr-builddeb (2.7.6) unstable; urgency=low
36
37 * Bump standards version to 3.9.2 (no changes).
38
39=== modified file 'merge_upstream.py'
40--- merge_upstream.py 2011-05-15 17:21:54 +0000
41+++ merge_upstream.py 2011-07-20 19:31:15 +0000
42@@ -101,9 +101,13 @@
43 str(package_version(upstream_version, distribution_name, epoch)),
44 "-D", "UNRELEASED", "--release-heuristic", "changelog",
45 "--package", package, entry_description]
46- if not tree.has_filename("debian/changelog"):
47+ create = (not tree.has_filename("debian/changelog"))
48+ if create:
49 argv.append("--create")
50- proc = subprocess.Popen(argv, cwd=tree.basedir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
51+ proc = subprocess.Popen(argv, cwd=tree.basedir, stdout=subprocess.PIPE,
52+ stderr=subprocess.PIPE)
53 (stdout, stderr) = proc.communicate()
54 if proc.returncode != 0:
55 raise DchError("Adding changelog entry failed: %s" % stderr)
56+ if create:
57+ tree.add(["debian/changelog"])
58
59=== modified file 'tests/blackbox/test_merge_upstream.py'
60--- tests/blackbox/test_merge_upstream.py 2011-06-23 10:29:54 +0000
61+++ tests/blackbox/test_merge_upstream.py 2011-07-20 19:31:15 +0000
62@@ -212,4 +212,12 @@
63 "--package", "bar", os.path.abspath(rel1.tarball)],
64 working_dir=tree.basedir)
65
66+ def test_new_package_from_empty_branch(self):
67+ upstream = self.make_upstream()
68+ tree = self.make_branch_and_tree("package")
69+ rel1 = self.release_upstream(upstream)
70+ self.run_bzr(['merge-upstream', '--version', str(rel1.version),
71+ "--package", "bar", os.path.abspath(rel1.tarball)],
72+ working_dir=tree.basedir)
73+
74 # vim: ts=4 sts=4 sw=4
75
76=== modified file 'tests/test_merge_upstream.py'
77--- tests/test_merge_upstream.py 2011-06-04 08:52:53 +0000
78+++ tests/test_merge_upstream.py 2011-07-20 19:31:15 +0000
79@@ -19,14 +19,18 @@
80 #
81
82 try:
83- from debian.changelog import Version
84+ from debian.changelog import Changelog, Version
85 except ImportError:
86 # Prior to 0.1.15 the debian module was called debian_bundle
87- from debian_bundle.changelog import Version
88+ from debian_bundle.changelog import Changelog, Version
89
90-from bzrlib.tests import TestCase
91+from bzrlib.tests import (
92+ TestCase,
93+ TestCaseWithTransport,
94+ )
95
96 from bzrlib.plugins.builddeb.merge_upstream import (
97+ changelog_add_new_version,
98 upstream_merge_changelog_line,
99 package_version,
100 )
101@@ -71,3 +75,19 @@
102 def test_plus(self):
103 self.assertEquals("New upstream release.",
104 upstream_merge_changelog_line("1.0+dfsg1"))
105+
106+
107+class ChangelogAddNewVersionTests(TestCaseWithTransport):
108+
109+ def test_add_new(self):
110+ tree = self.make_branch_and_tree(".")
111+ tree.lock_write()
112+ self.addCleanup(tree.unlock)
113+ tree.mkdir("debian")
114+ changelog_add_new_version(tree, "1.0", "sid", None, "somepkg")
115+ # changelog_add_new_version will version the changelog if it was created
116+ cl = Changelog(open('debian/changelog'))
117+ self.assertEquals(cl._blocks[0].package, "somepkg")
118+ self.assertEquals(cl._blocks[0].distributions, "UNRELEASED")
119+ self.assertEquals(cl._blocks[0].version, "1.0-1")
120+ self.assertEquals([], list(tree.filter_unversioned_files(["debian/changelog"])))
121
122=== modified file 'tests/test_util.py'
123--- tests/test_util.py 2011-07-15 14:16:52 +0000
124+++ tests/test_util.py 2011-07-20 19:31:15 +0000
125@@ -829,9 +829,16 @@
126 self.assertEquals(BUILD_TYPE_NATIVE,
127 guess_build_type(tree, Version("1.0"), True))
128
129+ def test_empty(self):
130+ # Empty tree and a non-native package -> NORMAL
131+ tree = self.make_branch_and_tree('.')
132+ self.assertEquals(BUILD_TYPE_NORMAL,
133+ guess_build_type(tree, Version("1.0-1"), None))
134+
135 def test_no_upstream_source(self):
136 # No upstream source code and a non-native package -> MERGE
137 tree = self.make_branch_and_tree('.')
138+ tree.mkdir("debian")
139 self.assertEquals(BUILD_TYPE_MERGE,
140 guess_build_type(tree, Version("1.0-1"), False))
141
142
143=== modified file 'util.py'
144--- util.py 2011-07-16 21:53:16 +0000
145+++ util.py 2011-07-20 19:31:15 +0000
146@@ -623,12 +623,11 @@
147
148 :param tree: A RevisionTree.
149 :return: Boolean indicating whether or not the tree contains the upstream
150- source
151+ source. None if the tree is empty
152 """
153- root = tree.inventory.root
154- if root is None:
155- return False # Empty tree
156- present_files = set(root.children.keys())
157+ present_files = set([f[0] for f in tree.list_files(recursive=False)])
158+ if len(present_files) == 0:
159+ return None
160 packaging_files = frozenset(["debian", ".bzr-builddeb", ".bzrignore"])
161 return (len(present_files - packaging_files) > 0)
162
163@@ -682,7 +681,7 @@
164
165 if version_native or format_native:
166 return BUILD_TYPE_NATIVE
167- if not contains_upstream_source:
168+ if contains_upstream_source == False:
169 # Default to merge mode if there's only a debian/ directory
170 return BUILD_TYPE_MERGE
171 else:

Subscribers

People subscribed via source and target branches