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
=== modified file 'NEWS'
--- NEWS 2010-04-15 12:02:11 +0000
+++ NEWS 2010-04-21 04:00:34 +0000
@@ -5,6 +5,20 @@
5.. contents:: List of Releases5.. contents:: List of Releases
6 :depth: 16 :depth: 1
77
8bzr 2.1.2
9#########
10
11:Codename: ?
12:2.1.2: NOT RELEASED YET
13
14Bug 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
8bzr 2.1.122bzr 2.1.1
9#########23#########
1024
1125
=== modified file 'bzrlib/merge.py'
--- bzrlib/merge.py 2010-04-15 10:23:59 +0000
+++ bzrlib/merge.py 2010-04-21 04:00:34 +0000
@@ -705,7 +705,9 @@
705 :param this_tree: The local tree in the merge operation705 :param this_tree: The local tree in the merge operation
706 :param base_tree: The common tree in the merge operation706 :param base_tree: The common tree in the merge operation
707 :param other_tree: The other tree to merge changes from707 :param other_tree: The other tree to merge changes from
708 :param this_branch: The branch associated with this_tree708 :param this_branch: The branch associated with this_tree.
709 this_tree.branch will be used if not passed explicitly. Cannot be
710 None.
709 :param interesting_ids: The file_ids of files that should be711 :param interesting_ids: The file_ids of files that should be
710 participate in the merge. May not be combined with712 participate in the merge. May not be combined with
711 interesting_files.713 interesting_files.
@@ -734,6 +736,10 @@
734 self.this_tree = working_tree736 self.this_tree = working_tree
735 self.base_tree = base_tree737 self.base_tree = base_tree
736 self.other_tree = other_tree738 self.other_tree = other_tree
739 if this_branch is None:
740 this_branch = this_tree.branch
741 if this_branch is None:
742 raise AssertionError('this_branch cannot be None')
737 self.this_branch = this_branch743 self.this_branch = this_branch
738 self._raw_conflicts = []744 self._raw_conflicts = []
739 self.cooked_conflicts = []745 self.cooked_conflicts = []
740746
=== modified file 'bzrlib/switch.py'
--- bzrlib/switch.py 2010-02-17 17:11:16 +0000
+++ bzrlib/switch.py 2010-04-21 04:00:34 +0000
@@ -135,7 +135,8 @@
135 note("Tree is up to date at revision %d.", to_branch.revno())135 note("Tree is up to date at revision %d.", to_branch.revno())
136 return136 return
137 base_tree = source_repository.revision_tree(tree.last_revision())137 base_tree = source_repository.revision_tree(tree.last_revision())
138 merge.Merge3Merger(tree, tree, base_tree, to_branch.repository.revision_tree(revision_id))138 merge.Merge3Merger(tree, tree, base_tree,
139 to_branch.repository.revision_tree(revision_id))
139 tree.set_last_revision(to_branch.last_revision())140 tree.set_last_revision(to_branch.last_revision())
140 if not quiet:141 if not quiet:
141 note('Updated to revision %d.' % to_branch.revno())142 note('Updated to revision %d.' % to_branch.revno())

Subscribers

People subscribed via source and target branches