def test_upgrade_v6_to_meta_no_workingtree(self): # Some format6 branches do not have checkout files. Upgrading # such a branch to metadir must not setup a working tree. self.build_tree_contents(_upgrade1_template) upgrade('.', bzrdir.BzrDirFormat6()) transport = get_transport('.') transport.delete_multi(['.bzr/pending-merges', '.bzr/inventory']) self.assertFalse(transport.has('.bzr/stat-cache')) # XXX: upgrade fails if a backup.bzr is already present # -- David Allouche 2006-08-11 transport.delete_tree('backup.bzr') # At this point, we have a format6 branch without checkout files. upgrade('.', bzrdir.BzrDirMetaFormat1()) # The upgrade should not have set up a working tree. control = bzrdir.BzrDir.open('.') self.assertFalse(control.has_workingtree()) # We have covered the scope of this test, we may as well check that # upgrade has not eaten our data, even if it's a bit redundant with # other tests. self.failUnless(isinstance(control._format, bzrdir.BzrDirMetaFormat1)) branch = control.open_branch() self.assertEquals(branch.revision_history(), [ '[email protected]', '[email protected]' ])
def test_no_ancestry_weave(self): control = bzrdir.BzrDirFormat6().initialize(self.get_url()) repo = weaverepo.RepositoryFormat6().initialize(control) # We no longer need to create the ancestry.weave file # since it is *never* used. self.assertRaises(NoSuchFile, control.transport.get, 'ancestry.weave')
def test_lock_file(self): # old format branches use a special lock file on sftp. b = self.make_branch('', format=bzrdir.BzrDirFormat6()) b = bzrlib.branch.Branch.open(self.get_url()) self.failUnlessExists('.bzr/') self.failUnlessExists('.bzr/branch-format') self.failUnlessExists('.bzr/branch-lock') self.failIf(lexists('.bzr/branch-lock.write-lock')) b.lock_write() self.failUnlessExists('.bzr/branch-lock.write-lock') b.unlock() self.failIf(lexists('.bzr/branch-lock.write-lock'))
class RepositoryFormat6(PreSplitOutRepositoryFormat): """Bzr control format 6. This repository format has: - weaves for file texts and inventory - hash subdirectory based stores. - TextStores for revisions and signatures. """ _versionedfile_class = weave.WeaveFile _matchingbzrdir = bzrdir.BzrDirFormat6() def __init__(self): super(RepositoryFormat6, self).__init__() self._fetch_order = 'topological' self._fetch_reconcile = True def get_format_description(self): """See RepositoryFormat.get_format_description().""" return "Weave repository format 6" def _get_inventories(self, repo_transport, repo, name='inventory'): mapper = versionedfile.ConstantMapper(name) return versionedfile.ThunkedVersionedFiles(repo_transport, weave.WeaveFile, mapper, repo.is_locked) def _get_revisions(self, repo_transport, repo): from bzrlib.xml5 import serializer_v5 return RevisionTextStore(repo_transport.clone('revision-store'), serializer_v5, False, versionedfile.HashPrefixMapper(), repo.is_locked, repo.is_write_locked) def _get_signatures(self, repo_transport, repo): return SignatureTextStore(repo_transport.clone('revision-store'), False, versionedfile.HashPrefixMapper(), repo.is_locked, repo.is_write_locked) def _get_texts(self, repo_transport, repo): mapper = versionedfile.HashPrefixMapper() base_transport = repo_transport.clone('weaves') return versionedfile.ThunkedVersionedFiles(base_transport, weave.WeaveFile, mapper, repo.is_locked)
def test_conflicts(self): """Conflicts are detected properly""" tree = self.make_branch_and_tree('.', format=bzrdir.BzrDirFormat6()) b = tree.branch file('hello', 'w').write('hello world4') file('hello.THIS', 'w').write('hello world2') file('hello.BASE', 'w').write('hello world1') file('hello.OTHER', 'w').write('hello world3') file('hello.sploo.BASE', 'w').write('yellow world') file('hello.sploo.OTHER', 'w').write('yellow world2') tree.lock_read() self.assertEqual(len(list(tree.list_files())), 6) tree.unlock() conflicts = tree.conflicts() self.assertEqual(len(conflicts), 2) self.assert_('hello' in conflicts[0].path) self.assert_('hello.sploo' in conflicts[1].path) restore('hello') restore('hello.sploo') self.assertEqual(len(tree.conflicts()), 0) self.assertFileEqual('hello world2', 'hello') self.assertFalse(os.path.lexists('hello.sploo')) self.assertRaises(NotConflicted, restore, 'hello') self.assertRaises(NotConflicted, restore, 'hello.sploo')
def test_info_locking_oslocks(self): if sys.platform == "win32": raise TestSkipped("don't use oslocks on win32 in unix manner") tree = self.make_branch_and_tree('branch', format=bzrdir.BzrDirFormat6()) # Test all permutations of locking the working tree, branch and repository # XXX: Well not yet, as we can't query oslocks yet. Currently, it's # implemented by raising NotImplementedError and get_physical_lock_status() # always returns false. This makes bzr info hide the lock status. (Olaf) # W B R # U U U out, err = self.run_bzr('info -v branch') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: %s Format: control: All-in-one format 6 working tree: Working tree format 2 branch: Branch format 4 repository: %s In the working tree: 0 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions 0 committers Repository: 0 revisions """ % ('branch', tree.branch.repository._format.get_format_description(), ), out) self.assertEqual('', err) # L L L tree.lock_write() out, err = self.run_bzr('info -v branch') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: %s Format: control: All-in-one format 6 working tree: Working tree format 2 branch: Branch format 4 repository: %s In the working tree: 0 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions 0 committers Repository: 0 revisions """ % ('branch', tree.branch.repository._format.get_format_description(), ), out) self.assertEqual('', err) tree.unlock()
def create_format2_tree(self, url): return self.make_branch_and_tree(url, format=bzrdir.BzrDirFormat6())
def test_supports_external_lookups(self): control = bzrdir.BzrDirFormat6().initialize(self.get_url()) repo = weaverepo.RepositoryFormat6().initialize(control) self.assertFalse(repo._format.supports_external_lookups)
def test_attribute__fetch_reconcile(self): """Weave repositories need a reconcile after fetch.""" control = bzrdir.BzrDirFormat6().initialize(self.get_url()) repo = weaverepo.RepositoryFormat6().initialize(control) self.assertEqual(True, repo._fetch_reconcile)
def test_attribute__fetch_uses_deltas(self): """Weaves do not reuse deltas.""" control = bzrdir.BzrDirFormat6().initialize(self.get_url()) repo = weaverepo.RepositoryFormat6().initialize(control) self.assertEqual(False, repo._fetch_uses_deltas)
def test_attribute__fetch_order(self): """Weaves need topological data insertion.""" control = bzrdir.BzrDirFormat6().initialize(self.get_url()) repo = weaverepo.RepositoryFormat6().initialize(control) self.assertEqual('topological', repo._fetch_order)