/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branchbuilder.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-22 20:40:34 UTC
  • mto: (3514.4.8 merge_lca_multi)
  • mto: This revision was merged to the branch mainline in revision 3590.
  • Revision ID: john@arbash-meinel.com-20080722204034-x54day968ipfmr1y
Add the ability to define a series of commits, which allows us to hold open the locks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
 
202
202
    def test_set_parent(self):
203
203
        builder = self.build_a_rev()
 
204
        builder.start_series()
 
205
        self.addCleanup(builder.finish_series)
204
206
        builder.build_snapshot('B-id', ['A-id'],
205
207
            [('modify', ('a-id', 'new\ncontent\n'))])
206
208
        builder.build_snapshot('C-id', ['A-id'], 
211
213
        #   C B
212
214
        # And not A => B => C
213
215
        repo = builder.get_branch().repository
214
 
        repo.lock_read()
215
 
        self.addCleanup(repo.unlock)
216
216
        self.assertEqual({'B-id': ('A-id',), 'C-id': ('A-id',)},
217
217
                         repo.get_parent_map(['B-id', 'C-id']))
218
218
        b_tree = repo.revision_tree('B-id')
232
232
 
233
233
    def test_set_merge_parent(self):
234
234
        builder = self.build_a_rev()
 
235
        builder.start_series()
 
236
        self.addCleanup(builder.finish_series)
235
237
        builder.build_snapshot('B-id', ['A-id'],
236
238
            [('add', ('b', 'b-id', 'file', 'b\ncontent\n'))])
237
239
        builder.build_snapshot('C-id', ['A-id'],
238
240
            [('add', ('c', 'c-id', 'file', 'alt\ncontent\n'))])
239
241
        builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
240
242
        repo = builder.get_branch().repository
241
 
        repo.lock_read()
242
 
        self.addCleanup(repo.unlock)
243
243
        self.assertEqual({'B-id': ('A-id',), 'C-id': ('A-id',),
244
244
                          'D-id': ('B-id', 'C-id')},
245
245
                         repo.get_parent_map(['B-id', 'C-id', 'D-id']))
253
253
 
254
254
    def test_set_merge_parent_and_contents(self):
255
255
        builder = self.build_a_rev()
 
256
        builder.start_series()
 
257
        self.addCleanup(builder.finish_series)
256
258
        builder.build_snapshot('B-id', ['A-id'],
257
259
            [('add', ('b', 'b-id', 'file', 'b\ncontent\n'))])
258
260
        builder.build_snapshot('C-id', ['A-id'],
260
262
        builder.build_snapshot('D-id', ['B-id', 'C-id'],
261
263
            [('add', ('c', 'c-id', 'file', 'alt\ncontent\n'))])
262
264
        repo = builder.get_branch().repository
263
 
        repo.lock_read()
264
 
        self.addCleanup(repo.unlock)
265
265
        self.assertEqual({'B-id': ('A-id',), 'C-id': ('A-id',),
266
266
                          'D-id': ('B-id', 'C-id')},
267
267
                         repo.get_parent_map(['B-id', 'C-id', 'D-id']))
274
274
        # Because we copied the exact text into *this* tree, the 'c' file
275
275
        # should look like it was not modified in the merge
276
276
        self.assertEqual('C-id', d_tree.inventory['c-id'].revision)
 
277
 
 
278
    def test_start_finish_series(self):
 
279
        builder = BranchBuilder(self.get_transport().clone('foo'))
 
280
        builder.start_series()
 
281
        try:
 
282
            self.assertIsNot(None, builder._tree)
 
283
            self.assertEqual('w', builder._tree._lock_mode)
 
284
            self.assertTrue(builder._branch.is_locked())
 
285
        finally:
 
286
            builder.finish_series()
 
287
        self.assertIs(None, builder._tree)
 
288
        self.assertFalse(builder._branch.is_locked())