769
769
self.get_transport('').rename('fallback', 'moved')
770
770
reopened = stacked.bzrdir.open_branch(ignore_fallbacks=True)
771
771
self.assertEqual([], reopened.repository._fallback_repositories)
773
773
def test_fallbacks_are_opened(self):
774
774
stacked = self.make_branch_with_fallback()
775
775
reopened = stacked.bzrdir.open_branch(ignore_fallbacks=False)
776
776
self.assertLength(1, reopened.repository._fallback_repositories)
779
class TestReferenceLocation(TestCaseWithBranch):
781
def test_reference_parent(self):
782
tree = self.make_branch_and_tree('tree')
783
subtree = self.make_branch_and_tree('tree/subtree')
784
subtree.set_root_id('subtree-id')
786
tree.add_reference(subtree)
787
except bzrlib.errors.UnsupportedOperation:
788
raise tests.TestNotApplicable('Tree cannot hold references.')
789
reference_parent = tree.branch.reference_parent('subtree-id',
791
self.assertEqual(subtree.branch.base, reference_parent.base)
793
def test_get_reference_info(self):
794
branch = self.make_branch('branch')
796
path, loc = branch.get_reference_info('file-id')
797
except bzrlib.errors.UnsupportedOperation:
798
raise tests.TestNotApplicable('Branch cannot hold references.')
799
self.assertIs(None, path)
800
self.assertIs(None, loc)
802
def test_set_reference_info(self):
803
branch = self.make_branch('branch')
805
branch.set_reference_info('file-id', 'path/to/location',
807
except bzrlib.errors.UnsupportedOperation:
808
raise tests.TestNotApplicable('Branch cannot hold references.')
810
def test_set_get_reference_info(self):
811
branch = self.make_branch('branch')
813
branch.set_reference_info('file-id', 'path/to/file',
815
except bzrlib.errors.UnsupportedOperation:
816
raise tests.TestNotApplicable('Branch cannot hold references.')
817
# Create a new instance to ensure storage is permanent
818
branch = Branch.open('branch')
819
tree_path, branch_location = branch.get_reference_info('file-id')
820
self.assertEqual('path/to/location', branch_location)
822
def test_set_null_reference_info(self):
823
branch = self.make_branch('branch')
825
branch.set_reference_info('file-id', 'path/to/file',
827
except bzrlib.errors.UnsupportedOperation:
828
raise tests.TestNotApplicable('Branch cannot hold references.')
829
branch.set_reference_info('file-id', None, None)
830
tree_path, branch_location = branch.get_reference_info('file-id')
831
self.assertIs(None, tree_path)
832
self.assertIs(None, branch_location)
834
def test_set_null_reference_info_when_null(self):
835
branch = self.make_branch('branch')
837
tree_path, branch_location = branch.get_reference_info('file-id')
838
except bzrlib.errors.UnsupportedOperation:
839
raise tests.TestNotApplicable('Branch cannot hold references.')
840
self.assertIs(None, tree_path)
841
self.assertIs(None, branch_location)
842
branch.set_reference_info('file-id', None, None)
844
def test_set_null_requires_two_nones(self):
845
branch = self.make_branch('branch')
847
e = self.assertRaises(ValueError, branch.set_reference_info,
848
'file-id', 'path', None)
849
except bzrlib.errors.UnsupportedOperation:
850
raise tests.TestNotApplicable('Branch cannot hold references.')
851
self.assertEqual('tree_path must be None when branch_location is'
853
e = self.assertRaises(ValueError, branch.set_reference_info,
854
'file-id', None, 'location')
855
self.assertEqual('branch_location must be None when tree_path is'