Exemple #1
0
 def test_is_compatible_and_registered(self):
     # InterWeaveRepo is compatible when either side
     # is a format 5/6/7 branch
     from bzrlib.repofmt import knitrepo, weaverepo
     formats = [weaverepo.RepositoryFormat5(),
                weaverepo.RepositoryFormat6(),
                weaverepo.RepositoryFormat7()]
     incompatible_formats = [weaverepo.RepositoryFormat4(),
                             knitrepo.RepositoryFormatKnit1(),
                             ]
     repo_a = self.make_repository('a')
     repo_b = self.make_repository('b')
     is_compatible = repository.InterWeaveRepo.is_compatible
     for source in incompatible_formats:
         # force incompatible left then right
         repo_a._format = source
         repo_b._format = formats[0]
         self.assertFalse(is_compatible(repo_a, repo_b))
         self.assertFalse(is_compatible(repo_b, repo_a))
     for source in formats:
         repo_a._format = source
         for target in formats:
             repo_b._format = target
             self.assertTrue(is_compatible(repo_a, repo_b))
     self.assertEqual(repository.InterWeaveRepo,
                      repository.InterRepository.get(repo_a,
                                                     repo_b).__class__)
Exemple #2
0
 def test_shared_no_tree_disk_layout(self):
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
     repo.set_make_working_trees(False)
     # we want:
     # format 'Bazaar-NG Repository format 7'
     # lock ''
     # inventory.weave == empty_weave
     # empty revision-store directory
     # empty weaves directory
     # a 'shared-storage' marker file.
     t = control.get_repository_transport(None)
     self.assertEqualDiff('Bazaar-NG Repository format 7',
                          t.get('format').read())
     ## self.assertEqualDiff('', t.get('lock').read())
     self.assertEqualDiff('', t.get('shared-storage').read())
     self.assertEqualDiff('', t.get('no-working-trees').read())
     repo.set_make_working_trees(True)
     self.assertFalse(t.has('no-working-trees'))
     self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
     self.assertTrue(S_ISDIR(t.stat('weaves').st_mode))
     self.assertEqualDiff('# bzr weave file v5\n'
                          'w\n'
                          'W\n',
                          t.get('inventory.weave').read())
Exemple #3
0
 def test_find_format(self):
     # is the right format object found for a repository?
     # create a branch with a few known format objects.
     # this is not quite the same as 
     self.build_tree(["foo/", "bar/"])
     def check_format(format, url):
         dir = format._matchingbzrdir.initialize(url)
         format.initialize(dir)
         t = get_transport(url)
         found_format = repository.RepositoryFormat.find_format(dir)
         self.failUnless(isinstance(found_format, format.__class__))
     check_format(weaverepo.RepositoryFormat7(), "bar")
Exemple #4
0
 def test_convert_empty(self):
     t = get_transport(self.get_url('.'))
     t.mkdir('repository')
     repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository')
     repo = weaverepo.RepositoryFormat7().initialize(repo_dir)
     target_format = knitrepo.RepositoryFormatKnit1()
     converter = repository.CopyConverter(target_format)
     pb = bzrlib.ui.ui_factory.nested_progress_bar()
     try:
         converter.convert(repo, pb)
     finally:
         pb.finished()
     repo = repo_dir.open_repository()
     self.assertTrue(isinstance(target_format, repo._format.__class__))
Exemple #5
0
 def test_creates_lockdir(self):
     """Make sure it appears to be controlled by a LockDir existence"""
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
     t = control.get_repository_transport(None)
     # TODO: Should check there is a 'lock' toplevel directory, 
     # regardless of contents
     self.assertFalse(t.has('lock/held/info'))
     repo.lock_write()
     try:
         self.assertTrue(t.has('lock/held/info'))
     finally:
         # unlock so we don't get a warning about failing to do so
         repo.unlock()
Exemple #6
0
 def test_uses_lockdir(self):
     """repo format 7 actually locks on lockdir"""
     base_url = self.get_url()
     control = bzrdir.BzrDirMetaFormat1().initialize(base_url)
     repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
     t = control.get_repository_transport(None)
     repo.lock_write()
     repo.unlock()
     del repo
     # make sure the same lock is created by opening it
     repo = repository.Repository.open(base_url)
     repo.lock_write()
     self.assertTrue(t.has('lock/held/info'))
     repo.unlock()
     self.assertFalse(t.has('lock/held/info'))
Exemple #7
0
 def test_disk_layout(self):
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = weaverepo.RepositoryFormat7().initialize(control)
     # in case of side effects of locking.
     repo.lock_write()
     repo.unlock()
     # we want:
     # format 'Bazaar-NG Repository format 7'
     # lock ''
     # inventory.weave == empty_weave
     # empty revision-store directory
     # empty weaves directory
     t = control.get_repository_transport(None)
     self.assertEqualDiff('Bazaar-NG Repository format 7',
                          t.get('format').read())
     self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
     self.assertTrue(S_ISDIR(t.stat('weaves').st_mode))
     self.assertEqualDiff('# bzr weave file v5\n'
                          'w\n'
                          'W\n',
                          t.get('inventory.weave').read())
     # Creating a file with id Foo:Bar results in a non-escaped file name on
     # disk.
     control.create_branch()
     tree = control.create_workingtree()
     tree.add(['foo'], ['Foo:Bar'], ['file'])
     tree.put_file_bytes_non_atomic('Foo:Bar', 'content\n')
     tree.commit('first post', rev_id='first')
     self.assertEqualDiff(
         '# bzr weave file v5\n'
         'i\n'
         '1 7fe70820e08a1aac0ef224d9c66ab66831cc4ab1\n'
         'n first\n'
         '\n'
         'w\n'
         '{ 0\n'
         '. content\n'
         '}\n'
         'W\n',
         t.get('weaves/74/Foo%3ABar.weave').read())
Exemple #8
0
 def test_supports_external_lookups(self):
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = weaverepo.RepositoryFormat7().initialize(control)
     self.assertFalse(repo._format.supports_external_lookups)
Exemple #9
0
 def test_attribute__fetch_reconcile(self):
     """Weave repositories need a reconcile after fetch."""
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = weaverepo.RepositoryFormat7().initialize(control)
     self.assertEqual(True, repo._fetch_reconcile)
Exemple #10
0
 def test_attribute__fetch_uses_deltas(self):
     """Weaves do not reuse deltas."""
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = weaverepo.RepositoryFormat7().initialize(control)
     self.assertEqual(False, repo._fetch_uses_deltas)
Exemple #11
0
 def test_attribute__fetch_order(self):
     """Weaves need topological data insertion."""
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = weaverepo.RepositoryFormat7().initialize(control)
     self.assertEqual('topological', repo._fetch_order)