Rev 3993: Docs and polish on RepositoryFormat.network_name. in http://people.ubuntu.com/~robertc/baz2.0/network-name
Robert Collins
robertc at robertcollins.net
Thu Feb 19 03:09:58 GMT 2009
At http://people.ubuntu.com/~robertc/baz2.0/network-name
------------------------------------------------------------
revno: 3993
revision-id: robertc at robertcollins.net-20090219030955-1gqi3hfhg3h16eqv
parent: robertc at robertcollins.net-20090218210002-0lnnxjxmrnoj8qdk
committer: Robert Collins <robertc at robertcollins.net>
branch nick: network-name
timestamp: Thu 2009-02-19 14:09:55 +1100
message:
Docs and polish on RepositoryFormat.network_name.
=== modified file 'NEWS'
--- a/NEWS 2009-02-18 12:48:23 +0000
+++ b/NEWS 2009-02-19 03:09:55 +0000
@@ -69,6 +69,9 @@
command object before the command is run (or help generated from
it), without overriding the command. (Robert Collins)
+ * ``RepositoryFormat`` objects now have a ``network_name`` for passing
+ the format across RPC calls. (Robert Collins, Andrew Bennetts)
+
* Some methods have been pulled up from ``BzrBranch`` to ``Branch``
to aid branch types that are not bzr branch objects (like
RemoteBranch). (Robert Collins, Andrew Bennetts)
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2009-02-18 21:00:02 +0000
+++ b/bzrlib/bzrdir.py 2009-02-19 03:09:55 +0000
@@ -3074,8 +3074,9 @@
# appear in chronological order and format descriptions can build
# on previous ones.
format_registry = BzrDirFormatRegistry()
-# The pre-0.8 formats have their repo format network name registered in
-# repository.py.
+# The pre-0.8 formats have their repository format network name registered in
+# repository.py. MetaDir formats have their repository format network name
+# inferred from their disk format string.
format_registry.register('weave', BzrDirFormat6,
'Pre-0.8 format. Slower than knit and does not'
' support checkouts or shared repositories.',
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2009-02-18 21:00:02 +0000
+++ b/bzrlib/remote.py 2009-02-19 03:09:55 +0000
@@ -267,6 +267,13 @@
the attributes rich_root_data and supports_tree_reference are set
on a per instance basis, and are not set (and should not be) at
the class level.
+
+ :ivar _custom_format: If set, a specific concrete repository format that
+ will be used when initializing a repository with this
+ RemoteRepositoryFormat.
+ :ivar _creating_repo: If set, the repository object that this
+ RemoteRepositoryFormat was created for: it can be called into
+ to obtain data like te network name.
"""
_matchingbzrdir = RemoteBzrDirFormat()
=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py 2009-02-10 05:44:04 +0000
+++ b/bzrlib/repofmt/weaverepo.py 2009-02-19 03:09:55 +0000
@@ -401,9 +401,7 @@
return "Weave repository format 5"
def network_name(self):
- """The network name for this format is the disk string, which is the
- bzrdir's string because this is a pre-split-out format.
- """
+ """The network name for this format is the control dirs disk label."""
return self._matchingbzrdir.get_format_string()
def _get_inventories(self, repo_transport, repo, name='inventory'):
@@ -451,9 +449,7 @@
return "Weave repository format 6"
def network_name(self):
- """The network name for this format is the disk string, which is the
- bzrdir's string because this is a pre-split-out format.
- """
+ """The network name for this format is the control dirs disk label."""
return self._matchingbzrdir.get_format_string()
def _get_inventories(self, repo_transport, repo, name='inventory'):
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2009-02-10 05:44:04 +0000
+++ b/bzrlib/repository.py 2009-02-19 03:09:55 +0000
@@ -2198,6 +2198,8 @@
def register_lazy(self, key, module_name, member_name,
help=None, info=None,
override_existing=False):
+ # Overridden to allow capturing registrations to two seperate
+ # registries in a single call.
registry.Registry.register_lazy(self, key, module_name, member_name,
help=help, info=info, override_existing=override_existing)
if self._other_registry is not None:
@@ -2212,11 +2214,16 @@
network_format_registry = RepositoryFormatRegistry()
-"""Registry of formats indexed by their network name."""
+"""Registry of formats indexed by their network name.
+
+The network name for a repository format is an identifier that can be used when
+referring to formats with smart server operations. See
+RepositoryFormat.network_name() for more detail.
+"""
format_registry = RepositoryFormatRegistry(network_format_registry)
-"""Registry of formats, indexed by their identifying format string.
+"""Registry of formats, indexed by their BzrDirMetaFormat format string.
This can contain either format instances themselves, or classes/factories that
can be called to obtain one.
@@ -2229,24 +2236,27 @@
class RepositoryFormat(object):
"""A repository format.
- Formats provide three things:
+ Formats provide four things:
* An initialization routine to construct repository data on disk.
- * a format string which is used when the BzrDir supports versioned
- children.
+ * a optional format string which is used when the BzrDir supports
+ versioned children.
* an open routine which returns a Repository instance.
+ * A network name for referring to the format in smart server RPC
+ methods.
There is one and only one Format subclass for each on-disk format. But
there can be one Repository subclass that is used for several different
formats. The _format attribute on a Repository instance can be used to
determine the disk format.
- Formats are placed in an dict by their format string for reference
- during opening. These should be subclasses of RepositoryFormat
- for consistency.
+ Formats are placed in a registry by their format string for reference
+ during opening. These should be subclasses of RepositoryFormat for
+ consistency.
Once a format is deprecated, just deprecate the initialize and open
methods on the format class. Do not deprecate the object, as the
- object will be created every system load.
+ object may be created even when a repository instnace hasn't been
+ created.
Common instance attributes:
_matchingbzrdir - the bzrdir format that the repository format was
@@ -2359,6 +2369,16 @@
"""
return True
+ def network_name(self):
+ """A simple byte string uniquely identifying this format for RPC calls.
+
+ MetaDir repository formats use their disk format string to identify the
+ repository over the wire. All in one formats such as bzr < 0.8, and
+ foreign formats like svn/git and hg should use some marker which is
+ unique and immutable.
+ """
+ raise NotImplementedError(self.network_name)
+
def check_conversion_target(self, target_format):
raise NotImplementedError(self.check_conversion_target)
@@ -2419,8 +2439,10 @@
return self.get_format_string()
-# Pre-0.8 formats that don't have a disk format string, but do have a network
-# name are just registered in network_format_registry.
+# Pre-0.8 formats that don't have a disk format string (because they are
+# versioned by the matching control directory). We use the control directories
+# disk format string as a key for the network_name because they meet the
+# constraints (simple string, unique, immmutable).
network_format_registry.register_lazy(
"Bazaar-NG branch, format 5\n",
'bzrlib.repofmt.weaverepo',
More information about the bazaar-commits
mailing list