[MERGE (0.12)] Bundle format 0.9

John Arbash Meinel john at arbash-meinel.com
Mon Sep 25 21:29:38 BST 2006

Hash: SHA1

Aaron Bentley wrote:
> Hi all,
> This patch introduces support for bundle format 0.9 and testament format
> 3 strict.
> The only thing new about these formats is that they support rich root
> metadata.  However, they can also be used for old revisions whose root
> metadata is not rich.
> This patch also includes my parent_check patch, because partway through
> this work, I discovered my knits were being silently corrupted, and
> wrote the patch.
> I believe these two formats are the last ones that need bumping, and
> once this is merged, I can go back to making root ids unique.
> Aaron

So before we can merge this, we need to decide as a group if we want the
'parent_check' patch, and I haven't heard anything from Robert or Martin

Also, if we are bumping the format, shouldn't this format include
Signatures? Since that is the only *functionality* missing. (The fact
that they are slow to use is an optimization, not a functionality flaw)

You also have some trailing whitespace here and there. It might be nice
to clean that up first.

v- This file needs a Copyright comment and a summary doc string. (And if
the other serializer formats don't have one, then they need them added
as well).

=== added file 'bzrlib/bundle/serializer/v09.py'
- --- bzrlib/bundle/serializer/v09.py	1970-01-01 00:00:00 +0000
+++ bzrlib/bundle/serializer/v09.py	2006-09-22 01:36:22 +0000
@@ -0,0 +1,57 @@
+from bzrlib.bundle.serializer import BUNDLE_HEADER
+from bzrlib.bundle.serializer.v08 import BundleSerializerV08, BundleReader
+from bzrlib.testament import StrictTestament2
+from bzrlib.bundle.bundle_data import BundleInfo
+class BundleSerializerV09(BundleSerializerV08):
+    """Serializer for bzr bundle format 0.9
+    This format supports rich root data, for the nested-trees work, but
+    supports repositories that don't have rich root data.  It cannot be
+    used to transfer from a knit2 repo into a knit1 repo, because that
+    be lossy.
+    """
+    def check_compatible(self):
+        pass
+    def _write_main_header(self):
+        """Write the header for the changes"""
+        f = self.to_file
+        f.write(BUNDLE_HEADER)
+        f.write('0.9\n')
+        f.write('#\n')

^ it is generally better to do:
f.write(BUNDLE_HEADER + '0.9\n#\n')
Or at least

Since the system call overhead is moderately big. (I realize these
aren't writing over a Transport at least).

v- I don't think we want to call the class StrictTestament2 but have the
header string be 'bazaar-ng testament version 3 strict\n'

1) We want to switch to 'bazaar' instead of 'bazaar-ng'.
2) If we are calling it version 3, I think it is best to call the class
...3 to avoid confusion.

+class StrictTestament2(StrictTestament):
+    """This testament format is for use as a checksum in bundle format 0.9+
+    It differs from StrictTestament by including data about the tree root.
+    """
+    long_header = 'bazaar-ng testament version 3 strict\n'
+    short_header = 'bazaar-ng testament short form 3 strict\n'
+    def _get_entries(self):
+        return self.inventory.iter_entries()
+    def _escape_path(self, path):
+        assert not contains_linebreaks(path)
+        if path == '':
+            path = '.'
+        return unicode(path.replace('\\', '/').replace(' ', '\ '))

^- Do we need replace('\\', '/') it seems that by this time, '\\' should
not exist in the path.


v- this should be split across multiple lines.

- -from bzrlib import inventory, treebuilder
+from bzrlib import bzrdir, errors, inventory, repository, treebuilder
 from bzrlib.builtins import merge
 from bzrlib.bzrdir import BzrDir
 from bzrlib.bundle.apply_bundle import install_bundle, merge_bundle
 from bzrlib.bundle.bundle_data import BundleTree
 from bzrlib.bundle.serializer import write_bundle, read_bundle
+from bzrlib.bundle.serializer.v08 import BundleSerializerV08
+from bzrlib.bundle.serializer.v09 import BundleSerializerV09
 from bzrlib.branch import Branch
 from bzrlib.diff import internal_diff
 from bzrlib.errors import (BzrError, TestamentMismatch, NotABundle,
@@ -301,15 +303,69 @@
             [inventory.ROOT_ID, 'a', 'b', 'd', 'e'])

v- You should probably update the Copyright line, but not delete it.
(Though I'm assuming the delete was actually accidental)

- --- bzrlib/tests/test_testament.py	2006-08-16 16:55:54 +0000
+++ bzrlib/tests/test_testament.py	2006-09-22 01:50:59 +0000
@@ -1,4 +1,3 @@
- -# Copyright (C) 2005 by 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
@@ -22,7 +21,7 @@
 from sha import sha

 from bzrlib.tests import TestCaseWithTransport
- -from bzrlib.testament import Testament, StrictTestament
+from bzrlib.testament import Testament, StrictTestament, StrictTestament2
 from bzrlib.transform import TreeTransform
 from bzrlib.osutils import has_symlinks

So I don't know that it is quite ready, but I think it is on its way.

Version: GnuPG v1.4.5 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the bazaar mailing list