Rev 5: Handle when there is no common ancestor. in http://bzr.arbash-meinel.com/plugins/per_file_remerge
John Arbash Meinel
john at arbash-meinel.com
Wed Jun 18 16:06:17 BST 2008
At http://bzr.arbash-meinel.com/plugins/per_file_remerge
------------------------------------------------------------
revno: 5
revision-id: john at arbash-meinel.com-20080618150604-agwb2hp79jfckpw5
parent: john at arbash-meinel.com-20080618140937-75riqlogk81ac8td
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: per_file_remerge
timestamp: Wed 2008-06-18 10:06:04 -0500
message:
Handle when there is no common ancestor.
-------------- next part --------------
=== modified file 'per_file_remerge.py'
--- a/per_file_remerge.py 2008-06-18 14:09:37 +0000
+++ b/per_file_remerge.py 2008-06-18 15:06:04 +0000
@@ -21,6 +21,8 @@
errors,
graph,
merge,
+ revision,
+ trace,
ui,
)
@@ -112,10 +114,15 @@
finally:
basis_tree.unlock()
- base_revision_id, num_steps = graph_obj.find_unique_lca(
- this_last_modified_revision_id,
- other_last_modified_revision_id,
- count_steps=True)
+ try:
+ base_revision_id, num_steps = graph_obj.find_unique_lca(
+ this_last_modified_revision_id,
+ other_last_modified_revision_id,
+ count_steps=True)
+ except errors.NoCommonAncestor:
+ trace.warning('Could not find a common ancestor for %s, using null:',
+ file_id)
+ base_revision_id = revision.NULL_REVISION
return (this_last_modified_revision_id, base_revision_id,
other_last_modified_revision_id)
=== modified file 'test_per_file_remerge.py'
--- a/test_per_file_remerge.py 2008-06-18 14:02:30 +0000
+++ b/test_per_file_remerge.py 2008-06-18 15:06:04 +0000
@@ -117,7 +117,7 @@
'new a contents\n'
'>>>>>>> MERGE-SOURCE\n', 'tree1/a')
- def test_remerge(self):
+ def test_remerge_all_conflicts(self):
tree1, tree2 = self.create_criss_cross_merge()
# Add another file into tree2, to make sure it gets merged, but not
# touched by remerge
@@ -132,3 +132,21 @@
self.assertFileEqual('updated a contents\n', 'tree1/a')
self.assertFileEqual('updated b contents\n', 'tree1/b')
self.assertFileEqual('c contents\n', 'tree1/c')
+
+ def test_no_common_ancestry(self):
+ # The same file is introduced on both sides, it can conflict, or
+ # whatever, but we shouldn't fail to finish.
+ tree1 = self.make_branch_and_tree('tree1')
+ tree1.commit('common base')
+ tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
+
+ self.build_tree(['tree1/a', 'tree2/a'])
+ tree1.add(['a'], ['a-id'])
+ tree1.commit('add a')
+ tree2.add(['a'], ['a-id'])
+ tree2.commit('add a')
+
+ # That should conflict
+ self.assertEqual(1, tree1.merge_from_branch(tree2.branch))
+ # There should still be a conflict, but the remerge should complete
+ self.run_bzr(['per-file-remerge'], working_dir='tree1', retcode=1)
More information about the bazaar-commits
mailing list