~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf_ui.py

  • Committer: Andrew Bennetts
  • Date: 2009-08-25 01:25:57 UTC
  • mfrom: (4642 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4657.
  • Revision ID: andrew.bennetts@canonical.com-20090825012557-1ku5o09nv3ra9n12
Merge from bzr.dev.

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):
242
247
        self.assertIs(None, tree.get_shelf_manager().last_shelf())
243
248
        self.assertFileEqual(LINES_AJ, 'tree/foo')
244
249
 
 
250
    @staticmethod
 
251
    def shelve_all(tree, target_revision_id):
 
252
        tree.lock_write()
 
253
        try:
 
254
            target = tree.branch.repository.revision_tree(target_revision_id)
 
255
            shelver = shelf_ui.Shelver(tree, target, auto=True,
 
256
                                       auto_apply=True)
 
257
            shelver.run()
 
258
        finally:
 
259
            tree.unlock()
 
260
 
 
261
    def test_shelve_old_root_deleted(self):
 
262
        tree1 = self.make_branch_and_tree('tree1')
 
263
        tree1.commit('add root')
 
264
        tree2 = self.make_branch_and_tree('tree2')
 
265
        rev2 = tree2.commit('add root')
 
266
        tree1.merge_from_branch(tree2.branch,
 
267
                                from_revision=revision.NULL_REVISION)
 
268
        tree1.commit('Replaced root entry')
 
269
        # This is essentially assertNotRaises(InconsistentDelta)
 
270
        self.expectFailure('Cannot shelve replacing a root entry',
 
271
                           self.assertRaises, AssertionError,
 
272
                           self.assertRaises, errors.InconsistentDelta,
 
273
                           self.shelve_all, tree1, rev2)
 
274
 
 
275
    def test_shelve_split(self):
 
276
        outer_tree = self.make_branch_and_tree('outer')
 
277
        outer_tree.commit('Add root')
 
278
        inner_tree = self.make_branch_and_tree('outer/inner')
 
279
        rev2 = inner_tree.commit('Add root')
 
280
        outer_tree.subsume(inner_tree)
 
281
        # This is essentially assertNotRaises(ValueError).
 
282
        # The ValueError is 'None is not a valid file id'.
 
283
        self.expectFailure('Cannot shelve a join back to the inner tree.',
 
284
                           self.assertRaises, AssertionError,
 
285
                           self.assertRaises, ValueError, self.shelve_all,
 
286
                           outer_tree, rev2)
 
287
 
245
288
 
246
289
class TestApplyReporter(TestShelver):
247
290