Rev 4253: (Jelmer) Split xml-independent bits out of bzrlib.xml_serializer. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Sat Apr 4 01:08:14 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4253
revision-id: pqm at pqm.ubuntu.com-20090404000810-fqvkqdjx9s1h9ks3
parent: pqm at pqm.ubuntu.com-20090403223059-0bqboagykhewobst
parent: jelmer at samba.org-20090403231811-8yh9yi6xl2lfce1v
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2009-04-04 01:08:10 +0100
message:
(Jelmer) Split xml-independent bits out of bzrlib.xml_serializer.
added:
bzrlib/serializer.py serializer.py-20090402143702-wmkh9cfjhwpju0qi-1
bzrlib/tests/test_serializer.py test_serializer.py-20090403213933-q6x117y8t9fbeyoz-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bundle/serializer/v4.py v10.py-20070611062757-5ggj7k18s9dej0fr-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/test_xml.py test_xml.py-20050905091053-80b45588931a9b35
bzrlib/xml4.py xml4.py-20050916091259-db5ab55e7e6ca324
bzrlib/xml8.py xml5.py-20050907032657-aac8f960815b66b1
bzrlib/xml_serializer.py xml.py-20050309040759-57d51586fdec365d
------------------------------------------------------------
revno: 4237.3.3
revision-id: jelmer at samba.org-20090403231811-8yh9yi6xl2lfce1v
parent: jelmer at samba.org-20090403215040-lz70cjc4i8bfg9xd
parent: pqm at pqm.ubuntu.com-20090403223059-0bqboagykhewobst
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: serializer
timestamp: Sat 2009-04-04 01:18:11 +0200
message:
Merge bzr.dev.
removed:
bzrlib/tests/blackbox/test_guess_renames.py test_guess_renames.p-20090312063936-bqdtxr0r3md3jc00-1
added:
bzrlib/inventory_delta.py journalled_inventory-20080103020931-0ht5n40kwc0p7fy1-1
bzrlib/tests/bzrdir_implementations/test_push.py test_push.py-20090403142358-xnn0wtsk3gx238ot-1
bzrlib/tests/test_inventory_delta.py test_journalled_inv.-20080103012121-ny2w9slze5jgty8i-1
doc/developers/groupcompress-design.txt design-20080705181503-ccbxd6xuy1bdnrpu-2
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/commit.py commit.py-20050511101309-79ec1a0168e0e825
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/inventory.py inventory.py-20050309040759-6648b84ca2005b37
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/memorytree.py memorytree.py-20060906023413-4wlkalbdpsxi2r4y-1
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
bzrlib/push.py push.py-20080606021927-5fe39050e8xne9un-1
bzrlib/reconcile.py reweave_inventory.py-20051108164726-1e5e0934febac06e
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/rename_map.py rename_map.py-20090312140439-xexkkmjlg2enbohc-1
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/smart/branch.py branch.py-20061124031907-mzh3pla28r83r97f-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
bzrlib/tests/blackbox/test_mv.py test_mv.py-20060705114902-33tkxz0o9cdshemo-1
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/bzrdir_implementations/__init__.py __init__.py-20060131065642-34c39b54f42dd048
bzrlib/tests/per_repository/test_add_inventory_by_delta.py test_add_inventory_d-20081013002626-rut81igtlqb4590z-1
bzrlib/tests/per_repository/test_check.py test_check.py-20070824124512-38g4d135gcqxo4zb-1
bzrlib/tests/per_repository/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
bzrlib/tests/per_repository_reference/test_add_inventory.py test_add_inventory.p-20080220025549-nnm2s80it1lvcwnc-3
bzrlib/tests/per_repository_reference/test_add_revision.py test_add_revision.py-20080220034108-ao1u8qgakqbo5a08-1
bzrlib/tests/per_repository_reference/test_add_signature_text.py test_add_signature_t-20080220041905-1j2g4lyz3c6h34v4-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_rename_map.py test_rename_map.py-20090312140439-xexkkmjlg2enbohc-2
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
bzrlib/tests/test_version_info.py test_version_info.py-20051228204928-2c364e30b702b41b
bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
bzrlib/ui/text.py text.py-20051130153916-2e438cffc8afc478
bzrlib/version_info_formats/format_custom.py format_custom.py-20071029100350-ajovqhbpb5khf6gu-1
bzrlib/version_info_formats/format_python.py format_python.py-20060809202444-ike7i9ub03gb432p-1
bzrlib/version_info_formats/format_rio.py format_rio.py-20060809202444-ike7i9ub03gb432p-2
bzrlib/versionedfile.py versionedfile.py-20060222045106-5039c71ee3b65490
bzrlib/weave.py knit.py-20050627021749-759c29984154256b
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
bzrlib/xml_serializer.py xml.py-20050309040759-57d51586fdec365d
doc/developers/development-repo.txt developmentrepo.txt-20080102200205-raj42k61dch8pjmj-1
doc/developers/index.txt index.txt-20070508041241-qznziunkg0nffhiw-1
doc/developers/inventory.txt inventory.txt-20080103013957-opkrhxy6lmywmx4i-1
doc/en/user-guide/svn_plugin.txt svn_plugin.txt-20080509065016-cjc90f46407vi9a0-2
tools/win32/build_release.py build_release.py-20081105204355-2ghh5cv01v1x4rzz-1
------------------------------------------------------------
revno: 4237.3.2
revision-id: jelmer at samba.org-20090403215040-lz70cjc4i8bfg9xd
parent: jelmer at samba.org-20090402152811-0uxng6q5kseoug7q
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: serializer
timestamp: Fri 2009-04-03 23:50:40 +0200
message:
Review from Aaron:
- move generic serializer tests to bzrlib.tests.test_serializer.
- fix some formatting
- add NEWS item
added:
bzrlib/tests/test_serializer.py test_serializer.py-20090403213933-q6x117y8t9fbeyoz-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/serializer.py serializer.py-20090402143702-wmkh9cfjhwpju0qi-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/test_xml.py test_xml.py-20050905091053-80b45588931a9b35
------------------------------------------------------------
revno: 4237.3.1
revision-id: jelmer at samba.org-20090402152811-0uxng6q5kseoug7q
parent: pqm at pqm.ubuntu.com-20090402093220-mqwls6dsncdfegbq
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: serializer
timestamp: Thu 2009-04-02 17:28:11 +0200
message:
Add new module with generic serializer information; keep XML-specific bits in
xml_serializer.
added:
bzrlib/serializer.py serializer.py-20090402143702-wmkh9cfjhwpju0qi-1
modified:
bzrlib/bundle/serializer/v4.py v10.py-20070611062757-5ggj7k18s9dej0fr-1
bzrlib/tests/test_xml.py test_xml.py-20050905091053-80b45588931a9b35
bzrlib/xml4.py xml4.py-20050916091259-db5ab55e7e6ca324
bzrlib/xml8.py xml5.py-20050907032657-aac8f960815b66b1
bzrlib/xml_serializer.py xml.py-20050309040759-57d51586fdec365d
=== modified file 'NEWS'
--- a/NEWS 2009-04-03 22:30:59 +0000
+++ b/NEWS 2009-04-03 23:18:11 +0000
@@ -187,7 +187,7 @@
API Changes
***********
-* APIs deprecated in 1.6 and previous verisons of bzr are now removed.
+* APIs deprecated in 1.6 and previous versions of bzr are now removed.
(Martin Pool)
* ``CommitReporter`` is no longer called with ``unchanged`` status during
@@ -215,6 +215,9 @@
* The ``pb`` argument to ``fetch()`` is deprecated.
(Martin Pool)
+* The ``Serializer`` class and the serializer ``format registry`` have moved
+ from ``bzrlib.xml_serializer`` to ``bzrlib.serializer``. (Jelmer Vernooij)
+
* The smart server jail now hooks into BzrDir.open to prevent any BzrDir
that is not inside the backing transport from being opened. See the
module documentation for ``bzrlib.smart.request`` for details.
=== modified file 'bzrlib/bundle/serializer/v4.py'
--- a/bzrlib/bundle/serializer/v4.py 2009-03-25 23:15:11 +0000
+++ b/bzrlib/bundle/serializer/v4.py 2009-04-02 15:28:11 +0000
@@ -27,9 +27,9 @@
pack,
revision as _mod_revision,
trace,
- xml_serializer,
+ serializer,
)
-from bzrlib.bundle import bundle_data, serializer
+from bzrlib.bundle import bundle_data, serializer as bundle_serializer
from bzrlib.util import bencode
@@ -54,8 +54,8 @@
def begin(self):
"""Start writing the bundle"""
- self._fileobj.write(serializer._get_bundle_header(
- serializer.v4_string))
+ self._fileobj.write(bundle_serializer._get_bundle_header(
+ bundle_serializer.v4_string))
self._fileobj.write('#\n')
self._container.begin()
@@ -218,7 +218,7 @@
yield (bytes, metadata) + self.decode_name(names[0][0])
-class BundleSerializerV4(serializer.BundleSerializer):
+class BundleSerializerV4(bundle_serializer.BundleSerializer):
"""Implement the high-level bundle interface"""
def write(self, repository, revision_ids, forced_bases, fileobj):
@@ -250,7 +250,7 @@
@staticmethod
def get_source_serializer(info):
"""Retrieve the serializer for a given info object"""
- return xml_serializer.format_registry.get(info['serializer'])
+ return serializer.format_registry.get(info['serializer'])
class BundleWriteOperation(object):
=== added file 'bzrlib/serializer.py'
--- a/bzrlib/serializer.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/serializer.py 2009-04-03 21:50:40 +0000
@@ -0,0 +1,77 @@
+# Copyright (C) 2005, 2006, 2009 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+"""Inventory/revision serialization."""
+
+
+from bzrlib import registry
+
+
+class Serializer(object):
+ """Inventory and revision serialization/deserialization."""
+
+ def write_inventory(self, inv, f):
+ """Write inventory to a file"""
+ raise NotImplementedError(self.write_inventory)
+
+ def write_inventory_to_string(self, inv):
+ raise NotImplementedError(self.write_inventory_to_string)
+
+ def read_inventory_from_string(self, string, revision_id=None,
+ entry_cache=None):
+ """Read string into an inventory object.
+
+ :param string: The serialized inventory to read.
+ :param revision_id: If not-None, the expected revision id of the
+ inventory. Some serialisers use this to set the results' root
+ revision. This should be supplied for deserialising all
+ from-repository inventories so that xml5 inventories that were
+ serialised without a revision identifier can be given the right
+ revision id (but not for working tree inventories where users can
+ edit the data without triggering checksum errors or anything).
+ :param entry_cache: An optional cache of InventoryEntry objects. If
+ supplied we will look up entries via (file_id, revision_id) which
+ should map to a valid InventoryEntry (File/Directory/etc) object.
+ """
+ raise NotImplementedError(self.read_inventory_from_string)
+
+ def read_inventory(self, f, revision_id=None):
+ raise NotImplementedError(self.read_inventory)
+
+ def write_revision(self, rev, f):
+ raise NotImplementedError(self.write_revision)
+
+ def write_revision_to_string(self, rev):
+ raise NotImplementedError(self.write_revision_to_string)
+
+ def read_revision(self, f):
+ raise NotImplementedError(self.read_revision)
+
+ def read_revision_from_string(self, xml_string):
+ raise NotImplementedError(self.read_revision_from_string)
+
+
+class SerializerRegistry(registry.Registry):
+ """Registry for serializer objects"""
+
+
+format_registry = SerializerRegistry()
+format_registry.register_lazy('4', 'bzrlib.xml4', 'serializer_v4')
+format_registry.register_lazy('5', 'bzrlib.xml5', 'serializer_v5')
+format_registry.register_lazy('6', 'bzrlib.xml6', 'serializer_v6')
+format_registry.register_lazy('7', 'bzrlib.xml7', 'serializer_v7')
+format_registry.register_lazy('8', 'bzrlib.xml8', 'serializer_v8')
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2009-04-03 15:32:56 +0000
+++ b/bzrlib/tests/__init__.py 2009-04-03 23:18:11 +0000
@@ -3374,6 +3374,7 @@
'bzrlib.tests.test_rules',
'bzrlib.tests.test_sampler',
'bzrlib.tests.test_selftest',
+ 'bzrlib.tests.test_serializer',
'bzrlib.tests.test_setup',
'bzrlib.tests.test_sftp_transport',
'bzrlib.tests.test_shelf',
=== added file 'bzrlib/tests/test_serializer.py'
--- a/bzrlib/tests/test_serializer.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/test_serializer.py 2009-04-03 21:50:40 +0000
@@ -0,0 +1,45 @@
+# Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+"""Tests for the revision/inventory Serializers."""
+
+
+from bzrlib import (
+ serializer,
+ xml4,
+ xml5,
+ xml6,
+ xml7,
+ xml8,
+ )
+from bzrlib.tests import TestCase
+
+
+class TestSerializer(TestCase):
+ """Test serializer"""
+
+ def test_registry(self):
+ self.assertIs(xml4.serializer_v4,
+ serializer.format_registry.get('4'))
+ self.assertIs(xml5.serializer_v5,
+ serializer.format_registry.get('5'))
+ self.assertIs(xml6.serializer_v6,
+ serializer.format_registry.get('6'))
+ self.assertIs(xml7.serializer_v7,
+ serializer.format_registry.get('7'))
+ self.assertIs(xml8.serializer_v8,
+ serializer.format_registry.get('8'))
=== modified file 'bzrlib/tests/test_xml.py'
--- a/bzrlib/tests/test_xml.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/test_xml.py 2009-04-03 21:50:40 +0000
@@ -21,7 +21,7 @@
inventory,
xml7,
xml8,
- xml_serializer,
+ serializer,
)
from bzrlib.tests import TestCase
from bzrlib.inventory import Inventory, InventoryEntry
@@ -492,18 +492,6 @@
self.assertEqual(len(expected), len(actual))
- def test_registry(self):
- self.assertIs(serializer_v4,
- xml_serializer.format_registry.get('4'))
- self.assertIs(bzrlib.xml5.serializer_v5,
- xml_serializer.format_registry.get('5'))
- self.assertIs(bzrlib.xml6.serializer_v6,
- xml_serializer.format_registry.get('6'))
- self.assertIs(bzrlib.xml7.serializer_v7,
- xml_serializer.format_registry.get('7'))
- self.assertIs(bzrlib.xml8.serializer_v8,
- xml_serializer.format_registry.get('8'))
-
class TestEncodeAndEscape(TestCase):
"""Whitebox testing of the _encode_and_escape function."""
=== modified file 'bzrlib/xml4.py'
--- a/bzrlib/xml4.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/xml4.py 2009-04-02 15:28:11 +0000
@@ -14,14 +14,19 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-from bzrlib.xml_serializer import ElementTree, SubElement, Element, Serializer
+from bzrlib.xml_serializer import (
+ Element,
+ ElementTree,
+ SubElement,
+ XMLSerializer,
+ )
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
import bzrlib.inventory as inventory
from bzrlib.revision import Revision
from bzrlib.errors import BzrError
-class _Serializer_v4(Serializer):
+class _Serializer_v4(XMLSerializer):
"""Version 0.0.4 serializer
You should use the serializer_v4 singleton.
=== modified file 'bzrlib/xml8.py'
--- a/bzrlib/xml8.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/xml8.py 2009-04-02 15:28:11 +0000
@@ -24,7 +24,11 @@
revision as _mod_revision,
trace,
)
-from bzrlib.xml_serializer import SubElement, Element, Serializer
+from bzrlib.xml_serializer import (
+ Element,
+ SubElement,
+ XMLSerializer,
+ )
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
from bzrlib.revision import Revision
from bzrlib.errors import BzrError
@@ -139,7 +143,7 @@
_to_escaped_map.clear()
-class Serializer_v8(Serializer):
+class Serializer_v8(XMLSerializer):
"""This serialiser adds rich roots.
Its revision format number matches its inventory number.
=== modified file 'bzrlib/xml_serializer.py'
--- a/bzrlib/xml_serializer.py 2009-03-31 20:34:33 +0000
+++ b/bzrlib/xml_serializer.py 2009-04-03 23:18:11 +0000
@@ -22,7 +22,7 @@
# importing this module is fairly slow because it has to load several
# ElementTree bits
-from bzrlib import registry
+from bzrlib.serializer import Serializer
from bzrlib.trace import mutter, warning
try:
@@ -49,15 +49,8 @@
from bzrlib import errors
-class Serializer(object):
- """Abstract object serialize/deserialize"""
-
- def write_inventory(self, inv, f):
- """Write inventory to a file"""
- raise NotImplementedError(self.write_inventory)
-
- def write_inventory_to_string(self, inv):
- raise NotImplementedError(self.write_inventory_to_string)
+class XMLSerializer(Serializer):
+ """Abstract XML object serialize/deserialize"""
def read_inventory_from_string(self, xml_string, revision_id=None,
entry_cache=None):
@@ -175,18 +168,6 @@
elementtree.ElementTree._escape_cdata = _escape_cdata
-class SerializerRegistry(registry.Registry):
- """Registry for serializer objects"""
-
-
-format_registry = SerializerRegistry()
-format_registry.register_lazy('4', 'bzrlib.xml4', 'serializer_v4')
-format_registry.register_lazy('5', 'bzrlib.xml5', 'serializer_v5')
-format_registry.register_lazy('6', 'bzrlib.xml6', 'serializer_v6')
-format_registry.register_lazy('7', 'bzrlib.xml7', 'serializer_v7')
-format_registry.register_lazy('8', 'bzrlib.xml8', 'serializer_v8')
-
-
def escape_invalid_chars(message):
"""Escape the XML-invalid characters in a commit message.
@@ -200,4 +181,3 @@
return re.subn(u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
lambda match: match.group(0).encode('unicode_escape'),
message)
-
More information about the bazaar-commits
mailing list