Merge lp:~spiv/bzr/switch-crash-559436 into lp:bzr/2.1

Proposed by Andrew Bennetts
Status: Rejected
Rejected by: Andrew Bennetts
Proposed branch: lp:~spiv/bzr/switch-crash-559436
Merge into: lp:bzr/2.1
Diff against target: 64 lines (+23/-2)
3 files modified
NEWS (+14/-0)
bzrlib/merge.py (+7/-1)
bzrlib/switch.py (+2/-1)
To merge this branch: bzr merge lp:~spiv/bzr/switch-crash-559436
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+23817@code.launchpad.net

Commit message

Fix crash in 'bzr switch' related to the merge_file_content hook.

Description of the change

This fixes bug 559436. A more conservative change might be to explicitly pass this_branch in bzrlib.switch._update, but I think it's reasonable for Merge3Merger to use this_tree.branch if not told otherwise.

I haven't added test coverage explicitly, instead relying on a new assertion in Merge3Merger to trip. In an earlier revision I added test coverage in a pretty blunt way: by registering a hook in setUp of blackbox.test_switch.TestSwitch that asserts the 'this_branch' attribute is set, but I think the simple approach is better.

(Incidentally, I cannot find a case where a *Merger is passed a this_tree that is not the same object as the working_tree, and Merge3Merger actually does self.this_tree = working_tree. Something to clean up in a future API bump perhaps.)

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-04-15 12:02:11 +0000
3+++ NEWS 2010-04-21 04:00:34 +0000
4@@ -5,6 +5,20 @@
5 .. contents:: List of Releases
6 :depth: 1
7
8+bzr 2.1.2
9+#########
10+
11+:Codename: ?
12+:2.1.2: NOT RELEASED YET
13+
14+Bug Fixes
15+*********
16+
17+* ``bzr switch`` no longer crashes with "no attribute 'get_config'"
18+ errors in some circumstances. This was a regression from bzr 2.0.
19+ (Andrew Bennetts, #559436)
20+
21+
22 bzr 2.1.1
23 #########
24
25
26=== modified file 'bzrlib/merge.py'
27--- bzrlib/merge.py 2010-04-15 10:23:59 +0000
28+++ bzrlib/merge.py 2010-04-21 04:00:34 +0000
29@@ -705,7 +705,9 @@
30 :param this_tree: The local tree in the merge operation
31 :param base_tree: The common tree in the merge operation
32 :param other_tree: The other tree to merge changes from
33- :param this_branch: The branch associated with this_tree
34+ :param this_branch: The branch associated with this_tree.
35+ this_tree.branch will be used if not passed explicitly. Cannot be
36+ None.
37 :param interesting_ids: The file_ids of files that should be
38 participate in the merge. May not be combined with
39 interesting_files.
40@@ -734,6 +736,10 @@
41 self.this_tree = working_tree
42 self.base_tree = base_tree
43 self.other_tree = other_tree
44+ if this_branch is None:
45+ this_branch = this_tree.branch
46+ if this_branch is None:
47+ raise AssertionError('this_branch cannot be None')
48 self.this_branch = this_branch
49 self._raw_conflicts = []
50 self.cooked_conflicts = []
51
52=== modified file 'bzrlib/switch.py'
53--- bzrlib/switch.py 2010-02-17 17:11:16 +0000
54+++ bzrlib/switch.py 2010-04-21 04:00:34 +0000
55@@ -135,7 +135,8 @@
56 note("Tree is up to date at revision %d.", to_branch.revno())
57 return
58 base_tree = source_repository.revision_tree(tree.last_revision())
59- merge.Merge3Merger(tree, tree, base_tree, to_branch.repository.revision_tree(revision_id))
60+ merge.Merge3Merger(tree, tree, base_tree,
61+ to_branch.repository.revision_tree(revision_id))
62 tree.set_last_revision(to_branch.last_revision())
63 if not quiet:
64 note('Updated to revision %d.' % to_branch.revno())

Subscribers

People subscribed via source and target branches