Merge lp:~jelmer/bzr-builddeb/merge-upstream-merge-mode into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 500
Proposed branch: lp:~jelmer/bzr-builddeb/merge-upstream-merge-mode
Merge into: lp:bzr-builddeb
Prerequisite: lp:~jelmer/bzr-builddeb/295274-merge-upstream-no-version
Diff against target: 232 lines (+74/-57)
6 files modified
cmds.py (+27/-18)
config.py (+1/-1)
debian/changelog (+3/-1)
tests/test_source_distiller.py (+1/-1)
tests/test_upstream.py (+41/-0)
upstream.py (+1/-36)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/merge-upstream-merge-mode
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+47218@code.launchpad.net

Description of the change

This makes it possible for 'bzr merge-upstream' to work in merge mode branches.

Instead of merging in the upstream branch we Do The Right Thing and only update the changelog with the new upstream version.

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-01-24 06:28:00 +0000
3+++ cmds.py 2011-01-24 06:28:00 +0000
4@@ -637,13 +637,6 @@
5 "working tree. You must commit before using this "
6 "command.")
7 config = debuild_config(tree, tree)
8- if config.build_type == BUILD_TYPE_MERGE:
9- raise BzrCommandError("Merge upstream in merge mode is not "
10- "yet supported.")
11- if config.build_type == BUILD_TYPE_NATIVE:
12- raise BzrCommandError("Merge upstream in native mode is not "
13- "yet supported.")
14-
15 primary_upstream_source = None
16
17 if upstream_branch is None:
18@@ -665,6 +658,15 @@
19 (current_version, package, distribution, distribution_name,
20 changelog, larstiq) = self._get_changelog_info(tree, last_version,
21 package, distribution)
22+ contains_upstream_source = tree_contains_upstream_source(tree)
23+ build_type = config.build_type
24+ if build_type is None:
25+ build_type = guess_build_type(tree, changelog.version,
26+ contains_upstream_source)
27+ need_upstream_tarball = (build_type != BUILD_TYPE_MERGE)
28+ if build_type == BUILD_TYPE_NATIVE:
29+ raise BzrCommandError("Merge upstream in native mode is not "
30+ "supported.")
31
32 if location is not None:
33 try:
34@@ -705,7 +707,9 @@
35 version = primary_upstream_source.get_latest_version(
36 package, current_version)
37 target_dir = tempfile.mkdtemp() # FIXME: Cleanup?
38- location = primary_upstream_source.fetch_tarball(package, version, target_dir)
39+ if need_upstream_tarball:
40+ location = primary_upstream_source.fetch_tarball(
41+ package, version, target_dir)
42 note("Using version string %s." % (version))
43 # Look up the revision id from the version string
44 if upstream_branch_source is not None:
45@@ -713,21 +717,26 @@
46 package, version)
47 if version is None:
48 raise BzrCommandError("You must specify the version number using --version.")
49- tarball_filename = self._get_tarball(config, tree, package,
50- version, upstream_branch, upstream_revision, v3,
51- location)
52- conflicts = self._do_merge(tree, tarball_filename, version,
53- current_version, upstream_branch, upstream_revision,
54- merge_type, force)
55+ if need_upstream_tarball:
56+ tarball_filename = self._get_tarball(config, tree, package,
57+ version, upstream_branch, upstream_revision, v3,
58+ location)
59+ conflicts = self._do_merge(tree, tarball_filename, version,
60+ current_version, upstream_branch, upstream_revision,
61+ merge_type, force)
62 self._add_changelog_entry(tree, package, version,
63 distribution_name, changelog)
64 finally:
65 tree.unlock()
66- note("The new upstream version has been imported.")
67- if conflicts:
68- note("You should now resolve the conflicts, review the changes, and then commit.")
69+ if not need_upstream_tarball:
70+ note("An entry for the new upstream version has been added "
71+ "to the changelog.")
72 else:
73- note("You should now review the changes and then commit.")
74+ note("The new upstream version has been imported.")
75+ if conflicts:
76+ note("You should now resolve the conflicts, review the changes, and then commit.")
77+ else:
78+ note("You should now review the changes and then commit.")
79
80
81 class cmd_import_dsc(Command):
82
83=== modified file 'config.py'
84--- config.py 2011-01-12 21:31:25 +0000
85+++ config.py 2011-01-24 06:28:00 +0000
86@@ -272,7 +272,7 @@
87 elif self.split:
88 return BUILD_TYPE_SPLIT
89 else:
90- return BUILD_TYPE_NORMAL
91+ return None
92
93 quick_builder = _opt_property('quick-builder',
94 "A quick command to build with", True)
95
96=== modified file 'debian/changelog'
97--- debian/changelog 2011-01-24 06:28:00 +0000
98+++ debian/changelog 2011-01-24 06:28:00 +0000
99@@ -30,8 +30,10 @@
100 * If possible use uscan to find the latest upstream version string.
101 LP: #295274
102 * Add --snapshot option to merge-upstream.
103+ * 'bzr merge-upstream' now also works in merge mode, and will simply
104+ add a new entry for new upstream versions.
105
106- -- Jelmer Vernooij <jelmer@debian.org> Sun, 23 Jan 2011 21:35:21 -0800
107+ -- Jelmer Vernooij <jelmer@debian.org> Sun, 23 Jan 2011 21:57:08 -0800
108
109 bzr-builddeb (2.5) unstable; urgency=low
110
111
112=== modified file 'tests/test_source_distiller.py'
113--- tests/test_source_distiller.py 2010-05-23 15:29:38 +0000
114+++ tests/test_source_distiller.py 2011-01-24 06:28:00 +0000
115@@ -37,7 +37,7 @@
116 NativeSourceDistiller,
117 )
118 from bzrlib.plugins.builddeb.tests import SourcePackageBuilder
119-from bzrlib.plugins.builddeb.upstream import (
120+from bzrlib.plugins.builddeb.tests.test_upstream import (
121 _MissingUpstreamProvider,
122 _SimpleUpstreamProvider,
123 _TouchUpstreamProvider,
124
125=== modified file 'tests/test_upstream.py'
126--- tests/test_upstream.py 2011-01-24 06:28:00 +0000
127+++ tests/test_upstream.py 2011-01-24 06:28:00 +0000
128@@ -33,6 +33,7 @@
129 DebBuildConfig,
130 )
131 from bzrlib.plugins.builddeb.errors import (
132+ MissingUpstreamTarball,
133 PackageVersionNotPresent,
134 WatchFileMissing,
135 )
136@@ -40,7 +41,9 @@
137 AptSource,
138 StackedUpstreamSource,
139 UpstreamBranchSource,
140+ UpstreamProvider,
141 UScanSource,
142+ Version,
143 )
144
145
146@@ -323,3 +326,41 @@
147 self.assertEquals(revid2,
148 source.version_as_revision("foo", "2.1+bzr2"))
149 self.assertEquals(revid1, source.version_as_revision("foo", "2.1"))
150+
151+
152+class _MissingUpstreamProvider(UpstreamProvider):
153+ """For tests"""
154+
155+ def __init__(self):
156+ pass
157+
158+ def provide(self, target_dir):
159+ raise MissingUpstreamTarball("test_tarball")
160+
161+
162+class _TouchUpstreamProvider(UpstreamProvider):
163+ """For tests"""
164+
165+ def __init__(self, desired_tarball_name):
166+ self.desired_tarball_name = desired_tarball_name
167+
168+ def provide(self, target_dir):
169+ f = open(os.path.join(target_dir, self.desired_tarball_name), "wb")
170+ f.write("I am a tarball, honest\n")
171+ f.close()
172+
173+
174+class _SimpleUpstreamProvider(UpstreamProvider):
175+ """For tests"""
176+
177+ def __init__(self, package, version, store_dir):
178+ self.package = package
179+ self.version = Version(version)
180+ self.store_dir = store_dir
181+
182+ def provide(self, target_dir):
183+ path = (self.already_exists_in_target(target_dir)
184+ or self.provide_from_store_dir(target_dir))
185+ if path is not None:
186+ return path
187+ raise MissingUpstreamTarball(self._tarball_names()[0])
188
189=== modified file 'upstream.py'
190--- upstream.py 2011-01-24 06:28:00 +0000
191+++ upstream.py 2011-01-24 06:28:00 +0000
192@@ -507,39 +507,4 @@
193 tarball_name(self.package, self.version.upstream_version, format='lzma')]
194
195
196-class _MissingUpstreamProvider(UpstreamProvider):
197- """For tests"""
198-
199- def __init__(self):
200- pass
201-
202- def provide(self, target_dir):
203- raise MissingUpstreamTarball("test_tarball")
204-
205-
206-class _TouchUpstreamProvider(UpstreamProvider):
207- """For tests"""
208-
209- def __init__(self, desired_tarball_name):
210- self.desired_tarball_name = desired_tarball_name
211-
212- def provide(self, target_dir):
213- f = open(os.path.join(target_dir, self.desired_tarball_name), "wb")
214- f.write("I am a tarball, honest\n")
215- f.close()
216-
217-
218-class _SimpleUpstreamProvider(UpstreamProvider):
219- """For tests"""
220-
221- def __init__(self, package, version, store_dir):
222- self.package = package
223- self.version = Version(version)
224- self.store_dir = store_dir
225-
226- def provide(self, target_dir):
227- path = (self.already_exists_in_target(target_dir)
228- or self.provide_from_store_dir(target_dir))
229- if path is not None:
230- return path
231- raise MissingUpstreamTarball(self._tarball_names()[0])
232+

Subscribers

People subscribed via source and target branches