Rev 3621: Merge in rich-root-serializer to get the NEWS entry correct. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/bug_261339

John Arbash Meinel john at arbash-meinel.com
Fri Aug 29 06:30:35 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/bug_261339

------------------------------------------------------------
revno: 3621
revision-id: john at arbash-meinel.com-20080829053033-sr6alv4rzfvlfwke
parent: john at arbash-meinel.com-20080829020522-kpkk0zvxf52oj3kh
parent: john at arbash-meinel.com-20080829051928-wtobyp0rxuepozmi
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bug_261339
timestamp: Fri 2008-08-29 00:30:33 -0500
message:
  Merge in rich-root-serializer to get the NEWS entry correct.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
  bzrlib/tests/test_info.py      test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
  bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
  bzrlib/tests/test_upgrade_stacked.py test_upgrade_stacked-20080804072225-jd13yami19nskns5-1
    ------------------------------------------------------------
    revno: 3619.1.6
    revision-id: john at arbash-meinel.com-20080829051928-wtobyp0rxuepozmi
    parent: john at arbash-meinel.com-20080829051856-cybdbv604adwbzn1
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rich_root_serializer
    timestamp: Fri 2008-08-29 00:19:28 -0500
    message:
      Cleanup NEWS
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3619.1.5
    revision-id: john at arbash-meinel.com-20080829051856-cybdbv604adwbzn1
    parent: john at arbash-meinel.com-20080829044612-i5eshappfji5sjfz
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rich_root_serializer
    timestamp: Fri 2008-08-29 00:18:56 -0500
    message:
      Switch out --1.6-rich-root for --1.6.1-rich-root.
      
      Fix up the tests that were expecting the old name.
      Also add tests that stacking properly check the various
      permutations.
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
      bzrlib/tests/test_info.py      test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
      bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
      bzrlib/tests/test_upgrade_stacked.py test_upgrade_stacked-20080804072225-jd13yami19nskns5-1
    ------------------------------------------------------------
    revno: 3619.1.4
    revision-id: john at arbash-meinel.com-20080829044612-i5eshappfji5sjfz
    parent: john at arbash-meinel.com-20080829025102-yen21bf2ryskwbrr
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rich_root_serializer
    timestamp: Thu 2008-08-28 23:46:12 -0500
    message:
      Remove --1.6-rich-root as a registered metadir collection.
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
    ------------------------------------------------------------
    revno: 3619.1.3
    revision-id: john at arbash-meinel.com-20080829025102-yen21bf2ryskwbrr
    parent: john at arbash-meinel.com-20080829024439-zx2jhwqbt4qlyg13
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rich_root_serializer
    timestamp: Thu 2008-08-28 21:51:02 -0500
    message:
      When warning give an exact upgrade request.
    modified:
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
    ------------------------------------------------------------
    revno: 3619.1.2
    revision-id: john at arbash-meinel.com-20080829024439-zx2jhwqbt4qlyg13
    parent: john at arbash-meinel.com-20080829023918-10cy13i3x5af62ne
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rich_root_serializer
    timestamp: Thu 2008-08-28 21:44:39 -0500
    message:
      Name the new format 1.6.1-rich-root, and NEWS for fixing bug #262333
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
    ------------------------------------------------------------
    revno: 3619.1.1
    revision-id: john at arbash-meinel.com-20080829023918-10cy13i3x5af62ne
    parent: pqm at pqm.ubuntu.com-20080825143827-fl7cocq59pqdig2p
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rich_root_serializer
    timestamp: Thu 2008-08-28 21:39:18 -0500
    message:
      Create a new --1.6-rich-root, deprecate the old one.
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-08-29 02:05:22 +0000
+++ b/NEWS	2008-08-29 05:30:33 +0000
@@ -4,8 +4,8 @@
 
 .. contents::
 
-bzr 1.6.1 IN DEVELOPMENT
-------------------------
+bzr 1.6.1rc1 IN DEVELOPMENT
+---------------------------
 
   BUG FIXES:
 
@@ -15,6 +15,13 @@
       but to support those repositories, we know always request full texts
       for Revision texts. (John Arbash Meinel, #261339)
 
+    * The previous ``--1.6-rich-root`` format used an incorrect xml
+      serializer, which would accidentally support fetching from a
+      repository that supported subtrees, even though the local one would
+      not. We deprecated that format, and introduced a new one that uses
+      the correct serializer ``--1.6.1-rich-root``.
+      (John Arbash Meinel, #262333)
+
 
 bzr 1.6 2008-08-25
 ------------------

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2008-08-19 21:04:22 +0000
+++ b/bzrlib/bzrdir.py	2008-08-29 05:18:56 +0000
@@ -3025,7 +3025,7 @@
     branch_format='bzrlib.branch.BzrBranchFormat7',
     tree_format='bzrlib.workingtree.WorkingTreeFormat4',
     )
-format_registry.register_metadir('1.6-rich-root',
+format_registry.register_metadir('1.6.1-rich-root',
     'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
     help='A branch and pack based repository that supports stacking '
          'and rich root data (needed for bzr-svn). ',

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2008-08-18 22:34:21 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2008-08-29 02:51:02 +0000
@@ -1722,8 +1722,15 @@
         self._fetch_order = 'unordered'
 
     def _warn_if_deprecated(self):
-        # This class isn't deprecated
-        pass
+        # This class isn't deprecated, but one sub-format is
+        if isinstance(self._format, RepositoryFormatKnitPack5RichRootBroken):
+            from bzrlib import repository
+            if repository._deprecation_warning_done:
+                return
+            repository._deprecation_warning_done = True
+            warning("Format %s for %s is deprecated - please use"
+                    " 'bzr upgrade --1.6.1-rich-root'"
+                    % (self._format, self.bzrdir.transport.base))
 
     def _abort_write_group(self):
         self._pack_collection._abort_write_group()
@@ -2086,12 +2093,54 @@
 
 
 class RepositoryFormatKnitPack5RichRoot(RepositoryFormatPack):
+    """A repository with rich roots and stacking.
+
+    New in release 1.6.1.
+
+    Supports stacking on other repositories, allowing data to be accessed
+    without being stored locally.
+    """
+
+    repository_class = KnitPackRepository
+    _commit_builder_class = PackRootCommitBuilder
+    rich_root_data = True
+    supports_tree_reference = False # no subtrees
+    _serializer = xml6.serializer_v6
+    supports_external_lookups = True
+
+    def _get_matching_bzrdir(self):
+        return bzrdir.format_registry.make_bzrdir(
+            '1.6.1-rich-root')
+
+    def _ignore_setting_bzrdir(self, format):
+        pass
+
+    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
+
+    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 get_format_string(self):
+        """See RepositoryFormat.get_format_string()."""
+        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n"
+
+    def get_format_description(self):
+        return "Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)"
+
+
+class RepositoryFormatKnitPack5RichRootBroken(RepositoryFormatPack):
     """A repository with rich roots and external references.
 
     New in release 1.6.
 
     Supports external lookups, which results in non-truncated ghosts after
     reconcile compared to pack-0.92 formats.
+
+    This format was deprecated because the serializer it uses accidentally
+    supported subtrees, when the format was not intended to. This meant that
+    someone could accidentally fetch from an incorrect repository.
     """
 
     repository_class = KnitPackRepository
@@ -2115,13 +2164,14 @@
         if not target_format.rich_root_data:
             raise errors.BadConversionTarget(
                 'Does not support rich root data.', target_format)
-            
+
     def get_format_string(self):
         """See RepositoryFormat.get_format_string()."""
         return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
 
     def get_format_description(self):
-        return "Packs 5 rich-root (adds stacking support, requires bzr 1.6)"
+        return ("Packs 5 rich-root (adds stacking support, requires bzr 1.6)"
+                " (deprecated)")
 
 
 class RepositoryFormatPackDevelopment0(RepositoryFormatPack):

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2008-08-18 22:34:21 +0000
+++ b/bzrlib/repository.py	2008-08-29 02:39:18 +0000
@@ -2300,9 +2300,14 @@
     'RepositoryFormatKnitPack5',
     )
 format_registry.register_lazy(
+    'Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n',
+    'bzrlib.repofmt.pack_repo',
+    'RepositoryFormatKnitPack5RichRoot',
+    )
+format_registry.register_lazy(
     'Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n',
     'bzrlib.repofmt.pack_repo',
-    'RepositoryFormatKnitPack5RichRoot',
+    'RepositoryFormatKnitPack5RichRootBroken',
     )
 
 # Development formats. 
@@ -2903,13 +2908,17 @@
     @staticmethod
     def is_compatible(source, target):
         """Be compatible with Knit1 source and Knit3 target"""
-        from bzrlib.repofmt.knitrepo import RepositoryFormatKnit3
         try:
-            from bzrlib.repofmt.knitrepo import (RepositoryFormatKnit1,
-                RepositoryFormatKnit3)
+            from bzrlib.repofmt.knitrepo import (
+                RepositoryFormatKnit1,
+                RepositoryFormatKnit3,
+                )
             from bzrlib.repofmt.pack_repo import (
                 RepositoryFormatKnitPack1,
                 RepositoryFormatKnitPack3,
+                RepositoryFormatKnitPack4,
+                RepositoryFormatKnitPack5,
+                RepositoryFormatKnitPack5RichRoot,
                 RepositoryFormatPackDevelopment0,
                 RepositoryFormatPackDevelopment0Subtree,
                 )
@@ -2917,6 +2926,9 @@
                 RepositoryFormatKnit1,
                 RepositoryFormatKnitPack1,
                 RepositoryFormatPackDevelopment0,
+                RepositoryFormatKnitPack4,
+                RepositoryFormatKnitPack5,
+                RepositoryFormatKnitPack5RichRoot,
                 )
             subtrees = (
                 RepositoryFormatKnit3,

=== modified file 'bzrlib/tests/blackbox/test_info.py'
--- a/bzrlib/tests/blackbox/test_info.py	2008-07-24 06:10:47 +0000
+++ b/bzrlib/tests/blackbox/test_info.py	2008-08-29 05:18:56 +0000
@@ -247,7 +247,7 @@
         branch5 = tree5.branch
         out, err = self.run_bzr('info -v lightcheckout')
         self.assertEqualDiff(
-"""Lightweight checkout (format: 1.6 or 1.6-rich-root \
+"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root \
 or dirstate or dirstate-tags or \
 pack-0.92 or rich-root or rich-root-pack)
 Location:
@@ -415,7 +415,7 @@
         # Out of date lightweight checkout
         out, err = self.run_bzr('info lightcheckout --verbose')
         self.assertEqualDiff(
-"""Lightweight checkout (format: 1.6 or 1.6-rich-root or \
+"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
 dirstate or dirstate-tags or \
 pack-0.92 or rich-root or rich-root-pack)
 Location:
@@ -552,7 +552,7 @@
         datestring_first = format_date(rev.timestamp, rev.timezone)
         out, err = self.run_bzr('info tree/lightcheckout --verbose')
         self.assertEqualDiff(
-"""Lightweight checkout (format: 1.6 or 1.6-rich-root or \
+"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
 dirstate or dirstate-tags or \
 pack-0.92 or rich-root or rich-root-pack)
 Location:
@@ -676,7 +676,7 @@
         datestring_last = format_date(rev.timestamp, rev.timezone)
         out, err = self.run_bzr('info tree/lightcheckout --verbose')
         self.assertEqualDiff(
-"""Lightweight checkout (format: 1.6 or 1.6-rich-root or \
+"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
 dirstate or dirstate-tags or \
 pack-0.92 or rich-root or rich-root-pack)
 Location:
@@ -1092,7 +1092,7 @@
             (False, True): 'Lightweight checkout',
             (False, False): 'Checkout',
             }[(shared_repo is not None, light_checkout)]
-        format = {True: '1.6 or 1.6-rich-root'
+        format = {True: '1.6 or 1.6.1-rich-root'
                         ' or dirstate or dirstate-tags or pack-0.92'
                         ' or rich-root or rich-root-pack',
                   False: 'dirstate'}[light_checkout]

=== modified file 'bzrlib/tests/test_info.py'
--- a/bzrlib/tests/test_info.py	2008-07-24 05:19:40 +0000
+++ b/bzrlib/tests/test_info.py	2008-08-29 05:18:56 +0000
@@ -146,8 +146,8 @@
             expected = None
             if key in ('dirstate', 'dirstate-tags', 'dirstate-with-subtree',
                 'pack-0.92', 'pack-0.92-subtree', 'rich-root',
-                'rich-root-pack', '1.6', '1.6-rich-root'):
-                expected = '1.6 or 1.6-rich-root or ' \
+                'rich-root-pack', '1.6', '1.6.1-rich-root'):
+                expected = '1.6 or 1.6.1-rich-root or ' \
                     'dirstate or dirstate-tags or pack-0.92 or'\
                     ' rich-root or rich-root-pack'
             if key in ('knit', 'metaweave'):

=== modified file 'bzrlib/tests/test_pack_repository.py'
--- a/bzrlib/tests/test_pack_repository.py	2008-08-18 23:11:59 +0000
+++ b/bzrlib/tests/test_pack_repository.py	2008-08-29 05:18:56 +0000
@@ -495,7 +495,7 @@
     def get_format(self):
         return bzrdir.format_registry.make_bzrdir(self.format_name)
 
-    def test_stack_checks_compatibility(self):
+    def test_stack_checks_rich_root_compatibility(self):
         # early versions of the packing code relied on pack internals to
         # stack, but the current version should be able to stack on any
         # format.
@@ -507,7 +507,10 @@
         if repo.supports_rich_root():
             # can only stack on repositories that have compatible internal
             # metadata
-            matching_format_name = 'pack-0.92-subtree'
+            if getattr(repo._format, 'supports_tree_reference', False):
+                matching_format_name = 'pack-0.92-subtree'
+            else:
+                matching_format_name = 'rich-root-pack'
             mismatching_format_name = 'pack-0.92'
         else:
             matching_format_name = 'pack-0.92'
@@ -524,6 +527,32 @@
             r'KnitPackRepository.*/repo/.*\n'
             r'different rich-root support')
 
+    def test_stack_checks_serializers_compatibility(self):
+        repo = self.make_repository('repo', format=self.get_format())
+        if getattr(repo._format, 'supports_tree_reference', False):
+            # can only stack on repositories that have compatible internal
+            # metadata
+            matching_format_name = 'pack-0.92-subtree'
+            mismatching_format_name = 'rich-root-pack'
+        else:
+            if repo.supports_rich_root():
+                matching_format_name = 'rich-root-pack'
+                mismatching_format_name = 'pack-0.92-subtree'
+            else:
+                raise TestNotApplicable('No formats use non-v5 serializer'
+                    ' without having rich-root also set')
+        base = self.make_repository('base', format=matching_format_name)
+        repo.add_fallback_repository(base)
+        # you can't stack on something with incompatible data
+        bad_repo = self.make_repository('mismatch',
+            format=mismatching_format_name)
+        e = self.assertRaises(errors.IncompatibleRepositories,
+            repo.add_fallback_repository, bad_repo)
+        self.assertContainsRe(str(e),
+            r'(?m)KnitPackRepository.*/mismatch/.*\nis not compatible with\n'
+            r'KnitPackRepository.*/repo/.*\n'
+            r'different serializers')
+
     def test_adding_pack_does_not_record_pack_names_from_other_repositories(self):
         base = self.make_branch_and_tree('base', format=self.get_format())
         base.commit('foo')
@@ -590,9 +619,9 @@
          dict(format_name='1.6',
               format_string="Bazaar RepositoryFormatKnitPack5 (bzr 1.6)\n",
               format_supports_external_lookups=True),
-         dict(format_name='1.6-rich-root',
+         dict(format_name='1.6.1-rich-root',
               format_string="Bazaar RepositoryFormatKnitPack5RichRoot "
-                  "(bzr 1.6)\n",
+                  "(bzr 1.6.1)\n",
               format_supports_external_lookups=True),
          dict(format_name='development0',
               format_string="Bazaar development format 0 "

=== modified file 'bzrlib/tests/test_upgrade_stacked.py'
--- a/bzrlib/tests/test_upgrade_stacked.py	2008-08-04 07:55:41 +0000
+++ b/bzrlib/tests/test_upgrade_stacked.py	2008-08-29 05:18:56 +0000
@@ -74,7 +74,7 @@
 #        ('knit', 'rich-root', True),
         ('knit', '1.6', False),
 #        ('pack-0.92', '1.6', False),
-        ('1.6', '1.6-rich-root', True),
+        ('1.6', '1.6.1-rich-root', True),
         ]
     scenarios = []
     for (old_name, new_name, model_change) in scenario_pairs:



More information about the bazaar-commits mailing list