/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_shelf_ui.py

  • Committer: Martin Pool
  • Date: 2009-08-28 04:13:16 UTC
  • mfrom: (4634.6.8 2.0)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: mbp@sourcefrog.net-20090828041316-adcbxfnfpc4bjtpl
Merge 2.0 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import os
20
20
import sys
21
21
 
22
 
from bzrlib import errors, shelf_ui, tests
 
22
from bzrlib import (
 
23
    errors,
 
24
    shelf_ui,
 
25
    revision,
 
26
    tests,
 
27
)
23
28
 
24
29
 
25
30
class ExpectShelver(shelf_ui.Shelver):
264
269
        self.assertIs(None, tree.get_shelf_manager().last_shelf())
265
270
        self.assertFileEqual(LINES_AJ, 'tree/foo')
266
271
 
 
272
    @staticmethod
 
273
    def shelve_all(tree, target_revision_id):
 
274
        tree.lock_write()
 
275
        try:
 
276
            target = tree.branch.repository.revision_tree(target_revision_id)
 
277
            shelver = shelf_ui.Shelver(tree, target, auto=True,
 
278
                                       auto_apply=True)
 
279
            shelver.run()
 
280
        finally:
 
281
            tree.unlock()
 
282
 
 
283
    def test_shelve_old_root_deleted(self):
 
284
        tree1 = self.make_branch_and_tree('tree1')
 
285
        tree1.commit('add root')
 
286
        tree2 = self.make_branch_and_tree('tree2')
 
287
        rev2 = tree2.commit('add root')
 
288
        tree1.merge_from_branch(tree2.branch,
 
289
                                from_revision=revision.NULL_REVISION)
 
290
        tree1.commit('Replaced root entry')
 
291
        # This is essentially assertNotRaises(InconsistentDelta)
 
292
        self.expectFailure('Cannot shelve replacing a root entry',
 
293
                           self.assertRaises, AssertionError,
 
294
                           self.assertRaises, errors.InconsistentDelta,
 
295
                           self.shelve_all, tree1, rev2)
 
296
 
 
297
    def test_shelve_split(self):
 
298
        outer_tree = self.make_branch_and_tree('outer')
 
299
        outer_tree.commit('Add root')
 
300
        inner_tree = self.make_branch_and_tree('outer/inner')
 
301
        rev2 = inner_tree.commit('Add root')
 
302
        outer_tree.subsume(inner_tree)
 
303
        # This is essentially assertNotRaises(ValueError).
 
304
        # The ValueError is 'None is not a valid file id'.
 
305
        self.expectFailure('Cannot shelve a join back to the inner tree.',
 
306
                           self.assertRaises, AssertionError,
 
307
                           self.assertRaises, ValueError, self.shelve_all,
 
308
                           outer_tree, rev2)
 
309
 
267
310
 
268
311
class TestApplyReporter(TestShelver):
269
312