~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testbranch.py

  • Committer: Michael Ellerman
  • Date: 2005-10-26 10:03:47 UTC
  • mfrom: (1185.16.116)
  • mto: (1185.16.126)
  • mto: This revision was merged to the branch mainline in revision 1488.
  • Revision ID: michael@ellerman.id.au-20051026100347-bb0b2bd42f7953f2
MergeĀ mainline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        tree = b2.revision_tree('revision-1')
63
63
        eq(tree.get_file_text('foo-id'), 'hello')
64
64
 
65
 
    def test_push_stores(self):
66
 
        """Copy the stores from one branch to another"""
 
65
    def get_unbalanced_branch_pair(self):
 
66
        """Return two branches, a and b, with one file in a."""
67
67
        os.mkdir('a')
68
68
        br_a = Branch.initialize("a")
69
69
        file('a/b', 'wb').write('b')
70
70
        br_a.add('b')
71
 
        commit(br_a, "silly commit")
72
 
 
 
71
        commit(br_a, "silly commit", rev_id='A')
73
72
        os.mkdir('b')
74
73
        br_b = Branch.initialize("b")
 
74
        return br_a, br_b
 
75
 
 
76
    def get_balanced_branch_pair(self):
 
77
        """Returns br_a, br_b as with one commit in a, and b has a's stores."""
 
78
        br_a, br_b = self.get_unbalanced_branch_pair()
 
79
        br_a.push_stores(br_b)
 
80
        return br_a, br_b
 
81
 
 
82
    def test_push_stores(self):
 
83
        """Copy the stores from one branch to another"""
 
84
        br_a, br_b = self.get_unbalanced_branch_pair()
 
85
        # ensure the revision is missing.
75
86
        self.assertRaises(NoSuchRevision, br_b.get_revision, 
76
87
                          br_a.revision_history()[0])
77
88
        br_a.push_stores(br_b)
 
89
        # check that b now has all the data from a's first commit.
78
90
        rev = br_b.get_revision(br_a.revision_history()[0])
79
91
        tree = br_b.revision_tree(br_a.revision_history()[0])
80
92
        for file_id in tree:
84
96
 
85
97
    def test_copy_branch(self):
86
98
        """Copy the stores from one branch to another"""
87
 
        br_a, br_b = self.test_push_stores()
 
99
        br_a, br_b = self.get_balanced_branch_pair()
88
100
        commit(br_b, "silly commit")
89
101
        os.mkdir('c')
90
102
        br_c = copy_branch(br_a, 'c', basis_branch=br_b)
104
116
        self.assertTrue(os.path.exists('b/one'))
105
117
        self.assertFalse(os.path.exists('b/two'))
106
118
        
107
 
 
108
119
    def test_record_initial_ghost_merge(self):
109
120
        """A pending merge with no revision present is still a merge."""
110
121
        branch = Branch.initialize('.')
158
169
                                        'FOO', 'A')
159
170
        self.assertEqual('FOO', branch.revision_store.get('A', 'sig').read())
160
171
 
 
172
    def test__relcontrolfilename(self):
 
173
        branch = Branch.initialize('.')
 
174
        self.assertEqual('.bzr/%25', branch._rel_controlfilename('%'))
 
175
        
 
176
    def test__relcontrolfilename_empty(self):
 
177
        branch = Branch.initialize('.')
 
178
        self.assertEqual('.bzr', branch._rel_controlfilename(''))
 
179
 
161
180
 
162
181
class TestRemote(TestCaseWithWebserver):
163
182