Merge lp:~jelmer/bzr-builddeb/auto-apply-quilt into lp:bzr-builddeb
- auto-apply-quilt
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Superseded |
---|---|
Proposed branch: | lp:~jelmer/bzr-builddeb/auto-apply-quilt |
Merge into: | lp:bzr-builddeb |
Prerequisite: | lp:~jelmer/bzr-builddeb/fix-bd-do-build-type-guessing |
Diff against target: |
472 lines (+299/-16) 9 files modified
builder.py (+19/-4) cmds.py (+2/-2) debian/changelog (+3/-1) merge_quilt.py (+24/-0) quilt.py (+151/-0) tests/__init__.py (+3/-0) tests/test_quilt.py (+87/-0) tests/test_util.py (+5/-5) util.py (+5/-4) |
To merge this branch: | bzr merge lp:~jelmer/bzr-builddeb/auto-apply-quilt |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby | Approve | ||
Review via email:
|
This proposal supersedes a proposal from 2012-01-02.
This proposal has been superseded by a proposal from 2012-01-05.
Commit message
Description of the change
Automatically apply patches for 3.0 (quilt) packages in 'bzr bd' or 'bzr bd-do'.
To post a comment you must log in.
- 685. By Jelmer Vernooij
-
Fix changelog.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'builder.py' | |||
2 | --- builder.py 2009-12-01 17:14:15 +0000 | |||
3 | +++ builder.py 2012-01-02 22:09:25 +0000 | |||
4 | @@ -28,10 +28,13 @@ | |||
5 | 28 | NoSourceDirError, | 28 | NoSourceDirError, |
6 | 29 | BuildFailedError, | 29 | BuildFailedError, |
7 | 30 | ) | 30 | ) |
8 | 31 | from bzrlib.plugins.builddeb.quilt import quilt_push_all | ||
9 | 31 | from bzrlib.plugins.builddeb.util import ( | 32 | from bzrlib.plugins.builddeb.util import ( |
13 | 32 | get_parent_dir, | 33 | get_parent_dir, |
14 | 33 | subprocess_setup, | 34 | tree_get_source_format, |
15 | 34 | ) | 35 | subprocess_setup, |
16 | 36 | FORMAT_3_0_QUILT, | ||
17 | 37 | ) | ||
18 | 35 | 38 | ||
19 | 36 | 39 | ||
20 | 37 | class DebBuild(object): | 40 | class DebBuild(object): |
21 | @@ -71,8 +74,20 @@ | |||
22 | 71 | if self.use_existing: | 74 | if self.use_existing: |
23 | 72 | raise NoSourceDirError | 75 | raise NoSourceDirError |
24 | 73 | 76 | ||
26 | 74 | def export(self): | 77 | def export(self, apply_quilt_patches=True): |
27 | 75 | self.distiller.distill(self.target_dir) | 78 | self.distiller.distill(self.target_dir) |
28 | 79 | if apply_quilt_patches: | ||
29 | 80 | self._apply_quilt_patches() | ||
30 | 81 | |||
31 | 82 | def _apply_quilt_patches(self): | ||
32 | 83 | if not os.path.isfile(os.path.join(self.target_dir, "debian/patches/series")): | ||
33 | 84 | return | ||
34 | 85 | format_path = os.path.join(self.target_dir, "debian/source/format") | ||
35 | 86 | if not os.path.isfile(format_path): | ||
36 | 87 | return | ||
37 | 88 | with file(format_path, 'r') as f: | ||
38 | 89 | if f.read().strip() == FORMAT_3_0_QUILT: | ||
39 | 90 | quilt_push_all(os.path.abspath(self.target_dir)) | ||
40 | 76 | 91 | ||
41 | 77 | def build(self): | 92 | def build(self): |
42 | 78 | """This builds the package using the supplied command.""" | 93 | """This builds the package using the supplied command.""" |
43 | 79 | 94 | ||
44 | === modified file 'cmds.py' | |||
45 | --- cmds.py 2012-01-02 22:09:25 +0000 | |||
46 | +++ cmds.py 2012-01-02 22:09:25 +0000 | |||
47 | @@ -697,7 +697,7 @@ | |||
48 | 697 | from bzrlib.plugins.builddeb.util import ( | 697 | from bzrlib.plugins.builddeb.util import ( |
49 | 698 | FORMAT_3_0_QUILT, | 698 | FORMAT_3_0_QUILT, |
50 | 699 | FORMAT_3_0_NATIVE, | 699 | FORMAT_3_0_NATIVE, |
52 | 700 | get_source_format, | 700 | tree_get_source_format, |
53 | 701 | guess_build_type, | 701 | guess_build_type, |
54 | 702 | tree_contains_upstream_source, | 702 | tree_contains_upstream_source, |
55 | 703 | ) | 703 | ) |
56 | @@ -824,7 +824,7 @@ | |||
57 | 824 | revisions=upstream_revisions) | 824 | revisions=upstream_revisions) |
58 | 825 | else: | 825 | else: |
59 | 826 | raise | 826 | raise |
61 | 827 | source_format = get_source_format(tree) | 827 | source_format = tree_get_source_format(tree) |
62 | 828 | v3 = (source_format in [ | 828 | v3 = (source_format in [ |
63 | 829 | FORMAT_3_0_QUILT, FORMAT_3_0_NATIVE]) | 829 | FORMAT_3_0_QUILT, FORMAT_3_0_NATIVE]) |
64 | 830 | tarball_filenames = self._get_tarballs(config, tree, package, | 830 | tarball_filenames = self._get_tarballs(config, tree, package, |
65 | 831 | 831 | ||
66 | === modified file 'debian/changelog' | |||
67 | --- debian/changelog 2012-01-02 18:01:36 +0000 | |||
68 | +++ debian/changelog 2012-01-02 22:09:25 +0000 | |||
69 | @@ -5,8 +5,10 @@ | |||
70 | 5 | commands like 'bzr bash-completion'. LP: #903650 | 5 | commands like 'bzr bash-completion'. LP: #903650 |
71 | 6 | * Provide merge-package functionality as a hook for 'bzr merge'. | 6 | * Provide merge-package functionality as a hook for 'bzr merge'. |
72 | 7 | LP: #486075, LP: #910900 | 7 | LP: #486075, LP: #910900 |
73 | 8 | * Automatically apply patches for 3.0 (quilt) packages in 'bzr bd-do' | ||
74 | 9 | and 'bzr bd'. LP: #616791 | ||
75 | 8 | 10 | ||
77 | 9 | -- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Jan 2012 17:57:33 +0100 | 11 | -- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Jan 2012 23:02:44 +0100 |
78 | 10 | 12 | ||
79 | 11 | bzr-builddeb (2.8.0) unstable; urgency=low | 13 | bzr-builddeb (2.8.0) unstable; urgency=low |
80 | 12 | 14 | ||
81 | 13 | 15 | ||
82 | === modified file 'merge_quilt.py' | |||
83 | --- merge_quilt.py 2011-12-20 14:44:17 +0000 | |||
84 | +++ merge_quilt.py 2012-01-02 22:09:25 +0000 | |||
85 | @@ -21,3 +21,27 @@ | |||
86 | 21 | """Quilt patch handling.""" | 21 | """Quilt patch handling.""" |
87 | 22 | 22 | ||
88 | 23 | from __future__ import absolute_import | 23 | from __future__ import absolute_import |
89 | 24 | import tempfile | ||
90 | 25 | |||
91 | 26 | from bzrlib import trace | ||
92 | 27 | from bzrlib.plugins.builddeb.quilt import quilt_pop_all | ||
93 | 28 | |||
94 | 29 | |||
95 | 30 | def tree_unapply_patches(orig_tree): | ||
96 | 31 | """Return a tree with patches unapplied. | ||
97 | 32 | |||
98 | 33 | :param tree: Tree from which to unapply quilt patches | ||
99 | 34 | :return: Tuple with tree and temp path. | ||
100 | 35 | The tree is a tree with unapplied patches; either a checkout of | ||
101 | 36 | tree or tree itself if there were no patches | ||
102 | 37 | """ | ||
103 | 38 | series_file_id = orig_tree.path2id("debian/patches/series") | ||
104 | 39 | if series_file_id is None: | ||
105 | 40 | # No quilt patches | ||
106 | 41 | return orig_tree, None | ||
107 | 42 | |||
108 | 43 | target_dir = tempfile.mkdtemp() | ||
109 | 44 | tree = orig_tree.branch.create_checkout(target_dir, lightweight=True) | ||
110 | 45 | trace.warning("Applying quilt patches for %r in %s", orig_tree, target_dir) | ||
111 | 46 | quilt_pop_all(working_dir=tree.basedir) | ||
112 | 47 | return tree, target_dir | ||
113 | 24 | 48 | ||
114 | === added file 'quilt.py' | |||
115 | --- quilt.py 1970-01-01 00:00:00 +0000 | |||
116 | +++ quilt.py 2012-01-02 22:09:25 +0000 | |||
117 | @@ -0,0 +1,151 @@ | |||
118 | 1 | # quilt.py -- Quilt patch handling | ||
119 | 2 | # Copyright (C) 2011 Canonical Ltd. | ||
120 | 3 | # | ||
121 | 4 | # This file is part of bzr-builddeb. | ||
122 | 5 | # | ||
123 | 6 | # bzr-builddeb is free software; you can redistribute it and/or modify | ||
124 | 7 | # it under the terms of the GNU General Public License as published by | ||
125 | 8 | # the Free Software Foundation; either version 2 of the License, or | ||
126 | 9 | # (at your option) any later version. | ||
127 | 10 | # | ||
128 | 11 | # bzr-builddeb is distributed in the hope that it will be useful, | ||
129 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
130 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
131 | 14 | # GNU General Public License for more details. | ||
132 | 15 | # | ||
133 | 16 | # You should have received a copy of the GNU General Public License | ||
134 | 17 | # along with bzr-builddeb; if not, write to the Free Software | ||
135 | 18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
136 | 19 | # | ||
137 | 20 | |||
138 | 21 | """Quilt patch handling.""" | ||
139 | 22 | |||
140 | 23 | from __future__ import absolute_import | ||
141 | 24 | |||
142 | 25 | import errno | ||
143 | 26 | import os | ||
144 | 27 | import signal | ||
145 | 28 | import subprocess | ||
146 | 29 | from bzrlib import ( | ||
147 | 30 | errors, | ||
148 | 31 | trace, | ||
149 | 32 | ) | ||
150 | 33 | |||
151 | 34 | |||
152 | 35 | class QuiltError(errors.BzrError): | ||
153 | 36 | |||
154 | 37 | _fmt = "An error (%(retcode)d) occurred running quilt: %(msg)s" | ||
155 | 38 | |||
156 | 39 | def __init__(self, retcode, msg): | ||
157 | 40 | self.retcode = retcode | ||
158 | 41 | self.msg = msg | ||
159 | 42 | |||
160 | 43 | |||
161 | 44 | def run_quilt(args, working_dir, series_file=None, patches_dir=None, quiet=None): | ||
162 | 45 | """Run quilt. | ||
163 | 46 | |||
164 | 47 | :param args: Arguments to quilt | ||
165 | 48 | :param working_dir: Working dir | ||
166 | 49 | :param series_file: Optional path to the series file | ||
167 | 50 | :param patches_dir: Optional path to the patches | ||
168 | 51 | :param quilt: Whether to be quiet (quilt stderr not to terminal) | ||
169 | 52 | :raise QuiltError: When running quilt fails | ||
170 | 53 | """ | ||
171 | 54 | def subprocess_setup(): | ||
172 | 55 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) | ||
173 | 56 | env = {} | ||
174 | 57 | if patches_dir is not None: | ||
175 | 58 | env["QUILT_PATCHES"] = patches_dir | ||
176 | 59 | else: | ||
177 | 60 | env["QUILT_PATCHES"] = os.path.join(working_dir, "debian", "patches") | ||
178 | 61 | if series_file is not None: | ||
179 | 62 | env["QUILT_SERIES"] = series_file | ||
180 | 63 | else: | ||
181 | 64 | env["QUILT_SERIES"] = os.path.join(env["QUILT_PATCHES"], "series") | ||
182 | 65 | # Hide output if -q is in use. | ||
183 | 66 | if quiet is None: | ||
184 | 67 | quiet = trace.is_quiet() | ||
185 | 68 | if quiet: | ||
186 | 69 | stderr = subprocess.STDOUT | ||
187 | 70 | else: | ||
188 | 71 | stderr = subprocess.PIPE | ||
189 | 72 | command = ["quilt"] + args | ||
190 | 73 | trace.mutter("running: %r", command) | ||
191 | 74 | if not os.path.isdir(working_dir): | ||
192 | 75 | raise AssertionError("%s is not a valid directory" % working_dir) | ||
193 | 76 | try: | ||
194 | 77 | proc = subprocess.Popen(command, cwd=working_dir, env=env, | ||
195 | 78 | stdin=subprocess.PIPE, preexec_fn=subprocess_setup, | ||
196 | 79 | stdout=subprocess.PIPE, stderr=stderr) | ||
197 | 80 | except OSError, e: | ||
198 | 81 | if e.errno != errno.ENOENT: | ||
199 | 82 | raise | ||
200 | 83 | raise errors.BzrError("quilt is not installed, please install it") | ||
201 | 84 | output = proc.communicate() | ||
202 | 85 | if proc.returncode not in (0, 2): | ||
203 | 86 | raise QuiltError(proc.returncode, output[1]) | ||
204 | 87 | if output[0] is None: | ||
205 | 88 | return "" | ||
206 | 89 | return output[0] | ||
207 | 90 | |||
208 | 91 | |||
209 | 92 | def quilt_pop_all(working_dir, patches_dir=None, series_file=None, quiet=None): | ||
210 | 93 | """Pop all patches. | ||
211 | 94 | |||
212 | 95 | :param working_dir: Directory to work in | ||
213 | 96 | :param patches_dir: Optional patches directory | ||
214 | 97 | :param series_file: Optional series file | ||
215 | 98 | """ | ||
216 | 99 | return run_quilt(["pop", "-a", "-v"], working_dir=working_dir, patches_dir=patches_dir, series_file=series_file, quiet=quiet) | ||
217 | 100 | |||
218 | 101 | |||
219 | 102 | def quilt_push_all(working_dir, patches_dir=None, series_file=None, quiet=None): | ||
220 | 103 | """Push all patches. | ||
221 | 104 | |||
222 | 105 | :param working_dir: Directory to work in | ||
223 | 106 | :param patches_dir: Optional patches directory | ||
224 | 107 | :param series_file: Optional series file | ||
225 | 108 | """ | ||
226 | 109 | return run_quilt(["push", "-a", "-v"], working_dir=working_dir, patches_dir=patches_dir, series_file=series_file, quiet=quiet) | ||
227 | 110 | |||
228 | 111 | |||
229 | 112 | def quilt_applied(working_dir, patches_dir=None, series_file=None): | ||
230 | 113 | """Find the list of applied quilt patches. | ||
231 | 114 | |||
232 | 115 | :param working_dir: Directory to work in | ||
233 | 116 | :param patches_dir: Optional patches directory | ||
234 | 117 | :param series_file: Optional series file | ||
235 | 118 | """ | ||
236 | 119 | try: | ||
237 | 120 | return run_quilt(["applied"], working_dir=working_dir, patches_dir=patches_dir, series_file=series_file).splitlines() | ||
238 | 121 | except QuiltError, e: | ||
239 | 122 | if e.retcode == 1: | ||
240 | 123 | return [] | ||
241 | 124 | raise | ||
242 | 125 | |||
243 | 126 | |||
244 | 127 | def quilt_unapplied(working_dir, patches_dir=None, series_file=None): | ||
245 | 128 | """Find the list of unapplied quilt patches. | ||
246 | 129 | |||
247 | 130 | :param working_dir: Directory to work in | ||
248 | 131 | :param patches_dir: Optional patches directory | ||
249 | 132 | :param series_file: Optional series file | ||
250 | 133 | """ | ||
251 | 134 | try: | ||
252 | 135 | return run_quilt(["unapplied"], working_dir=working_dir, | ||
253 | 136 | patches_dir=patches_dir, series_file=series_file).splitlines() | ||
254 | 137 | except QuiltError, e: | ||
255 | 138 | if e.retcode == 1: | ||
256 | 139 | return [] | ||
257 | 140 | raise | ||
258 | 141 | |||
259 | 142 | |||
260 | 143 | def quilt_series(working_dir, patches_dir=None, series_file=None): | ||
261 | 144 | """Find the list of patches. | ||
262 | 145 | |||
263 | 146 | :param working_dir: Directory to work in | ||
264 | 147 | :param patches_dir: Optional patches directory | ||
265 | 148 | :param series_file: Optional series file | ||
266 | 149 | """ | ||
267 | 150 | return run_quilt(["series"], working_dir=working_dir, patches_dir=patches_dir, series_file=series_file).splitlines() | ||
268 | 151 | |||
269 | 0 | 152 | ||
270 | === modified file 'tests/__init__.py' | |||
271 | --- tests/__init__.py 2011-12-20 14:44:17 +0000 | |||
272 | +++ tests/__init__.py 2012-01-02 22:09:25 +0000 | |||
273 | @@ -37,11 +37,13 @@ | |||
274 | 37 | from bzrlib.tests import TestUtil, multiply_tests | 37 | from bzrlib.tests import TestUtil, multiply_tests |
275 | 38 | try: | 38 | try: |
276 | 39 | from bzrlib.tests.features import ( | 39 | from bzrlib.tests.features import ( |
277 | 40 | ExecutableFeature, | ||
278 | 40 | ModuleAvailableFeature, | 41 | ModuleAvailableFeature, |
279 | 41 | UnicodeFilenameFeature, | 42 | UnicodeFilenameFeature, |
280 | 42 | ) | 43 | ) |
281 | 43 | except ImportError: # bzr < 2.5 | 44 | except ImportError: # bzr < 2.5 |
282 | 44 | from bzrlib.tests import ( | 45 | from bzrlib.tests import ( |
283 | 46 | ExecutableFeature, | ||
284 | 45 | ModuleAvailableFeature, | 47 | ModuleAvailableFeature, |
285 | 46 | UnicodeFilenameFeature, | 48 | UnicodeFilenameFeature, |
286 | 47 | ) | 49 | ) |
287 | @@ -135,6 +137,7 @@ | |||
288 | 135 | 'test_merge_package', | 137 | 'test_merge_package', |
289 | 136 | 'test_merge_quilt', | 138 | 'test_merge_quilt', |
290 | 137 | 'test_merge_upstream', | 139 | 'test_merge_upstream', |
291 | 140 | 'test_quilt', | ||
292 | 138 | 'test_repack_tarball_extra', | 141 | 'test_repack_tarball_extra', |
293 | 139 | 'test_revspec', | 142 | 'test_revspec', |
294 | 140 | 'test_source_distiller', | 143 | 'test_source_distiller', |
295 | 141 | 144 | ||
296 | === added file 'tests/test_quilt.py' | |||
297 | --- tests/test_quilt.py 1970-01-01 00:00:00 +0000 | |||
298 | +++ tests/test_quilt.py 2012-01-02 22:09:25 +0000 | |||
299 | @@ -0,0 +1,87 @@ | |||
300 | 1 | # Copyright (C) 2011 Canonical Ltd | ||
301 | 2 | # | ||
302 | 3 | # This file is part of bzr-builddeb. | ||
303 | 4 | # | ||
304 | 5 | # bzr-builddeb is free software; you can redistribute it and/or modify | ||
305 | 6 | # it under the terms of the GNU General Public License as published by | ||
306 | 7 | # the Free Software Foundation; either version 2 of the License, or | ||
307 | 8 | # (at your option) any later version. | ||
308 | 9 | # | ||
309 | 10 | # bzr-builddeb is distributed in the hope that it will be useful, | ||
310 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
311 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
312 | 13 | # GNU General Public License for more details. | ||
313 | 14 | # | ||
314 | 15 | # You should have received a copy of the GNU General Public License | ||
315 | 16 | # along with bzr-builddeb; if not, write to the Free Software | ||
316 | 17 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
317 | 18 | # | ||
318 | 19 | |||
319 | 20 | """Tests for the quilt code.""" | ||
320 | 21 | |||
321 | 22 | import os | ||
322 | 23 | |||
323 | 24 | from bzrlib.plugins.builddeb.tests import ExecutableFeature | ||
324 | 25 | from bzrlib.plugins.builddeb.quilt import ( | ||
325 | 26 | quilt_pop_all, | ||
326 | 27 | quilt_applied, | ||
327 | 28 | quilt_unapplied, | ||
328 | 29 | quilt_push_all, | ||
329 | 30 | quilt_series, | ||
330 | 31 | ) | ||
331 | 32 | |||
332 | 33 | from bzrlib.tests import TestCaseWithTransport | ||
333 | 34 | |||
334 | 35 | quilt_feature = ExecutableFeature('quilt') | ||
335 | 36 | |||
336 | 37 | TRIVIAL_PATCH = """--- /dev/null 2012-01-02 01:09:10.986490031 +0100 | ||
337 | 38 | +++ a 2012-01-02 20:03:59.710666215 +0100 | ||
338 | 39 | @@ -0,0 +1 @@ | ||
339 | 40 | +a | ||
340 | 41 | """ | ||
341 | 42 | |||
342 | 43 | class QuiltTests(TestCaseWithTransport): | ||
343 | 44 | |||
344 | 45 | _test_needs_features = [quilt_feature] | ||
345 | 46 | |||
346 | 47 | def make_empty_quilt_dir(self, path): | ||
347 | 48 | source = self.make_branch_and_tree(path) | ||
348 | 49 | self.build_tree([os.path.join(path, n) for n in ['debian/', | ||
349 | 50 | 'debian/patches/']]) | ||
350 | 51 | self.build_tree_contents([ | ||
351 | 52 | (os.path.join(path, "debian/patches/series"), "\n")]) | ||
352 | 53 | source.add(["debian", "debian/patches", "debian/patches/series"]) | ||
353 | 54 | return source | ||
354 | 55 | |||
355 | 56 | def test_series_all_empty(self): | ||
356 | 57 | self.make_empty_quilt_dir("source") | ||
357 | 58 | self.assertEquals([], quilt_series("source")) | ||
358 | 59 | |||
359 | 60 | def test_series_all(self): | ||
360 | 61 | self.make_empty_quilt_dir("source") | ||
361 | 62 | self.build_tree_contents([ | ||
362 | 63 | ("source/debian/patches/series", "patch1.diff\n"), | ||
363 | 64 | ("source/debian/patches/patch1.diff", TRIVIAL_PATCH)]) | ||
364 | 65 | self.assertEquals(["patch1.diff"], quilt_series("source")) | ||
365 | 66 | |||
366 | 67 | def test_push_all_empty(self): | ||
367 | 68 | self.make_empty_quilt_dir("source") | ||
368 | 69 | quilt_push_all("source", quiet=True) | ||
369 | 70 | |||
370 | 71 | def test_poph_all_empty(self): | ||
371 | 72 | self.make_empty_quilt_dir("source") | ||
372 | 73 | quilt_pop_all("source", quiet=True) | ||
373 | 74 | |||
374 | 75 | def test_applied_empty(self): | ||
375 | 76 | self.make_empty_quilt_dir("source") | ||
376 | 77 | self.build_tree_contents([ | ||
377 | 78 | ("source/debian/patches/series", "patch1.diff\n"), | ||
378 | 79 | ("source/debian/patches/patch1.diff", "foob ar")]) | ||
379 | 80 | self.assertEquals([], quilt_applied("source")) | ||
380 | 81 | |||
381 | 82 | def test_unapplied(self): | ||
382 | 83 | self.make_empty_quilt_dir("source") | ||
383 | 84 | self.build_tree_contents([ | ||
384 | 85 | ("source/debian/patches/series", "patch1.diff\n"), | ||
385 | 86 | ("source/debian/patches/patch1.diff", "foob ar")]) | ||
386 | 87 | self.assertEquals(["patch1.diff"], quilt_unapplied("source")) | ||
387 | 0 | 88 | ||
388 | === modified file 'tests/test_util.py' | |||
389 | --- tests/test_util.py 2011-09-09 13:20:42 +0000 | |||
390 | +++ tests/test_util.py 2012-01-02 22:09:25 +0000 | |||
391 | @@ -63,7 +63,6 @@ | |||
392 | 63 | _find_previous_upload, | 63 | _find_previous_upload, |
393 | 64 | find_thanks, | 64 | find_thanks, |
394 | 65 | get_commit_info_from_changelog, | 65 | get_commit_info_from_changelog, |
395 | 66 | get_source_format, | ||
396 | 67 | guess_build_type, | 66 | guess_build_type, |
397 | 68 | lookup_distribution, | 67 | lookup_distribution, |
398 | 69 | move_file_if_different, | 68 | move_file_if_different, |
399 | @@ -74,6 +73,7 @@ | |||
400 | 74 | suite_to_distribution, | 73 | suite_to_distribution, |
401 | 75 | tarball_name, | 74 | tarball_name, |
402 | 76 | tree_contains_upstream_source, | 75 | tree_contains_upstream_source, |
403 | 76 | tree_get_source_format, | ||
404 | 77 | write_if_different, | 77 | write_if_different, |
405 | 78 | ) | 78 | ) |
406 | 79 | 79 | ||
407 | @@ -773,27 +773,27 @@ | |||
408 | 773 | 773 | ||
409 | 774 | def test_no_source_format_file(self): | 774 | def test_no_source_format_file(self): |
410 | 775 | tree = self.make_branch_and_tree('.') | 775 | tree = self.make_branch_and_tree('.') |
412 | 776 | self.assertEquals("1.0", get_source_format(tree)) | 776 | self.assertEquals("1.0", tree_get_source_format(tree)) |
413 | 777 | 777 | ||
414 | 778 | def test_source_format_newline(self): | 778 | def test_source_format_newline(self): |
415 | 779 | tree = self.make_branch_and_tree('.') | 779 | tree = self.make_branch_and_tree('.') |
416 | 780 | self.build_tree_contents([("debian/", ), ("debian/source/",), | 780 | self.build_tree_contents([("debian/", ), ("debian/source/",), |
417 | 781 | ("debian/source/format", "3.0 (native)\n")]) | 781 | ("debian/source/format", "3.0 (native)\n")]) |
418 | 782 | tree.add(["debian", "debian/source", "debian/source/format"]) | 782 | tree.add(["debian", "debian/source", "debian/source/format"]) |
420 | 783 | self.assertEquals("3.0 (native)", get_source_format(tree)) | 783 | self.assertEquals("3.0 (native)", tree_get_source_format(tree)) |
421 | 784 | 784 | ||
422 | 785 | def test_source_format(self): | 785 | def test_source_format(self): |
423 | 786 | tree = self.make_branch_and_tree('.') | 786 | tree = self.make_branch_and_tree('.') |
424 | 787 | self.build_tree_contents([("debian/",), ("debian/source/",), | 787 | self.build_tree_contents([("debian/",), ("debian/source/",), |
425 | 788 | ("debian/source/format", "3.0 (quilt)")]) | 788 | ("debian/source/format", "3.0 (quilt)")]) |
426 | 789 | tree.add(["debian", "debian/source", "debian/source/format"]) | 789 | tree.add(["debian", "debian/source", "debian/source/format"]) |
428 | 790 | self.assertEquals("3.0 (quilt)", get_source_format(tree)) | 790 | self.assertEquals("3.0 (quilt)", tree_get_source_format(tree)) |
429 | 791 | 791 | ||
430 | 792 | def test_source_format_file_unversioned(self): | 792 | def test_source_format_file_unversioned(self): |
431 | 793 | tree = self.make_branch_and_tree('.') | 793 | tree = self.make_branch_and_tree('.') |
432 | 794 | self.build_tree_contents([("debian/",), ("debian/source/",), | 794 | self.build_tree_contents([("debian/",), ("debian/source/",), |
433 | 795 | ("debian/source/format", "3.0 (quilt)")]) | 795 | ("debian/source/format", "3.0 (quilt)")]) |
435 | 796 | self.assertEquals("3.0 (quilt)", get_source_format(tree)) | 796 | self.assertEquals("3.0 (quilt)", tree_get_source_format(tree)) |
436 | 797 | 797 | ||
437 | 798 | 798 | ||
438 | 799 | class GuessBuildTypeTests(TestCaseWithTransport): | 799 | class GuessBuildTypeTests(TestCaseWithTransport): |
439 | 800 | 800 | ||
440 | === modified file 'util.py' | |||
441 | --- util.py 2011-10-28 16:32:42 +0000 | |||
442 | +++ util.py 2012-01-02 22:09:25 +0000 | |||
443 | @@ -648,16 +648,17 @@ | |||
444 | 648 | return (len(present_files - packaging_files) > 0) | 648 | return (len(present_files - packaging_files) > 0) |
445 | 649 | 649 | ||
446 | 650 | 650 | ||
448 | 651 | def get_source_format(tree): | 651 | def tree_get_source_format(tree): |
449 | 652 | """Retrieve the source format name from a package. | 652 | """Retrieve the source format name from a package. |
450 | 653 | 653 | ||
451 | 654 | :param path: Path to the package | 654 | :param path: Path to the package |
452 | 655 | :return: String with package format | 655 | :return: String with package format |
453 | 656 | """ | 656 | """ |
454 | 657 | filename = "debian/source/format" | 657 | filename = "debian/source/format" |
456 | 658 | if not tree.has_filename(filename): | 658 | file_id = tree.path2id(filename) |
457 | 659 | if file_id is None: | ||
458 | 659 | return FORMAT_1_0 | 660 | return FORMAT_1_0 |
460 | 660 | text = tree.get_file_text(tree.path2id(filename), filename) | 661 | text = tree.get_file_text(file_id, filename) |
461 | 661 | return text.strip() | 662 | return text.strip() |
462 | 662 | 663 | ||
463 | 663 | 664 | ||
464 | @@ -677,7 +678,7 @@ | |||
465 | 677 | :param contains_upstream_source: Whether this branch contains the upstream source. | 678 | :param contains_upstream_source: Whether this branch contains the upstream source. |
466 | 678 | :return: A build_type value. | 679 | :return: A build_type value. |
467 | 679 | """ | 680 | """ |
469 | 680 | source_format = get_source_format(tree) | 681 | source_format = tree_get_source_format(tree) |
470 | 681 | if source_format in NATIVE_SOURCE_FORMATS: | 682 | if source_format in NATIVE_SOURCE_FORMATS: |
471 | 682 | format_native = True | 683 | format_native = True |
472 | 683 | elif source_format in NORMAL_SOURCE_FORMATS: | 684 | elif source_format in NORMAL_SOURCE_FORMATS: |
This looks good.
However, the diff on LP includes a bit much. Is that a bug with
added files + prerequisite branches on Launchpad?
Thanks,
James