66
68
# commit to the master making the child tree out of date and not a prefix.
67
69
master_tree.commit('bar', rev_id='bar', allow_pointless=True)
68
70
self.assertEqual('foo', child_tree.branch.update())
69
self.assertEqual(['bar'], child_tree.branch.revision_history())
72
class TestUpdateRevisions(per_branch.TestCaseWithBranch):
74
def test_accepts_graph(self):
75
# An implementation may not use it, but it should allow a 'graph' to be
77
tree1 = self.make_branch_and_tree('tree1')
78
rev1 = tree1.commit('one')
79
tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
80
rev2 = tree2.commit('two')
83
self.addCleanup(tree1.unlock)
85
self.addCleanup(tree2.unlock)
86
graph = tree2.branch.repository.get_graph(tree1.branch.repository)
88
tree1.branch.update_revisions(tree2.branch, graph=graph)
89
self.assertEqual((2, rev2), tree1.branch.last_revision_info())
91
def test_overwrite_ignores_diverged(self):
92
tree1 = self.make_branch_and_tree('tree1')
93
rev1 = tree1.commit('one')
94
tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
95
rev2 = tree1.commit('two')
96
rev2b = tree2.commit('alt two')
98
self.assertRaises(errors.DivergedBranches,
99
tree1.branch.update_revisions,
100
tree2.branch, overwrite=False)
101
# However, the revision should be copied into the repository
102
self.assertTrue(tree1.branch.repository.has_revision(rev2b))
104
tree1.branch.update_revisions(tree2.branch, overwrite=True)
105
self.assertEqual((2, rev2b), tree1.branch.last_revision_info())
107
def test_ignores_older_unless_overwrite(self):
108
tree1 = self.make_branch_and_tree('tree1')
109
rev1 = tree1.commit('one')
110
tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
111
rev2 = tree1.commit('two')
113
tree1.branch.update_revisions(tree2.branch)
114
self.assertEqual((2, rev2), tree1.branch.last_revision_info())
116
tree1.branch.update_revisions(tree2.branch, overwrite=True)
117
self.assertEqual((1, rev1), tree1.branch.last_revision_info())
71
self.assertEqual('bar', child_tree.branch.last_revision())
73
def test_update_in_checkout_of_readonly(self):
74
tree1 = self.make_branch_and_tree('tree1')
75
rev1 = tree1.commit('one')
77
tree1.branch.tags.set_tag('test-tag', rev1)
78
except errors.TagsNotSupported:
80
raise tests.TestNotApplicable("only triggered from branches with"
82
readonly_branch1 = branch.Branch.open('readonly+' + tree1.branch.base)
83
tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
85
tree2.branch.bind(readonly_branch1)
86
except errors.UpgradeRequired:
87
# old branch, cant test.
88
raise tests.TestNotApplicable("only triggered in bound branches")
89
rev2 = tree1.commit('two')
91
self.assertEqual(rev2, tree2.branch.last_revision())