/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 breezy/tests/test_branch.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-07 11:22:07 UTC
  • mfrom: (6951 work)
  • mto: This revision was merged to the branch mainline in revision 6953.
  • Revision ID: jelmer@jelmer.uk-20180507112207-x3kqvmjdzfvmfk2p
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
437
437
 
438
438
    def create_branch_with_reference(self):
439
439
        branch = self.make_branch('branch')
440
 
        branch._set_all_reference_info({'file-id': ('path', 'location')})
 
440
        branch._set_all_reference_info({'path': ('location', 'file-id')})
441
441
        return branch
442
442
 
443
443
    @staticmethod
454
454
        branch.lock_read()
455
455
        self.addCleanup(branch.unlock)
456
456
        self.instrument_branch(branch, gets)
457
 
        branch.get_reference_info('file-id')
458
 
        branch.get_reference_info('file-id')
 
457
        branch.get_reference_info('path')
 
458
        branch.get_reference_info('path')
459
459
        self.assertEqual(1, len(gets))
460
460
 
461
461
    def test_reference_info_caching_read_unlocked(self):
462
462
        gets = []
463
463
        branch = self.create_branch_with_reference()
464
464
        self.instrument_branch(branch, gets)
465
 
        branch.get_reference_info('file-id')
466
 
        branch.get_reference_info('file-id')
 
465
        branch.get_reference_info('path')
 
466
        branch.get_reference_info('path')
467
467
        self.assertEqual(2, len(gets))
468
468
 
469
469
    def test_reference_info_caching_write_locked(self):
472
472
        branch.lock_write()
473
473
        self.instrument_branch(branch, gets)
474
474
        self.addCleanup(branch.unlock)
475
 
        branch._set_all_reference_info({'file-id': ('path2', 'location2')})
476
 
        path, location = branch.get_reference_info('file-id')
 
475
        branch._set_all_reference_info({'path2': ('location2', 'file-id')})
 
476
        location, file_id = branch.get_reference_info('path2')
477
477
        self.assertEqual(0, len(gets))
478
 
        self.assertEqual('path2', path)
 
478
        self.assertEqual('file-id', file_id)
479
479
        self.assertEqual('location2', location)
480
480
 
481
481
    def test_reference_info_caches_cleared(self):
482
482
        branch = self.make_branch('branch')
483
 
        branch.lock_write()
484
 
        branch.set_reference_info('file-id', 'path2', 'location2')
485
 
        branch.unlock()
 
483
        with branch.lock_write():
 
484
            branch.set_reference_info('path2', 'location2', b'file-id')
486
485
        doppelganger = _mod_branch.Branch.open('branch')
487
 
        doppelganger.set_reference_info('file-id', 'path3', 'location3')
488
 
        self.assertEqual(('path3', 'location3'),
489
 
                         branch.get_reference_info('file-id'))
 
486
        doppelganger.set_reference_info('path3', 'location3', b'file-id')
 
487
        self.assertEqual(('location3', b'file-id'),
 
488
                         branch.get_reference_info('path3'))
490
489
 
491
490
    def _recordParentMapCalls(self, repo):
492
491
        self._parent_map_calls = []