/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-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
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({'path': ('location', 'file-id')})
 
440
        branch._set_all_reference_info({'file-id': ('path', 'location')})
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('path')
458
 
        branch.get_reference_info('path')
 
457
        branch.get_reference_info('file-id')
 
458
        branch.get_reference_info('file-id')
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('path')
466
 
        branch.get_reference_info('path')
 
465
        branch.get_reference_info('file-id')
 
466
        branch.get_reference_info('file-id')
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({'path2': ('location2', 'file-id')})
476
 
        location, file_id = branch.get_reference_info('path2')
 
475
        branch._set_all_reference_info({'file-id': ('path2', 'location2')})
 
476
        path, location = branch.get_reference_info('file-id')
477
477
        self.assertEqual(0, len(gets))
478
 
        self.assertEqual('file-id', file_id)
 
478
        self.assertEqual('path2', path)
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
 
        with branch.lock_write():
484
 
            branch.set_reference_info('path2', 'location2', b'file-id')
 
483
        branch.lock_write()
 
484
        branch.set_reference_info('file-id', 'path2', 'location2')
 
485
        branch.unlock()
485
486
        doppelganger = _mod_branch.Branch.open('branch')
486
 
        doppelganger.set_reference_info('path3', 'location3', b'file-id')
487
 
        self.assertEqual(('location3', b'file-id'),
488
 
                         branch.get_reference_info('path3'))
 
487
        doppelganger.set_reference_info('file-id', 'path3', 'location3')
 
488
        self.assertEqual(('path3', 'location3'),
 
489
                         branch.get_reference_info('file-id'))
489
490
 
490
491
    def _recordParentMapCalls(self, repo):
491
492
        self._parent_map_calls = []