~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_update.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-04 23:53:19 UTC
  • mfrom: (5809.2.6 private-update-revisions)
  • Revision ID: pqm@pqm.ubuntu.com-20110504235319-9yz7jg7i0mica9wk
(jelmer) Make InterBranch.update_revisions private. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
        self.assertEqual('foo', child_tree.branch.update())
71
71
        self.assertEqual(['bar'], child_tree.branch.revision_history())
72
72
 
73
 
 
74
 
class TestUpdateRevisions(per_branch.TestCaseWithBranch):
75
 
 
76
 
    def test_accepts_graph(self):
77
 
        # An implementation may not use it, but it should allow a 'graph' to be
78
 
        # supplied
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')
83
 
 
84
 
        tree1.lock_write()
85
 
        self.addCleanup(tree1.unlock)
86
 
        tree2.lock_read()
87
 
        self.addCleanup(tree2.unlock)
88
 
        graph = tree2.branch.repository.get_graph(tree1.branch.repository)
89
 
 
90
 
        tree1.branch.update_revisions(tree2.branch, graph=graph)
91
 
        self.assertEqual((2, rev2), tree1.branch.last_revision_info())
92
 
 
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')
99
 
 
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))
105
 
 
106
 
        tree1.branch.update_revisions(tree2.branch, overwrite=True)
107
 
        self.assertEqual((2, rev2b), tree1.branch.last_revision_info())
108
 
 
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')
114
 
 
115
 
        tree1.branch.update_revisions(tree2.branch)
116
 
        self.assertEqual((2, rev2), tree1.branch.last_revision_info())
117
 
 
118
 
        tree1.branch.update_revisions(tree2.branch, overwrite=True)
119
 
        self.assertEqual((1, rev1), tree1.branch.last_revision_info())
120
 
 
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')