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
1=== modified file '__init__.py'
2--- __init__.py 2012-01-05 18:53:13 +0000
3+++ __init__.py 2012-01-06 01:35:25 +0000
4@@ -203,6 +203,13 @@
5 merger.this_tree.path2id("debian/patches") is None and
6 merger.working_tree.path2id("debian/patches") is None):
7 return
8+
9+ from bzrlib.plugins.builddeb.util import debuild_config
10+ config = debuild_config(merger.working_tree, merger.working_tree)
11+ if not config.quilt_smart_merge:
12+ from bzrlib import trace; trace.mutter("FOO")
13+ return
14+
15 import shutil
16 from bzrlib import trace
17 from bzrlib.plugins.builddeb.errors import QuiltUnapplyError
18@@ -213,7 +220,8 @@
19 if merger.working_tree.path2id("debian/patches") is not None:
20 quilt_pop_all(working_dir=merger.working_tree.basedir)
21 try:
22- merger.this_tree, this_dir = tree_unapply_patches(merger.this_tree, merger.this_branch)
23+ merger.this_tree, this_dir = tree_unapply_patches(merger.this_tree,
24+ merger.this_branch)
25 except QuiltError, e:
26 shutil.rmtree(this_dir)
27 raise QuiltUnapplyError("this", e.msg)
28@@ -221,7 +229,8 @@
29 if this_dir is not None:
30 merger._quilt_tempdirs.append(this_dir)
31 try:
32- merger.base_tree, base_dir = tree_unapply_patches(merger.base_tree, merger.this_branch)
33+ merger.base_tree, base_dir = tree_unapply_patches(merger.base_tree,
34+ merger.this_branch)
35 except QuiltError, e:
36 shutil.rmtree(base_dir)
37 raise QuiltUnapplyError("base", e.msg)
38@@ -232,7 +241,8 @@
39 if other_branch is None:
40 other_branch = merger.this_branch
41 try:
42- merger.other_tree, other_dir = tree_unapply_patches(merger.other_tree, other_branch)
43+ merger.other_tree, other_dir = tree_unapply_patches(merger.other_tree,
44+ other_branch)
45 except QuiltError, e:
46 shutil.rmtree(other_dir)
47 raise QuiltUnapplyError("other", e.msg)
48
49=== modified file 'config.py'
50--- config.py 2011-11-22 14:05:25 +0000
51+++ config.py 2012-01-06 01:35:25 +0000
52@@ -295,6 +295,9 @@
53 commit_message_from_changelog = _bool_property('commit-message-from-changelog',
54 "Whether the commit message should come from debian/changelog", default=False)
55
56+ quilt_smart_merge = _bool_property('quilt-smart-merge',
57+ "Automatically unapply quilt patches during merge", default=True)
58+
59
60 def _test():
61 import doctest
62
63=== modified file 'tests/test_merge_quilt.py'
64--- tests/test_merge_quilt.py 2012-01-05 11:38:00 +0000
65+++ tests/test_merge_quilt.py 2012-01-06 01:35:25 +0000
66@@ -125,3 +125,51 @@
67 # "a" should be unapplied again
68 self.assertPathDoesNotExist("a/a")
69 self.assertEquals(1, conflicts)
70+
71+ def test_disabled_hook(self):
72+ self.enable_hooks()
73+
74+ tree_a = self.make_branch_and_tree('a')
75+ self.build_tree(['a/debian/', 'a/debian/patches/'])
76+ self.build_tree_contents([
77+ ('a/debian/patches/series', 'patch1\n'),
78+ ('a/debian/patches/patch1', TRIVIAL_PATCH),
79+ ("a/debian/bzr-builddeb.conf", "[BUILDDEB]\n"
80+ "quilt-smart-merge = False\n"),
81+ ("a/a", "")])
82+ tree_a.smart_add([tree_a.basedir])
83+ tree_a.commit('initial')
84+
85+ tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
86+ self.build_tree_contents([
87+ ('a/debian/patches/patch1',
88+ "\n".join(TRIVIAL_PATCH.splitlines()[:-1] + ["+d\n"]))])
89+ quilt_push_all(tree_a.basedir)
90+ tree_a.smart_add([tree_a.basedir])
91+ tree_a.commit('apply patches')
92+ self.assertFileEqual("d\n", "a/a")
93+ self.build_tree_contents([
94+ ('b/debian/patches/patch1',
95+ "\n".join(TRIVIAL_PATCH.splitlines()[:-1] + ["+c\n"]))])
96+ quilt_push_all(tree_b.basedir)
97+ tree_b.commit('apply patches')
98+ self.assertFileEqual("c\n", "b/a")
99+ conflicts = tree_a.merge_from_branch(tree_b.branch)
100+ self.assertFileEqual("""\
101+--- /dev/null\t2012-01-02 01:09:10.986490031 +0100
102++++ base/a\t2012-01-02 20:03:59.710666215 +0100
103+@@ -0,0 +1 @@
104+<<<<<<< TREE
105++d
106+=======
107++c
108+>>>>>>> MERGE-SOURCE
109+""", "a/debian/patches/patch1")
110+ self.assertFileEqual("""\
111+<<<<<<< TREE
112+d
113+=======
114+c
115+>>>>>>> MERGE-SOURCE
116+""", "a/a")
117+ self.assertEquals(2, conflicts)

Subscribers

People subscribed via source and target branches