Rev 2247: Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and in file:///home/mbp/bzr/Work/repoformats/
Martin Pool
mbp at sourcefrog.net
Wed Feb 7 09:11:32 GMT 2007
------------------------------------------------------------
revno: 2247
revision-id: mbp at sourcefrog.net-20070207091131-458fw18bgytvaz7t
parent: mbp at sourcefrog.net-20070206081613-dxop566k13bll6j0
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: repoformats
timestamp: Wed 2007-02-07 20:11:31 +1100
message:
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and
lazily load from the registry.
InterRepo._matching_repo_format is now a method not a class field so that
it can load repositories when we need them.
modified:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/blackbox/test_upgrade.py test_upgrade.py-20060120060132-b41e5ed2f886ad28
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_options.py testoptions.py-20051014093702-96457cfc86319a8f
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2007-02-06 08:16:13 +0000
+++ b/bzrlib/bzrdir.py 2007-02-07 09:11:31 +0000
@@ -2103,9 +2103,12 @@
format_registry = BzrDirFormatRegistry()
format_registry.register('weave', BzrDirFormat6,
'Pre-0.8 format. Slower than knit and does not'
- ' support checkouts or shared repositories.', deprecated=True)
-format_registry.register_metadir('knit', 'RepositoryFormatKnit1',
- 'Format using knits. Recommended.')
+ ' support checkouts or shared repositories.',
+ deprecated=True)
+format_registry.register_metadir('knit',
+ 'RepositoryFormatKnit1',
+ 'Format using knits. Recommended.',
+ repo_module='bzrlib.repofmt.knitrepo')
format_registry.set_default('knit')
format_registry.register_metadir('metaweave', 'RepositoryFormat7',
'Transitional format in 0.8. Slower than knit.',
=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py 2007-02-06 08:16:13 +0000
+++ b/bzrlib/repofmt/knitrepo.py 2007-02-07 09:11:31 +0000
@@ -16,17 +16,173 @@
from bzrlib import (
errors,
+ graph,
+ knit,
lockable_files,
lockdir,
+ transactions,
xml6,
)
+from bzrlib.decorators import needs_read_lock, needs_write_lock
from bzrlib.repository import (
- KnitRepository,
+ MetaDirRepository,
+ MetaDirRepositoryFormat,
RepositoryFormat,
- RepositoryFormatKnit,
RootCommitBuilder,
)
+import bzrlib.revision as _mod_revision
+from bzrlib.store.versioned import VersionedFileStore
+from bzrlib.trace import mutter, note, warning
+
+
+class KnitRepository(MetaDirRepository):
+ """Knit format repository."""
+
+ def _warn_if_deprecated(self):
+ # This class isn't deprecated
+ pass
+
+ def _inventory_add_lines(self, inv_vf, revid, parents, lines):
+ inv_vf.add_lines_with_ghosts(revid, parents, lines)
+
+ @needs_read_lock
+ def _all_revision_ids(self):
+ """See Repository.all_revision_ids()."""
+ # Knits get the revision graph from the index of the revision knit, so
+ # it's always possible even if they're on an unlistable transport.
+ return self._revision_store.all_revision_ids(self.get_transaction())
+
+ def fileid_involved_between_revs(self, from_revid, to_revid):
+ """Find file_id(s) which are involved in the changes between revisions.
+
+ This determines the set of revisions which are involved, and then
+ finds all file ids affected by those revisions.
+ """
+ vf = self._get_revision_vf()
+ from_set = set(vf.get_ancestry(from_revid))
+ to_set = set(vf.get_ancestry(to_revid))
+ changed = to_set.difference(from_set)
+ return self._fileid_involved_by_set(changed)
+
+ def fileid_involved(self, last_revid=None):
+ """Find all file_ids modified in the ancestry of last_revid.
+
+ :param last_revid: If None, last_revision() will be used.
+ """
+ if not last_revid:
+ changed = set(self.all_revision_ids())
+ else:
+ changed = set(self.get_ancestry(last_revid))
+ if None in changed:
+ changed.remove(None)
+ return self._fileid_involved_by_set(changed)
+
+ @needs_read_lock
+ def get_ancestry(self, revision_id):
+ """Return a list of revision-ids integrated by a revision.
+
+ This is topologically sorted.
+ """
+ if revision_id is None:
+ return [None]
+ vf = self._get_revision_vf()
+ try:
+ return [None] + vf.get_ancestry(revision_id)
+ except errors.RevisionNotPresent:
+ raise errors.NoSuchRevision(self, revision_id)
+
+ @needs_read_lock
+ def get_revision(self, revision_id):
+ """Return the Revision object for a named revision"""
+ return self.get_revision_reconcile(revision_id)
+
+ @needs_read_lock
+ def get_revision_graph(self, revision_id=None):
+ """Return a dictionary containing the revision graph.
+
+ :param revision_id: The revision_id to get a graph from. If None, then
+ the entire revision graph is returned. This is a deprecated mode of
+ operation and will be removed in the future.
+ :return: a dictionary of revision_id->revision_parents_list.
+ """
+ # special case NULL_REVISION
+ if revision_id == _mod_revision.NULL_REVISION:
+ return {}
+ a_weave = self._get_revision_vf()
+ entire_graph = a_weave.get_graph()
+ if revision_id is None:
+ return a_weave.get_graph()
+ elif revision_id not in a_weave:
+ raise errors.NoSuchRevision(self, revision_id)
+ else:
+ # add what can be reached from revision_id
+ result = {}
+ pending = set([revision_id])
+ while len(pending) > 0:
+ node = pending.pop()
+ result[node] = a_weave.get_parents(node)
+ for revision_id in result[node]:
+ if revision_id not in result:
+ pending.add(revision_id)
+ return result
+
+ @needs_read_lock
+ def get_revision_graph_with_ghosts(self, revision_ids=None):
+ """Return a graph of the revisions with ghosts marked as applicable.
+
+ :param revision_ids: an iterable of revisions to graph or None for all.
+ :return: a Graph object with the graph reachable from revision_ids.
+ """
+ result = graph.Graph()
+ vf = self._get_revision_vf()
+ versions = set(vf.versions())
+ if not revision_ids:
+ pending = set(self.all_revision_ids())
+ required = set([])
+ else:
+ pending = set(revision_ids)
+ # special case NULL_REVISION
+ if _mod_revision.NULL_REVISION in pending:
+ pending.remove(_mod_revision.NULL_REVISION)
+ required = set(pending)
+ done = set([])
+ while len(pending):
+ revision_id = pending.pop()
+ if not revision_id in versions:
+ if revision_id in required:
+ raise errors.NoSuchRevision(self, revision_id)
+ # a ghost
+ result.add_ghost(revision_id)
+ # mark it as done so we don't try for it again.
+ done.add(revision_id)
+ continue
+ parent_ids = vf.get_parents_with_ghosts(revision_id)
+ for parent_id in parent_ids:
+ # is this queued or done ?
+ if (parent_id not in pending and
+ parent_id not in done):
+ # no, queue it.
+ pending.add(parent_id)
+ result.add_node(revision_id, parent_ids)
+ done.add(revision_id)
+ return result
+
+ def _get_revision_vf(self):
+ """:return: a versioned file containing the revisions."""
+ vf = self._revision_store.get_revision_file(self.get_transaction())
+ return vf
+
+ @needs_write_lock
+ def reconcile(self, other=None, thorough=False):
+ """Reconcile this repository."""
+ from bzrlib.reconcile import KnitReconciler
+ reconciler = KnitReconciler(self, thorough=thorough)
+ reconciler.reconcile()
+ return reconciler
+
+ def revision_parents(self, revision_id):
+ return self._get_revision_vf().get_parents(revision_id)
class KnitRepository2(KnitRepository):
@@ -75,6 +231,141 @@
committer, revprops, revision_id)
+class RepositoryFormatKnit(MetaDirRepositoryFormat):
+ """Bzr repository knit format (generalized).
+
+ 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
+ """
+
+ def _get_control_store(self, repo_transport, control_files):
+ """Return the control store for this repository."""
+ return VersionedFileStore(
+ repo_transport,
+ prefixed=False,
+ file_mode=control_files._file_mode,
+ versionedfile_class=knit.KnitVersionedFile,
+ versionedfile_kwargs={'factory':knit.KnitPlainFactory()},
+ )
+
+ def _get_revision_store(self, repo_transport, control_files):
+ """See RepositoryFormat._get_revision_store()."""
+ from bzrlib.store.revision.knit import KnitRevisionStore
+ versioned_file_store = VersionedFileStore(
+ repo_transport,
+ file_mode=control_files._file_mode,
+ prefixed=False,
+ precious=True,
+ versionedfile_class=knit.KnitVersionedFile,
+ versionedfile_kwargs={'delta':False,
+ 'factory':knit.KnitPlainFactory(),
+ },
+ escaped=True,
+ )
+ return KnitRevisionStore(versioned_file_store)
+
+ def _get_text_store(self, transport, control_files):
+ """See RepositoryFormat._get_text_store()."""
+ return self._get_versioned_file_store('knits',
+ transport,
+ control_files,
+ versionedfile_class=knit.KnitVersionedFile,
+ versionedfile_kwargs={
+ 'create_parent_dir':True,
+ 'delay_create':True,
+ 'dir_mode':control_files._dir_mode,
+ },
+ escaped=True)
+
+ def initialize(self, a_bzrdir, shared=False):
+ """Create a knit format 1 repository.
+
+ :param a_bzrdir: bzrdir to contain the new repository; must already
+ be initialized.
+ :param shared: If true the repository will be initialized as a shared
+ repository.
+ """
+ mutter('creating repository in %s.', a_bzrdir.transport.base)
+ dirs = ['revision-store', 'knits']
+ files = []
+ utf8_files = [('format', self.get_format_string())]
+
+ self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
+ repo_transport = a_bzrdir.get_repository_transport(None)
+ control_files = lockable_files.LockableFiles(repo_transport,
+ 'lock', lockdir.LockDir)
+ control_store = self._get_control_store(repo_transport, control_files)
+ transaction = transactions.WriteTransaction()
+ # trigger a write of the inventory store.
+ control_store.get_weave_or_empty('inventory', transaction)
+ _revision_store = self._get_revision_store(repo_transport, control_files)
+ # the revision id here is irrelevant: it will not be stored, and cannot
+ # already exist.
+ _revision_store.has_revision_id('A', transaction)
+ _revision_store.get_signature_file(transaction)
+ return self.open(a_bzrdir=a_bzrdir, _found=True)
+
+ 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 KnitRepository(_format=self,
+ a_bzrdir=a_bzrdir,
+ control_files=control_files,
+ _revision_store=_revision_store,
+ control_store=control_store,
+ text_store=text_store)
+
+
+class RepositoryFormatKnit1(RepositoryFormatKnit):
+ """Bzr repository knit format 1.
+
+ 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
+
+ This format was introduced in bzr 0.8.
+ """
+ def get_format_string(self):
+ """See RepositoryFormat.get_format_string()."""
+ return "Bazaar-NG Knit Repository Format 1"
+
+ def get_format_description(self):
+ """See RepositoryFormat.get_format_description()."""
+ return "Knit repository format 1"
+
+ def check_conversion_target(self, target_format):
+ pass
+
+
class RepositoryFormatKnit2(RepositoryFormatKnit):
"""Bzr repository knit format 2.
@@ -134,4 +425,5 @@
text_store=text_store)
+RepositoryFormatKnit1_instance = RepositoryFormatKnit1()
RepositoryFormatKnit2_instance = RepositoryFormatKnit2()
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-02-06 08:16:13 +0000
+++ b/bzrlib/repository.py 2007-02-07 09:11:31 +0000
@@ -869,155 +869,6 @@
return not self.control_files._transport.has('no-working-trees')
-class KnitRepository(MetaDirRepository):
- """Knit format repository."""
-
- def _warn_if_deprecated(self):
- # This class isn't deprecated
- pass
-
- def _inventory_add_lines(self, inv_vf, revid, parents, lines):
- inv_vf.add_lines_with_ghosts(revid, parents, lines)
-
- @needs_read_lock
- def _all_revision_ids(self):
- """See Repository.all_revision_ids()."""
- # Knits get the revision graph from the index of the revision knit, so
- # it's always possible even if they're on an unlistable transport.
- return self._revision_store.all_revision_ids(self.get_transaction())
-
- def fileid_involved_between_revs(self, from_revid, to_revid):
- """Find file_id(s) which are involved in the changes between revisions.
-
- This determines the set of revisions which are involved, and then
- finds all file ids affected by those revisions.
- """
- vf = self._get_revision_vf()
- from_set = set(vf.get_ancestry(from_revid))
- to_set = set(vf.get_ancestry(to_revid))
- changed = to_set.difference(from_set)
- return self._fileid_involved_by_set(changed)
-
- def fileid_involved(self, last_revid=None):
- """Find all file_ids modified in the ancestry of last_revid.
-
- :param last_revid: If None, last_revision() will be used.
- """
- if not last_revid:
- changed = set(self.all_revision_ids())
- else:
- changed = set(self.get_ancestry(last_revid))
- if None in changed:
- changed.remove(None)
- return self._fileid_involved_by_set(changed)
-
- @needs_read_lock
- def get_ancestry(self, revision_id):
- """Return a list of revision-ids integrated by a revision.
-
- This is topologically sorted.
- """
- if revision_id is None:
- return [None]
- vf = self._get_revision_vf()
- try:
- return [None] + vf.get_ancestry(revision_id)
- except errors.RevisionNotPresent:
- raise errors.NoSuchRevision(self, revision_id)
-
- @needs_read_lock
- def get_revision(self, revision_id):
- """Return the Revision object for a named revision"""
- return self.get_revision_reconcile(revision_id)
-
- @needs_read_lock
- def get_revision_graph(self, revision_id=None):
- """Return a dictionary containing the revision graph.
-
- :param revision_id: The revision_id to get a graph from. If None, then
- the entire revision graph is returned. This is a deprecated mode of
- operation and will be removed in the future.
- :return: a dictionary of revision_id->revision_parents_list.
- """
- # special case NULL_REVISION
- if revision_id == _mod_revision.NULL_REVISION:
- return {}
- a_weave = self._get_revision_vf()
- entire_graph = a_weave.get_graph()
- if revision_id is None:
- return a_weave.get_graph()
- elif revision_id not in a_weave:
- raise errors.NoSuchRevision(self, revision_id)
- else:
- # add what can be reached from revision_id
- result = {}
- pending = set([revision_id])
- while len(pending) > 0:
- node = pending.pop()
- result[node] = a_weave.get_parents(node)
- for revision_id in result[node]:
- if revision_id not in result:
- pending.add(revision_id)
- return result
-
- @needs_read_lock
- def get_revision_graph_with_ghosts(self, revision_ids=None):
- """Return a graph of the revisions with ghosts marked as applicable.
-
- :param revision_ids: an iterable of revisions to graph or None for all.
- :return: a Graph object with the graph reachable from revision_ids.
- """
- result = graph.Graph()
- vf = self._get_revision_vf()
- versions = set(vf.versions())
- if not revision_ids:
- pending = set(self.all_revision_ids())
- required = set([])
- else:
- pending = set(revision_ids)
- # special case NULL_REVISION
- if _mod_revision.NULL_REVISION in pending:
- pending.remove(_mod_revision.NULL_REVISION)
- required = set(pending)
- done = set([])
- while len(pending):
- revision_id = pending.pop()
- if not revision_id in versions:
- if revision_id in required:
- raise errors.NoSuchRevision(self, revision_id)
- # a ghost
- result.add_ghost(revision_id)
- # mark it as done so we don't try for it again.
- done.add(revision_id)
- continue
- parent_ids = vf.get_parents_with_ghosts(revision_id)
- for parent_id in parent_ids:
- # is this queued or done ?
- if (parent_id not in pending and
- parent_id not in done):
- # no, queue it.
- pending.add(parent_id)
- result.add_node(revision_id, parent_ids)
- done.add(revision_id)
- return result
-
- def _get_revision_vf(self):
- """:return: a versioned file containing the revisions."""
- vf = self._revision_store.get_revision_file(self.get_transaction())
- return vf
-
- @needs_write_lock
- def reconcile(self, other=None, thorough=False):
- """Reconcile this repository."""
- from bzrlib.reconcile import KnitReconciler
- reconciler = KnitReconciler(self, thorough=thorough)
- reconciler.reconcile()
- return reconciler
-
- def revision_parents(self, revision_id):
- return self._get_revision_vf().get_parents(revision_id)
-
-
class RepositoryFormatRegistry(registry.Registry):
"""Registry of RepositoryFormats.
"""
@@ -1140,6 +991,8 @@
_revision_store = TextRevisionStore(text_store, serializer)
return _revision_store
+ # TODO: this shouldn't be in the base class, it's specific to things that
+ # use weaves or knits -- mbp 20070207
def _get_versioned_file_store(self,
name,
transport,
@@ -1224,141 +1077,6 @@
control_files.unlock()
-class RepositoryFormatKnit(MetaDirRepositoryFormat):
- """Bzr repository knit format (generalized).
-
- 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
- """
-
- def _get_control_store(self, repo_transport, control_files):
- """Return the control store for this repository."""
- return VersionedFileStore(
- repo_transport,
- prefixed=False,
- file_mode=control_files._file_mode,
- versionedfile_class=knit.KnitVersionedFile,
- versionedfile_kwargs={'factory':knit.KnitPlainFactory()},
- )
-
- def _get_revision_store(self, repo_transport, control_files):
- """See RepositoryFormat._get_revision_store()."""
- from bzrlib.store.revision.knit import KnitRevisionStore
- versioned_file_store = VersionedFileStore(
- repo_transport,
- file_mode=control_files._file_mode,
- prefixed=False,
- precious=True,
- versionedfile_class=knit.KnitVersionedFile,
- versionedfile_kwargs={'delta':False,
- 'factory':knit.KnitPlainFactory(),
- },
- escaped=True,
- )
- return KnitRevisionStore(versioned_file_store)
-
- def _get_text_store(self, transport, control_files):
- """See RepositoryFormat._get_text_store()."""
- return self._get_versioned_file_store('knits',
- transport,
- control_files,
- versionedfile_class=knit.KnitVersionedFile,
- versionedfile_kwargs={
- 'create_parent_dir':True,
- 'delay_create':True,
- 'dir_mode':control_files._dir_mode,
- },
- escaped=True)
-
- def initialize(self, a_bzrdir, shared=False):
- """Create a knit format 1 repository.
-
- :param a_bzrdir: bzrdir to contain the new repository; must already
- be initialized.
- :param shared: If true the repository will be initialized as a shared
- repository.
- """
- mutter('creating repository in %s.', a_bzrdir.transport.base)
- dirs = ['revision-store', 'knits']
- files = []
- utf8_files = [('format', self.get_format_string())]
-
- self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
- repo_transport = a_bzrdir.get_repository_transport(None)
- control_files = lockable_files.LockableFiles(repo_transport,
- 'lock', lockdir.LockDir)
- control_store = self._get_control_store(repo_transport, control_files)
- transaction = transactions.WriteTransaction()
- # trigger a write of the inventory store.
- control_store.get_weave_or_empty('inventory', transaction)
- _revision_store = self._get_revision_store(repo_transport, control_files)
- # the revision id here is irrelevant: it will not be stored, and cannot
- # already exist.
- _revision_store.has_revision_id('A', transaction)
- _revision_store.get_signature_file(transaction)
- return self.open(a_bzrdir=a_bzrdir, _found=True)
-
- 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 KnitRepository(_format=self,
- a_bzrdir=a_bzrdir,
- control_files=control_files,
- _revision_store=_revision_store,
- control_store=control_store,
- text_store=text_store)
-
-
-class RepositoryFormatKnit1(RepositoryFormatKnit):
- """Bzr repository knit format 1.
-
- 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
-
- This format was introduced in bzr 0.8.
- """
- def get_format_string(self):
- """See RepositoryFormat.get_format_string()."""
- return "Bazaar-NG Knit Repository Format 1"
-
- def get_format_description(self):
- """See RepositoryFormat.get_format_description()."""
- return "Knit repository format 1"
-
- def check_conversion_target(self, target_format):
- pass
-
-
# 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.
@@ -1369,14 +1087,19 @@
)
# KEEP in sync with bzrdir.format_registry default, which controls the overall
# default control directory format
-_default_format = RepositoryFormatKnit1()
-RepositoryFormat.register_format(_default_format)
+
+format_registry.register_lazy(
+ 'Bazaar-NG Knit Repository Format 1',
+ 'bzrlib.repofmt.knitrepo',
+ 'RepositoryFormatKnit1_instance',
+ )
+format_registry.default_key = 'Bazaar-NG Knit Repository Format 1'
+
format_registry.register_lazy(
'Bazaar Knit Repository Format 2\n',
'bzrlib.repofmt.knitrepo',
'RepositoryFormatKnit2_instance',
)
-RepositoryFormat._set_default_format(_default_format)
class InterRepository(InterObject):
@@ -1442,8 +1165,10 @@
Data format and model must match for this to work.
"""
- _matching_repo_format = _default_format
- """Repository format for testing with."""
+ @classmethod
+ def _get_matching_repo_format(self):
+ """Repository format for testing with."""
+ return RepositoryFormat.get_default_format()
@staticmethod
def is_compatible(source, target):
@@ -1497,8 +1222,10 @@
class InterKnitRepo(InterSameDataRepository):
"""Optimised code paths between Knit based repositories."""
- _matching_repo_format = RepositoryFormatKnit1()
- """Repository format for testing with."""
+ @classmethod
+ def _get_matching_repo_format(self):
+ from bzrlib.repofmt import knitrepo
+ return knitrepo.RepositoryFormatKnit1()
@staticmethod
def is_compatible(source, target):
@@ -1508,6 +1235,7 @@
could lead to confusing results, and there is no need to be
overly general.
"""
+ from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
try:
return (isinstance(source._format, (RepositoryFormatKnit1)) and
isinstance(target._format, (RepositoryFormatKnit1)))
@@ -1559,7 +1287,9 @@
class InterModel1and2(InterRepository):
- _matching_repo_format = None
+ @classmethod
+ def _get_matching_repo_format(self):
+ return None
@staticmethod
def is_compatible(source, target):
@@ -1609,13 +1339,17 @@
class InterKnit1and2(InterKnitRepo):
- _matching_repo_format = None
+ @classmethod
+ def _get_matching_repo_format(self):
+ return None
@staticmethod
def is_compatible(source, target):
"""Be compatible with Knit1 source and Knit2 target"""
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit2
try:
+ from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1, \
+ RepositoryFormatKnit2
return (isinstance(source._format, (RepositoryFormatKnit1)) and
isinstance(target._format, (RepositoryFormatKnit2)))
except AttributeError:
@@ -1713,18 +1447,18 @@
#result.append((InterRepository,
# RepositoryFormat6(),
# RepositoryFormatKnit1()))
- for optimiser in InterRepository._optimisers:
- if optimiser._matching_repo_format is not None:
- result.append((optimiser,
- optimiser._matching_repo_format,
- optimiser._matching_repo_format
- ))
+ for optimiser_class in InterRepository._optimisers:
+ format_to_test = optimiser_class._get_matching_repo_format()
+ if format_to_test is not None:
+ result.append((optimiser_class,
+ format_to_test, format_to_test))
# if there are specific combinations we want to use, we can add them
# here.
result.append((InterModel1and2,
weaverepo.RepositoryFormat5(),
knitrepo.RepositoryFormatKnit2()))
- result.append((InterKnit1and2, RepositoryFormatKnit1(),
+ result.append((InterKnit1and2,
+ knitrepo.RepositoryFormatKnit1(),
knitrepo.RepositoryFormatKnit2()))
return result
=== modified file 'bzrlib/tests/blackbox/test_branch.py'
--- a/bzrlib/tests/blackbox/test_branch.py 2006-10-11 23:08:27 +0000
+++ b/bzrlib/tests/blackbox/test_branch.py 2007-02-07 09:11:31 +0000
@@ -20,7 +20,7 @@
import os
from bzrlib import branch, bzrdir
-from bzrlib.repository import RepositoryFormatKnit1
+from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
from bzrlib.tests.blackbox import ExternalBase
from bzrlib.workingtree import WorkingTree
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py 2006-10-16 01:25:46 +0000
+++ b/bzrlib/tests/blackbox/test_push.py 2007-02-07 09:11:31 +0000
@@ -24,7 +24,7 @@
from bzrlib.branch import Branch
from bzrlib.bzrdir import BzrDirMetaFormat1
from bzrlib.osutils import abspath
-from bzrlib.repository import RepositoryFormatKnit1
+from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
from bzrlib.tests.blackbox import ExternalBase
from bzrlib.uncommit import uncommit
from bzrlib.urlutils import local_path_from_url
=== modified file 'bzrlib/tests/blackbox/test_upgrade.py'
--- a/bzrlib/tests/blackbox/test_upgrade.py 2007-01-05 17:12:03 +0000
+++ b/bzrlib/tests/blackbox/test_upgrade.py 2007-02-07 09:11:31 +0000
@@ -28,6 +28,10 @@
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
from bzrlib.transport import get_transport
import bzrlib.ui as ui
+from bzrlib.repofmt.knitrepo import (
+ RepositoryFormatKnit1,
+ RepositoryFormatKnit2,
+ )
class TestWithUpgradableBranches(TestCaseWithTransport):
@@ -140,7 +144,7 @@
self.assertTrue(isinstance(converted_dir._format,
bzrdir.BzrDirMetaFormat1))
self.assertTrue(isinstance(converted_dir.open_repository()._format,
- repository.RepositoryFormatKnit1))
+ RepositoryFormatKnit1))
def test_upgrade_repo(self):
self.run_bzr('init-repository', '--format=metaweave', 'repo')
=== modified file 'bzrlib/tests/test_bundle.py'
--- a/bzrlib/tests/test_bundle.py 2007-02-06 08:16:13 +0000
+++ b/bzrlib/tests/test_bundle.py 2007-02-07 09:11:31 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2004, 2005, 2006 Canonical Ltd
+# Copyright (C) 2004, 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
@@ -341,7 +341,7 @@
text.seek(0)
format = bzrdir.BzrDirMetaFormat1()
- format.repository_format = repository.RepositoryFormatKnit1()
+ format.repository_format = knitrepo.RepositoryFormatKnit1()
target = self.make_branch('target', format=format)
self.assertRaises(errors.IncompatibleRevision, install_bundle,
target.repository, read_bundle(text))
@@ -353,7 +353,7 @@
def bzrdir_format(self):
format = bzrdir.BzrDirMetaFormat1()
- format.repository_format = repository.RepositoryFormatKnit1()
+ format.repository_format = knitrepo.RepositoryFormatKnit1()
return format
def make_branch_and_tree(self, path, format=None):
@@ -901,7 +901,7 @@
def bzrdir_format(self):
format = bzrdir.BzrDirMetaFormat1()
- format.repository_format = repository.RepositoryFormatKnit1()
+ format.repository_format = knitrepo.RepositoryFormatKnit1()
return format
=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py 2007-02-06 08:16:13 +0000
+++ b/bzrlib/tests/test_bzrdir.py 2007-02-07 09:11:31 +0000
@@ -72,11 +72,13 @@
my_format_registry.register_lazy('lazy', 'bzrlib.bzrdir',
'BzrDirFormat6', 'Format registered lazily', deprecated=True)
my_format_registry.register_metadir('knit', 'RepositoryFormatKnit1',
- 'Format using knits')
+ 'Format using knits',
+ repo_module='bzrlib.repofmt.knitrepo')
my_format_registry.set_default('knit')
- my_format_registry.register_metadir('experimental-knit2',
+ my_format_registry.register_metadir('experimental-knit2',
'RepositoryFormatKnit2',
- 'Experimental successor to knit. Use at your own risk.')
+ 'Experimental successor to knit. Use at your own risk.',
+ repo_module='bzrlib.repofmt.knitrepo')
return my_format_registry
def test_format_registry(self):
@@ -87,10 +89,10 @@
self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6)
my_bzrdir = my_format_registry.make_bzrdir('default')
self.assertIsInstance(my_bzrdir.repository_format,
- repository.RepositoryFormatKnit1)
+ knitrepo.RepositoryFormatKnit1)
my_bzrdir = my_format_registry.make_bzrdir('knit')
self.assertIsInstance(my_bzrdir.repository_format,
- repository.RepositoryFormatKnit1)
+ knitrepo.RepositoryFormatKnit1)
def test_get_help(self):
my_format_registry = self.make_format_registry()
=== modified file 'bzrlib/tests/test_fetch.py'
--- a/bzrlib/tests/test_fetch.py 2007-02-06 08:16:13 +0000
+++ b/bzrlib/tests/test_fetch.py 2007-02-07 09:11:31 +0000
@@ -124,7 +124,7 @@
corresponding filename, parent, contents or other changes.
"""
knit1_format = bzrdir.BzrDirMetaFormat1()
- knit1_format.repository_format = repository.RepositoryFormatKnit1()
+ knit1_format.repository_format = knitrepo.RepositoryFormatKnit1()
knit2_format = bzrdir.BzrDirMetaFormat1()
knit2_format.repository_format = knitrepo.RepositoryFormatKnit2()
# we start with a knit1 repository because that causes the
=== modified file 'bzrlib/tests/test_options.py'
--- a/bzrlib/tests/test_options.py 2007-01-17 16:32:40 +0000
+++ b/bzrlib/tests/test_options.py 2007-02-07 09:11:31 +0000
@@ -25,6 +25,7 @@
from bzrlib.builtins import cmd_commit, cmd_log, cmd_status
from bzrlib.commands import Command, parse_args
from bzrlib.tests import TestCase
+from bzrlib.repofmt import knitrepo
def parse(options, args):
parser = option.get_optparser(dict((o.name, o) for o in options))
@@ -162,12 +163,13 @@
bzrdir.format_registry, builtins.get_format_type)]
opts, args = self.parse(options, ['--format', 'knit'])
self.assertIsInstance(opts.format.repository_format,
- repository.RepositoryFormatKnit1)
+ knitrepo.RepositoryFormatKnit1)
def test_help(self):
registry = bzrdir.BzrDirFormatRegistry()
registry.register_metadir('one', 'RepositoryFormat7', 'one help')
- registry.register_metadir('two', 'RepositoryFormatKnit1', 'two help')
+ registry.register_metadir('two', 'RepositoryFormatKnit1', 'two help',
+ repo_module='bzrlib.repofmt.knitrepo')
registry.set_default('one')
options = [option.RegistryOption('format', 'format help', registry,
str, value_switches=True)]
@@ -188,7 +190,8 @@
[('hello', None, 'GAR', 'fg')])
registry = bzrdir.BzrDirFormatRegistry()
registry.register_metadir('one', 'RepositoryFormat7', 'one help')
- registry.register_metadir('two', 'RepositoryFormatKnit1', 'two help')
+ registry.register_metadir('two', 'RepositoryFormatKnit1', 'two help',
+ repo_module='bzrlib.repofmt.knitrepo')
registry.set_default('one')
opt = option.RegistryOption('format', 'format help', registry,
value_switches=False)
=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py 2007-02-06 08:16:13 +0000
+++ b/bzrlib/tests/test_repository.py 2007-02-07 09:11:31 +0000
@@ -260,7 +260,7 @@
def test_disk_layout(self):
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
- repo = repository.RepositoryFormatKnit1().initialize(control)
+ repo = knitrepo.RepositoryFormatKnit1().initialize(control)
# in case of side effects of locking.
repo.lock_write()
repo.unlock()
@@ -293,7 +293,7 @@
def test_shared_disk_layout(self):
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
- repo = repository.RepositoryFormatKnit1().initialize(control, shared=True)
+ repo = knitrepo.RepositoryFormatKnit1().initialize(control, shared=True)
# we want:
# format 'Bazaar-NG Knit Repository Format 1'
# lock: is a directory
@@ -312,7 +312,7 @@
def test_shared_no_tree_disk_layout(self):
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
- repo = repository.RepositoryFormatKnit1().initialize(control, shared=True)
+ repo = knitrepo.RepositoryFormatKnit1().initialize(control, shared=True)
repo.set_make_working_trees(False)
# we want:
# format 'Bazaar-NG Knit Repository Format 1'
@@ -402,7 +402,7 @@
t.mkdir('repository')
repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository')
repo = weaverepo.RepositoryFormat7().initialize(repo_dir)
- target_format = repository.RepositoryFormatKnit1()
+ target_format = knitrepo.RepositoryFormatKnit1()
converter = repository.CopyConverter(target_format)
pb = bzrlib.ui.ui_factory.nested_progress_bar()
try:
@@ -425,7 +425,7 @@
def test_convert(self):
"""Ensure the upgrade adds weaves for roots"""
format = bzrdir.BzrDirMetaFormat1()
- format.repository_format = repository.RepositoryFormatKnit1()
+ format.repository_format = knitrepo.RepositoryFormatKnit1()
tree = self.make_branch_and_tree('.', format)
tree.commit("Dull commit", rev_id="dull")
revision_tree = tree.branch.repository.revision_tree('dull')
More information about the bazaar-commits
mailing list