Merge lp:~jelmer/bzr-builddeb/merge-quilt-option into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 690
Merged at revision: 690
Proposed branch: lp:~jelmer/bzr-builddeb/merge-quilt-option
Merge into: lp:bzr-builddeb
Diff against target: 117 lines (+64/-3)
3 files modified
__init__.py (+13/-3)
config.py (+3/-0)
tests/test_merge_quilt.py (+48/-0)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/merge-quilt-option
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+87705@code.launchpad.net

Description of the change

Add option to enable/disable the smart merging hooks, so people can
disable them in case we get anything wrong.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

12 + from bzrlib import trace; trace.mutter("FOO")

Might be nice to have the mutter there actually so that there is the trace in the log file.

Thanks,

James

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On 01/06/2012 04:32 PM, James Westby wrote:
> Review: Approve
>
> 12 + from bzrlib import trace; trace.mutter("FOO")
>
> Might be nice to have the mutter there actually so that there is the trace in the log file.
>
:-) Thanks for catching that. I've improved the message.

Cheers,

Jelmer

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '__init__.py'
--- __init__.py 2012-01-05 18:53:13 +0000
+++ __init__.py 2012-01-06 01:35:25 +0000
@@ -203,6 +203,13 @@
203 merger.this_tree.path2id("debian/patches") is None and203 merger.this_tree.path2id("debian/patches") is None and
204 merger.working_tree.path2id("debian/patches") is None):204 merger.working_tree.path2id("debian/patches") is None):
205 return205 return
206
207 from bzrlib.plugins.builddeb.util import debuild_config
208 config = debuild_config(merger.working_tree, merger.working_tree)
209 if not config.quilt_smart_merge:
210 from bzrlib import trace; trace.mutter("FOO")
211 return
212
206 import shutil213 import shutil
207 from bzrlib import trace214 from bzrlib import trace
208 from bzrlib.plugins.builddeb.errors import QuiltUnapplyError215 from bzrlib.plugins.builddeb.errors import QuiltUnapplyError
@@ -213,7 +220,8 @@
213 if merger.working_tree.path2id("debian/patches") is not None:220 if merger.working_tree.path2id("debian/patches") is not None:
214 quilt_pop_all(working_dir=merger.working_tree.basedir)221 quilt_pop_all(working_dir=merger.working_tree.basedir)
215 try:222 try:
216 merger.this_tree, this_dir = tree_unapply_patches(merger.this_tree, merger.this_branch)223 merger.this_tree, this_dir = tree_unapply_patches(merger.this_tree,
224 merger.this_branch)
217 except QuiltError, e:225 except QuiltError, e:
218 shutil.rmtree(this_dir)226 shutil.rmtree(this_dir)
219 raise QuiltUnapplyError("this", e.msg)227 raise QuiltUnapplyError("this", e.msg)
@@ -221,7 +229,8 @@
221 if this_dir is not None:229 if this_dir is not None:
222 merger._quilt_tempdirs.append(this_dir)230 merger._quilt_tempdirs.append(this_dir)
223 try:231 try:
224 merger.base_tree, base_dir = tree_unapply_patches(merger.base_tree, merger.this_branch)232 merger.base_tree, base_dir = tree_unapply_patches(merger.base_tree,
233 merger.this_branch)
225 except QuiltError, e:234 except QuiltError, e:
226 shutil.rmtree(base_dir)235 shutil.rmtree(base_dir)
227 raise QuiltUnapplyError("base", e.msg)236 raise QuiltUnapplyError("base", e.msg)
@@ -232,7 +241,8 @@
232 if other_branch is None:241 if other_branch is None:
233 other_branch = merger.this_branch242 other_branch = merger.this_branch
234 try:243 try:
235 merger.other_tree, other_dir = tree_unapply_patches(merger.other_tree, other_branch)244 merger.other_tree, other_dir = tree_unapply_patches(merger.other_tree,
245 other_branch)
236 except QuiltError, e:246 except QuiltError, e:
237 shutil.rmtree(other_dir)247 shutil.rmtree(other_dir)
238 raise QuiltUnapplyError("other", e.msg)248 raise QuiltUnapplyError("other", e.msg)
239249
=== modified file 'config.py'
--- config.py 2011-11-22 14:05:25 +0000
+++ config.py 2012-01-06 01:35:25 +0000
@@ -295,6 +295,9 @@
295 commit_message_from_changelog = _bool_property('commit-message-from-changelog',295 commit_message_from_changelog = _bool_property('commit-message-from-changelog',
296 "Whether the commit message should come from debian/changelog", default=False)296 "Whether the commit message should come from debian/changelog", default=False)
297297
298 quilt_smart_merge = _bool_property('quilt-smart-merge',
299 "Automatically unapply quilt patches during merge", default=True)
300
298301
299def _test():302def _test():
300 import doctest303 import doctest
301304
=== modified file 'tests/test_merge_quilt.py'
--- tests/test_merge_quilt.py 2012-01-05 11:38:00 +0000
+++ tests/test_merge_quilt.py 2012-01-06 01:35:25 +0000
@@ -125,3 +125,51 @@
125 # "a" should be unapplied again125 # "a" should be unapplied again
126 self.assertPathDoesNotExist("a/a")126 self.assertPathDoesNotExist("a/a")
127 self.assertEquals(1, conflicts)127 self.assertEquals(1, conflicts)
128
129 def test_disabled_hook(self):
130 self.enable_hooks()
131
132 tree_a = self.make_branch_and_tree('a')
133 self.build_tree(['a/debian/', 'a/debian/patches/'])
134 self.build_tree_contents([
135 ('a/debian/patches/series', 'patch1\n'),
136 ('a/debian/patches/patch1', TRIVIAL_PATCH),
137 ("a/debian/bzr-builddeb.conf", "[BUILDDEB]\n"
138 "quilt-smart-merge = False\n"),
139 ("a/a", "")])
140 tree_a.smart_add([tree_a.basedir])
141 tree_a.commit('initial')
142
143 tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
144 self.build_tree_contents([
145 ('a/debian/patches/patch1',
146 "\n".join(TRIVIAL_PATCH.splitlines()[:-1] + ["+d\n"]))])
147 quilt_push_all(tree_a.basedir)
148 tree_a.smart_add([tree_a.basedir])
149 tree_a.commit('apply patches')
150 self.assertFileEqual("d\n", "a/a")
151 self.build_tree_contents([
152 ('b/debian/patches/patch1',
153 "\n".join(TRIVIAL_PATCH.splitlines()[:-1] + ["+c\n"]))])
154 quilt_push_all(tree_b.basedir)
155 tree_b.commit('apply patches')
156 self.assertFileEqual("c\n", "b/a")
157 conflicts = tree_a.merge_from_branch(tree_b.branch)
158 self.assertFileEqual("""\
159--- /dev/null\t2012-01-02 01:09:10.986490031 +0100
160+++ base/a\t2012-01-02 20:03:59.710666215 +0100
161@@ -0,0 +1 @@
162<<<<<<< TREE
163+d
164=======
165+c
166>>>>>>> MERGE-SOURCE
167""", "a/debian/patches/patch1")
168 self.assertFileEqual("""\
169<<<<<<< TREE
170d
171=======
172c
173>>>>>>> MERGE-SOURCE
174""", "a/a")
175 self.assertEquals(2, conflicts)

Subscribers

People subscribed via source and target branches