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

  • Committer: Aaron Bentley
  • Date: 2007-08-21 13:52:35 UTC
  • mto: This revision was merged to the branch mainline in revision 2765.
  • Revision ID: abentley@panoramicfeedback.com-20070821135235-b550623c3zvm71re
Test transform rollback when renaming into place

Show diffs side-by-side

added added

removed removed

Lines of Context:
1370
1370
 
1371
1371
    class ExceptionFileMover(_FileMover):
1372
1372
 
 
1373
        def __init__(self, bad_source=None, bad_target=None):
 
1374
            _FileMover.__init__(self)
 
1375
            self.bad_source = bad_source
 
1376
            self.bad_target = bad_target
 
1377
 
1373
1378
        def rename(self, source, target):
1374
 
            if source.endswith('a'):
 
1379
            if (self.bad_source is not None and
 
1380
                source.endswith(self.bad_source)):
 
1381
                raise Bogus
 
1382
            elif (self.bad_target is not None and
 
1383
                target.endswith(self.bad_target)):
1375
1384
                raise Bogus
1376
1385
            else:
1377
1386
                _FileMover.rename(self, source, target)
1384
1393
        a_id = tt.trans_id_tree_path('a')
1385
1394
        tt.adjust_path('c', tt.root, a_id)
1386
1395
        tt.adjust_path('d', a_id, tt.trans_id_tree_path('a/b'))
1387
 
        self.assertRaises(Bogus, tt.apply, _mover=self.ExceptionFileMover())
1388
 
        self.failUnlessExists('a')
1389
 
        self.failUnlessExists('a/b')
 
1396
        self.assertRaises(Bogus, tt.apply,
 
1397
                          _mover=self.ExceptionFileMover(bad_source='a'))
 
1398
        self.failUnlessExists('a')
 
1399
        self.failUnlessExists('a/b')
 
1400
        tt.apply()
 
1401
        self.failUnlessExists('c')
 
1402
        self.failUnlessExists('c/d')
 
1403
 
 
1404
    def test_rollback_rename_into_place(self):
 
1405
        tree = self.make_branch_and_tree('.')
 
1406
        self.build_tree(['a/', 'a/b'])
 
1407
        tt = TreeTransform(tree)
 
1408
        self.addCleanup(tt.finalize)
 
1409
        a_id = tt.trans_id_tree_path('a')
 
1410
        tt.adjust_path('c', tt.root, a_id)
 
1411
        tt.adjust_path('d', a_id, tt.trans_id_tree_path('a/b'))
 
1412
        self.assertRaises(Bogus, tt.apply,
 
1413
                          _mover=self.ExceptionFileMover(bad_target='c/d'))
 
1414
        self.failUnlessExists('a')
 
1415
        self.failUnlessExists('a/b')
 
1416
        tt.apply()
 
1417
        self.failUnlessExists('c')
 
1418
        self.failUnlessExists('c/d')