Rev 2246: Move KnitFormat2 into repofmt in file:///home/mbp/bzr/Work/repoformats/
Martin Pool
mbp at sourcefrog.net
Tue Feb 6 08:16:14 GMT 2007
------------------------------------------------------------
revno: 2246
revision-id: mbp at sourcefrog.net-20070206081613-dxop566k13bll6j0
parent: mbp at sourcefrog.net-20070206062724-a5uo1u27jxsal2t0
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: repoformats
timestamp: Tue 2007-02-06 19:16:13 +1100
message:
Move KnitFormat2 into repofmt
added:
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
modified:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/test_bundle.py test.py-20050630184834-092aa401ab9f039c
bzrlib/tests/test_bzrdir.py test_bzrdir.py-20060131065654-deba40eef51cf220
bzrlib/tests/test_fetch.py testfetch.py-20050825090644-f73e07e7dfb1765a
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
=== added file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/repofmt/knitrepo.py 2007-02-06 08:16:13 +0000
@@ -0,0 +1,137 @@
+# Copyright (C) 2005, 2006, 2007 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+from bzrlib import (
+ errors,
+ lockable_files,
+ lockdir,
+ xml6,
+ )
+
+from bzrlib.repository import (
+ KnitRepository,
+ RepositoryFormat,
+ RepositoryFormatKnit,
+ RootCommitBuilder,
+ )
+
+
+class KnitRepository2(KnitRepository):
+ """"""
+ def __init__(self, _format, a_bzrdir, control_files, _revision_store,
+ control_store, text_store):
+ KnitRepository.__init__(self, _format, a_bzrdir, control_files,
+ _revision_store, control_store, text_store)
+ self._serializer = xml6.serializer_v6
+
+ def deserialise_inventory(self, revision_id, xml):
+ """Transform the xml into an inventory object.
+
+ :param revision_id: The expected revision id of the inventory.
+ :param xml: A serialised inventory.
+ """
+ result = self._serializer.read_inventory_from_string(xml)
+ assert result.root.revision is not None
+ return result
+
+ def serialise_inventory(self, inv):
+ """Transform the inventory object into XML text.
+
+ :param revision_id: The expected revision id of the inventory.
+ :param xml: A serialised inventory.
+ """
+ assert inv.revision_id is not None
+ assert inv.root.revision is not None
+ return KnitRepository.serialise_inventory(self, inv)
+
+ def get_commit_builder(self, branch, parents, config, timestamp=None,
+ timezone=None, committer=None, revprops=None,
+ revision_id=None):
+ """Obtain a CommitBuilder for this repository.
+
+ :param branch: Branch to commit to.
+ :param parents: Revision ids of the parents of the new revision.
+ :param config: Configuration to use.
+ :param timestamp: Optional timestamp recorded for commit.
+ :param timezone: Optional timezone for timestamp.
+ :param committer: Optional committer to set for commit.
+ :param revprops: Optional dictionary of revision properties.
+ :param revision_id: Optional revision id.
+ """
+ return RootCommitBuilder(self, parents, config, timestamp, timezone,
+ committer, revprops, revision_id)
+
+
+class RepositoryFormatKnit2(RepositoryFormatKnit):
+ """Bzr repository knit format 2.
+
+ THIS FORMAT IS EXPERIMENTAL
+ This repository format has:
+ - knits for file texts and inventory
+ - hash subdirectory based stores.
+ - knits for revisions and signatures
+ - TextStores for revisions and signatures.
+ - a format marker of its own
+ - an optional 'shared-storage' flag
+ - an optional 'no-working-trees' flag
+ - a LockDir lock
+ - Support for recording full info about the tree root
+
+ """
+
+ rich_root_data = True
+
+ def get_format_string(self):
+ """See RepositoryFormat.get_format_string()."""
+ return "Bazaar Knit Repository Format 2\n"
+
+ def get_format_description(self):
+ """See RepositoryFormat.get_format_description()."""
+ return "Knit repository format 2"
+
+ def check_conversion_target(self, target_format):
+ if not target_format.rich_root_data:
+ raise errors.BadConversionTarget(
+ 'Does not support rich root data.', target_format)
+
+ def open(self, a_bzrdir, _found=False, _override_transport=None):
+ """See RepositoryFormat.open().
+
+ :param _override_transport: INTERNAL USE ONLY. Allows opening the
+ repository at a slightly different url
+ than normal. I.e. during 'upgrade'.
+ """
+ if not _found:
+ format = RepositoryFormat.find_format(a_bzrdir)
+ assert format.__class__ == self.__class__
+ if _override_transport is not None:
+ repo_transport = _override_transport
+ else:
+ repo_transport = a_bzrdir.get_repository_transport(None)
+ control_files = lockable_files.LockableFiles(repo_transport, 'lock',
+ lockdir.LockDir)
+ text_store = self._get_text_store(repo_transport, control_files)
+ control_store = self._get_control_store(repo_transport, control_files)
+ _revision_store = self._get_revision_store(repo_transport, control_files)
+ return KnitRepository2(_format=self,
+ a_bzrdir=a_bzrdir,
+ control_files=control_files,
+ _revision_store=_revision_store,
+ control_store=control_store,
+ text_store=text_store)
+
+
+RepositoryFormatKnit2_instance = RepositoryFormatKnit2()
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2007-02-06 06:27:24 +0000
+++ b/bzrlib/bzrdir.py 2007-02-06 08:16:13 +0000
@@ -2111,5 +2111,7 @@
'Transitional format in 0.8. Slower than knit.',
deprecated=True,
repo_module='bzrlib.repofmt.weaverepo')
-format_registry.register_metadir('experimental-knit2', 'RepositoryFormatKnit2',
- 'Experimental successor to knit. Use at your own risk.')
+format_registry.register_metadir('experimental-knit2',
+ 'RepositoryFormatKnit2',
+ 'Experimental successor to knit. Use at your own risk.',
+ repo_module='bzrlib.repofmt.knitrepo')
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-02-06 06:27:24 +0000
+++ b/bzrlib/repository.py 2007-02-06 08:16:13 +0000
@@ -1018,52 +1018,6 @@
return self._get_revision_vf().get_parents(revision_id)
-class KnitRepository2(KnitRepository):
- """"""
- def __init__(self, _format, a_bzrdir, control_files, _revision_store,
- control_store, text_store):
- KnitRepository.__init__(self, _format, a_bzrdir, control_files,
- _revision_store, control_store, text_store)
- self._serializer = xml6.serializer_v6
-
- def deserialise_inventory(self, revision_id, xml):
- """Transform the xml into an inventory object.
-
- :param revision_id: The expected revision id of the inventory.
- :param xml: A serialised inventory.
- """
- result = self._serializer.read_inventory_from_string(xml)
- assert result.root.revision is not None
- return result
-
- def serialise_inventory(self, inv):
- """Transform the inventory object into XML text.
-
- :param revision_id: The expected revision id of the inventory.
- :param xml: A serialised inventory.
- """
- assert inv.revision_id is not None
- assert inv.root.revision is not None
- return KnitRepository.serialise_inventory(self, inv)
-
- def get_commit_builder(self, branch, parents, config, timestamp=None,
- timezone=None, committer=None, revprops=None,
- revision_id=None):
- """Obtain a CommitBuilder for this repository.
-
- :param branch: Branch to commit to.
- :param parents: Revision ids of the parents of the new revision.
- :param config: Configuration to use.
- :param timestamp: Optional timestamp recorded for commit.
- :param timezone: Optional timezone for timestamp.
- :param committer: Optional committer to set for commit.
- :param revprops: Optional dictionary of revision properties.
- :param revision_id: Optional revision id.
- """
- return RootCommitBuilder(self, parents, config, timestamp, timezone,
- committer, revprops, revision_id)
-
-
class RepositoryFormatRegistry(registry.Registry):
"""Registry of RepositoryFormats.
"""
@@ -1405,65 +1359,6 @@
pass
-class RepositoryFormatKnit2(RepositoryFormatKnit):
- """Bzr repository knit format 2.
-
- THIS FORMAT IS EXPERIMENTAL
- This repository format has:
- - knits for file texts and inventory
- - hash subdirectory based stores.
- - knits for revisions and signatures
- - TextStores for revisions and signatures.
- - a format marker of its own
- - an optional 'shared-storage' flag
- - an optional 'no-working-trees' flag
- - a LockDir lock
- - Support for recording full info about the tree root
-
- """
-
- rich_root_data = True
-
- def get_format_string(self):
- """See RepositoryFormat.get_format_string()."""
- return "Bazaar Knit Repository Format 2\n"
-
- def get_format_description(self):
- """See RepositoryFormat.get_format_description()."""
- return "Knit repository format 2"
-
- def check_conversion_target(self, target_format):
- if not target_format.rich_root_data:
- raise errors.BadConversionTarget(
- 'Does not support rich root data.', target_format)
-
- def open(self, a_bzrdir, _found=False, _override_transport=None):
- """See RepositoryFormat.open().
-
- :param _override_transport: INTERNAL USE ONLY. Allows opening the
- repository at a slightly different url
- than normal. I.e. during 'upgrade'.
- """
- if not _found:
- format = RepositoryFormat.find_format(a_bzrdir)
- assert format.__class__ == self.__class__
- if _override_transport is not None:
- repo_transport = _override_transport
- else:
- repo_transport = a_bzrdir.get_repository_transport(None)
- control_files = lockable_files.LockableFiles(repo_transport, 'lock',
- lockdir.LockDir)
- text_store = self._get_text_store(repo_transport, control_files)
- control_store = self._get_control_store(repo_transport, control_files)
- _revision_store = self._get_revision_store(repo_transport, control_files)
- return KnitRepository2(_format=self,
- a_bzrdir=a_bzrdir,
- control_files=control_files,
- _revision_store=_revision_store,
- control_store=control_store,
- text_store=text_store)
-
-
# formats which have no format string are not discoverable
# and not independently creatable, so are not registered. They're
# all in bzrlib.repofmt.weaverepo now.
@@ -1476,7 +1371,11 @@
# default control directory format
_default_format = RepositoryFormatKnit1()
RepositoryFormat.register_format(_default_format)
-RepositoryFormat.register_format(RepositoryFormatKnit2())
+format_registry.register_lazy(
+ 'Bazaar Knit Repository Format 2\n',
+ 'bzrlib.repofmt.knitrepo',
+ 'RepositoryFormatKnit2_instance',
+ )
RepositoryFormat._set_default_format(_default_format)
@@ -1715,6 +1614,7 @@
@staticmethod
def is_compatible(source, target):
"""Be compatible with Knit1 source and Knit2 target"""
+ from bzrlib.repofmt.knitrepo import RepositoryFormatKnit2
try:
return (isinstance(source._format, (RepositoryFormatKnit1)) and
isinstance(target._format, (RepositoryFormatKnit2)))
@@ -1804,7 +1704,7 @@
@staticmethod
def default_test_list():
"""Generate the default list of interrepo permutations to test."""
- from bzrlib.repofmt import weaverepo
+ from bzrlib.repofmt import knitrepo, weaverepo
result = []
# test the default InterRepository between format 6 and the current
# default format.
@@ -1823,9 +1723,9 @@
# here.
result.append((InterModel1and2,
weaverepo.RepositoryFormat5(),
- RepositoryFormatKnit2()))
+ knitrepo.RepositoryFormatKnit2()))
result.append((InterKnit1and2, RepositoryFormatKnit1(),
- RepositoryFormatKnit2()))
+ knitrepo.RepositoryFormatKnit2()))
return result
=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py 2007-02-06 06:27:24 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py 2007-02-06 08:16:13 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,7 +21,12 @@
import sys
import bzrlib
-from bzrlib import bzrdir, errors, repository
+from bzrlib import (
+ bzrdir,
+ errors,
+ repository,
+ transactions,
+ )
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
from bzrlib.delta import TreeDelta
from bzrlib.errors import (FileExists,
@@ -32,10 +37,10 @@
)
from bzrlib.inventory import Inventory, InventoryDirectory
from bzrlib.revision import NULL_REVISION
+from bzrlib.repofmt import knitrepo
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
from bzrlib.trace import mutter
-import bzrlib.transactions as transactions
from bzrlib.transport import get_transport
from bzrlib.upgrade import upgrade
from bzrlib.workingtree import WorkingTree
@@ -190,7 +195,7 @@
tree_a.commit('rev1', rev_id='rev1')
# fetch with a default limit (grab everything)
f = bzrdir.BzrDirMetaFormat1()
- f._repository_format = repository.RepositoryFormatKnit2()
+ f._repository_format = knitrepo.RepositoryFormatKnit2()
os.mkdir('b')
b_bzrdir = f.initialize(self.get_url('b'))
repo = b_bzrdir.create_repository()
=== modified file 'bzrlib/tests/test_bundle.py'
--- a/bzrlib/tests/test_bundle.py 2006-11-02 10:20:19 +0000
+++ b/bzrlib/tests/test_bundle.py 2007-02-06 08:16:13 +0000
@@ -38,6 +38,7 @@
from bzrlib.errors import (BzrError, TestamentMismatch, NotABundle, BadBundle,
NoSuchFile,)
from bzrlib.merge import Merge3Merger
+from bzrlib.repofmt import knitrepo
from bzrlib.osutils import has_symlinks, sha_file
from bzrlib.tests import (TestCaseInTempDir, TestCaseWithTransport,
TestCase, TestSkipped)
@@ -313,7 +314,7 @@
def test_mismatched_bundle(self):
format = bzrdir.BzrDirMetaFormat1()
- format.repository_format = repository.RepositoryFormatKnit2()
+ format.repository_format = knitrepo.RepositoryFormatKnit2()
serializer = BundleSerializerV08('0.8')
b = self.make_branch('.', format=format)
self.assertRaises(errors.IncompatibleBundleFormat, serializer.write,
@@ -322,7 +323,7 @@
def test_matched_bundle(self):
"""Don't raise IncompatibleBundleFormat for knit2 and bundle0.9"""
format = bzrdir.BzrDirMetaFormat1()
- format.repository_format = repository.RepositoryFormatKnit2()
+ format.repository_format = knitrepo.RepositoryFormatKnit2()
serializer = BundleSerializerV09('0.9')
b = self.make_branch('.', format=format)
serializer.write(b.repository, [], {}, StringIO())
@@ -330,7 +331,7 @@
def test_mismatched_model(self):
"""Try copying a bundle from knit2 to knit1"""
format = bzrdir.BzrDirMetaFormat1()
- format.repository_format = repository.RepositoryFormatKnit2()
+ format.repository_format = knitrepo.RepositoryFormatKnit2()
source = self.make_branch_and_tree('source', format=format)
source.commit('one', rev_id='one-id')
source.commit('two', rev_id='two-id')
@@ -890,7 +891,7 @@
def bzrdir_format(self):
format = bzrdir.BzrDirMetaFormat1()
- format.repository_format = repository.RepositoryFormatKnit2()
+ format.repository_format = knitrepo.RepositoryFormatKnit2()
return format
=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py 2007-02-06 06:27:24 +0000
+++ b/bzrlib/tests/test_bzrdir.py 2007-02-06 08:16:13 +0000
@@ -40,7 +40,7 @@
from bzrlib.tests.HttpServer import HttpServer
from bzrlib.transport import get_transport
from bzrlib.transport.memory import MemoryServer
-from bzrlib.repofmt import weaverepo
+from bzrlib.repofmt import knitrepo, weaverepo
class TestDefaultFormat(TestCase):
@@ -126,7 +126,7 @@
bzrdir.format_registry.get('default'))
self.assertIs(
repository.RepositoryFormat.get_default_format().__class__,
- repository.RepositoryFormatKnit2)
+ knitrepo.RepositoryFormatKnit2)
finally:
bzrdir.format_registry.set_default_repository(old_default)
=== modified file 'bzrlib/tests/test_fetch.py'
--- a/bzrlib/tests/test_fetch.py 2006-11-08 07:44:30 +0000
+++ b/bzrlib/tests/test_fetch.py 2007-02-06 08:16:13 +0000
@@ -23,6 +23,7 @@
from bzrlib.bzrdir import BzrDir
from bzrlib.builtins import merge
import bzrlib.errors
+from bzrlib.repofmt import knitrepo
from bzrlib.tests import TestCaseWithTransport
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
from bzrlib.tests.test_revision import make_branches
@@ -125,7 +126,7 @@
knit1_format = bzrdir.BzrDirMetaFormat1()
knit1_format.repository_format = repository.RepositoryFormatKnit1()
knit2_format = bzrdir.BzrDirMetaFormat1()
- knit2_format.repository_format = repository.RepositoryFormatKnit2()
+ knit2_format.repository_format = knitrepo.RepositoryFormatKnit2()
# we start with a knit1 repository because that causes the
# root revision to change for each commit, even though the content,
# parent, name, and other attributes are unchanged.
=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py 2007-02-06 06:27:24 +0000
+++ b/bzrlib/tests/test_repository.py 2007-02-06 08:16:13 +0000
@@ -43,7 +43,7 @@
upgrade,
workingtree,
)
-from bzrlib.repofmt import weaverepo
+from bzrlib.repofmt import knitrepo, weaverepo
class TestDefaultFormat(TestCase):
@@ -432,7 +432,7 @@
self.assertRaises(errors.NoSuchFile, revision_tree.get_file_lines,
revision_tree.inventory.root.file_id)
format = bzrdir.BzrDirMetaFormat1()
- format.repository_format = repository.RepositoryFormatKnit2()
+ format.repository_format = knitrepo.RepositoryFormatKnit2()
upgrade.Convert('.', format)
tree = workingtree.WorkingTree.open('.')
revision_tree = tree.branch.repository.revision_tree('dull')
More information about the bazaar-commits
mailing list