70
70
self.assertEqual('foo', child_tree.branch.update())
71
71
self.assertEqual(['bar'], child_tree.branch.revision_history())
74
class TestUpdateRevisions(per_branch.TestCaseWithBranch):
76
def test_accepts_graph(self):
77
# An implementation may not use it, but it should allow a 'graph' to be
79
tree1 = self.make_branch_and_tree('tree1')
80
rev1 = tree1.commit('one')
81
tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
82
rev2 = tree2.commit('two')
85
self.addCleanup(tree1.unlock)
87
self.addCleanup(tree2.unlock)
88
graph = tree2.branch.repository.get_graph(tree1.branch.repository)
90
tree1.branch.update_revisions(tree2.branch, graph=graph)
91
self.assertEqual((2, rev2), tree1.branch.last_revision_info())
93
def test_overwrite_ignores_diverged(self):
94
tree1 = self.make_branch_and_tree('tree1')
95
rev1 = tree1.commit('one')
96
tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
97
rev2 = tree1.commit('two')
98
rev2b = tree2.commit('alt two')
100
self.assertRaises(errors.DivergedBranches,
101
tree1.branch.update_revisions,
102
tree2.branch, overwrite=False)
103
# However, the revision should be copied into the repository
104
self.assertTrue(tree1.branch.repository.has_revision(rev2b))
106
tree1.branch.update_revisions(tree2.branch, overwrite=True)
107
self.assertEqual((2, rev2b), tree1.branch.last_revision_info())
109
def test_ignores_older_unless_overwrite(self):
110
tree1 = self.make_branch_and_tree('tree1')
111
rev1 = tree1.commit('one')
112
tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
113
rev2 = tree1.commit('two')
115
tree1.branch.update_revisions(tree2.branch)
116
self.assertEqual((2, rev2), tree1.branch.last_revision_info())
118
tree1.branch.update_revisions(tree2.branch, overwrite=True)
119
self.assertEqual((1, rev1), tree1.branch.last_revision_info())
121
73
def test_update_in_checkout_of_readonly(self):
122
74
tree1 = self.make_branch_and_tree('tree1')
123
75
rev1 = tree1.commit('one')