Rev 3011: Add support for rich-root format in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Nov 22 04:21:32 GMT 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3011
revision-id: pqm at pqm.ubuntu.com-20071122042129-w0k63wqlxo09i4xb
parent: pqm at pqm.ubuntu.com-20071121045727-gqycrul94d0ssir1
parent: aaron.bentley at utoronto.ca-20071122032911-e8p1v3tu3o11mdm1
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2007-11-22 04:21:29 +0000
message:
  Add support for rich-root format
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/repofmt/knitrepo.py     knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
  bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
  bzrlib/tests/test_info.py      test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
    ------------------------------------------------------------
    revno: 2996.2.9
    merged: aaron.bentley at utoronto.ca-20071122032911-e8p1v3tu3o11mdm1
    parent: aaron.bentley at utoronto.ca-20071118192542-jw7j3sqqraratw0m
    parent: pqm at pqm.ubuntu.com-20071121045727-gqycrul94d0ssir1
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: rich-root
    timestamp: Wed 2007-11-21 22:29:11 -0500
    message:
      Merge bzr.dev
    ------------------------------------------------------------
    revno: 2996.2.8
    merged: aaron.bentley at utoronto.ca-20071118192542-jw7j3sqqraratw0m
    parent: aaron.bentley at utoronto.ca-20071118184712-8hyvjolf9gvq5a0r
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: rich-root
    timestamp: Sun 2007-11-18 14:25:42 -0500
    message:
      Fix add_signature discrepancies
    ------------------------------------------------------------
    revno: 2996.2.7
    merged: aaron.bentley at utoronto.ca-20071118184712-8hyvjolf9gvq5a0r
    parent: aaron.bentley at utoronto.ca-20071118184335-rjptgedxv4357lna
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: rich-root
    timestamp: Sun 2007-11-18 13:47:12 -0500
    message:
      Update NEWS
    ------------------------------------------------------------
    revno: 2996.2.6
    merged: aaron.bentley at utoronto.ca-20071118184335-rjptgedxv4357lna
    parent: aaron.bentley at utoronto.ca-20071118184217-3rko8v8ewfukrtfw
    parent: pqm at pqm.ubuntu.com-20071117180742-59zhz30s7839y41j
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: rich-root
    timestamp: Sun 2007-11-18 13:43:35 -0500
    message:
      Merge from bzr.dev
    ------------------------------------------------------------
    revno: 2996.2.5
    merged: aaron.bentley at utoronto.ca-20071118184217-3rko8v8ewfukrtfw
    parent: aaron.bentley at utoronto.ca-20071117175425-q236vj7y57ltotpp
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: rich-root
    timestamp: Sun 2007-11-18 13:42:17 -0500
    message:
      Correct docstring
    ------------------------------------------------------------
    revno: 2996.2.4
    merged: aaron.bentley at utoronto.ca-20071117175425-q236vj7y57ltotpp
    parent: aaron.bentley at utoronto.ca-20071115060401-wfp0g00mfmw3pdha
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: rich-root
    timestamp: Sat 2007-11-17 12:54:25 -0500
    message:
      Rename function to add_signature_text
    ------------------------------------------------------------
    revno: 2996.2.3
    merged: aaron.bentley at utoronto.ca-20071115060401-wfp0g00mfmw3pdha
    parent: aaron.bentley at utoronto.ca-20071115051956-g7i5mleab9evq1c7
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: rich-root
    timestamp: Thu 2007-11-15 01:04:01 -0500
    message:
      Add tests for install_revisions and add_signature
    ------------------------------------------------------------
    revno: 2996.2.2
    merged: aaron.bentley at utoronto.ca-20071115051956-g7i5mleab9evq1c7
    parent: aaron.bentley at utoronto.ca-20071115040832-ta9k8osywsvmh47o
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: rich-root
    timestamp: Thu 2007-11-15 00:19:56 -0500
    message:
      Create install_revisions function
    ------------------------------------------------------------
    revno: 2996.2.1
    merged: aaron.bentley at utoronto.ca-20071115040832-ta9k8osywsvmh47o
    parent: pqm at pqm.ubuntu.com-20071114233259-pdmdsqafctzx6bjs
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: rich-root
    timestamp: Wed 2007-11-14 23:08:32 -0500
    message:
      Add KnitRepositoryFormat4
=== modified file 'NEWS'
--- a/NEWS	2007-11-19 22:54:30 +0000
+++ b/NEWS	2007-11-22 03:29:11 +0000
@@ -22,6 +22,9 @@
      supported transports.
      (Vincent Ladeuil)
 
+   * New rich-root format, recording the same data about tree roots that's
+     recorded for all other directories.  (Aaron Bentley)
+
   PERFORMANCE:
 
    * Commit updates the state of the working tree via a delta rather than

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2007-11-14 12:53:19 +0000
+++ b/bzrlib/bzrdir.py	2007-11-18 18:43:35 +0000
@@ -2487,6 +2487,14 @@
     branch_format='bzrlib.branch.BzrBranchFormat6',
     tree_format='bzrlib.workingtree.WorkingTreeFormat4',
     )
+format_registry.register_metadir('rich-root',
+    'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4',
+    help='New in 1.0.  Better handling of tree roots.  Incompatible with'
+        ' bzr < 1.0',
+    branch_format='bzrlib.branch.BzrBranchFormat6',
+    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+    hidden=False,
+    )
 format_registry.register_metadir('dirstate-with-subtree',
     'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
     help='New in 0.15: Fast local operations and improved scaling for '

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2007-11-16 05:36:12 +0000
+++ b/bzrlib/remote.py	2007-11-18 19:25:42 +0000
@@ -796,6 +796,10 @@
         return self._real_repository.store_revision_signature(
             gpg_strategy, plaintext, revision_id)
 
+    def add_signature_text(self, revision_id, signature):
+        self._ensure_real()
+        return self._real_repository.add_signature_text(revision_id, signature)
+
     def has_signature_for_revision_id(self, revision_id):
         self._ensure_real()
         return self._real_repository.has_signature_for_revision_id(revision_id)

=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py	2007-10-30 17:39:11 +0000
+++ b/bzrlib/repofmt/knitrepo.py	2007-11-18 18:42:17 +0000
@@ -32,6 +32,7 @@
     osutils,
     transactions,
     xml5,
+    xml6,
     xml7,
     )
 
@@ -457,7 +458,7 @@
 
 
 class RepositoryFormatKnit3(RepositoryFormatKnit):
-    """Bzr repository knit format 2.
+    """Bzr repository knit format 3.
 
     This repository format has:
      - knits for file texts and inventory
@@ -503,6 +504,50 @@
         return "Knit repository format 3"
 
 
+class RepositoryFormatKnit4(RepositoryFormatKnit):
+    """Bzr repository knit format 4.
+
+    This repository format has everything in format 3, except for
+    tree-references:
+     - 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
+     - support for recording full info about the tree root
+    """
+
+    repository_class = KnitRepository
+    _commit_builder_class = RootCommitBuilder
+    rich_root_data = True
+    supports_tree_reference = False
+    _serializer = xml6.serializer_v6
+
+    def _get_matching_bzrdir(self):
+        return bzrdir.format_registry.make_bzrdir('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 Knit Repository Format 4 (bzr 1.0)\n'
+
+    def get_format_description(self):
+        """See RepositoryFormat.get_format_description()."""
+        return "Knit repository format 4"
+
+
 def _get_stream_as_bytes(knit, required_versions):
     """Generate a serialised data stream.
 

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-11-09 17:50:31 +0000
+++ b/bzrlib/repository.py	2007-11-18 19:25:42 +0000
@@ -1051,6 +1051,10 @@
     @needs_write_lock
     def store_revision_signature(self, gpg_strategy, plaintext, revision_id):
         signature = gpg_strategy.sign(plaintext)
+        self.add_signature_text(revision_id, signature)
+
+    @needs_write_lock
+    def add_signature_text(self, revision_id, signature):
         self._revision_store.add_revision_signature_text(revision_id,
                                                          signature,
                                                          self.get_transaction())
@@ -1628,9 +1632,19 @@
 
 def install_revision(repository, rev, revision_tree):
     """Install all revision data into a repository."""
+    install_revisions(repository, [(rev, revision_tree, None)])
+
+
+def install_revisions(repository, iterable):
+    """Install all revision data into a repository.
+
+    Accepts an iterable of revision, tree, signature tuples.  The signature
+    may be None.
+    """
     repository.start_write_group()
     try:
-        _install_revision(repository, rev, revision_tree)
+        for revision, revision_tree, signature in iterable:
+            _install_revision(repository, revision, revision_tree, signature)
     except:
         repository.abort_write_group()
         raise
@@ -1638,7 +1652,7 @@
         repository.commit_write_group()
 
 
-def _install_revision(repository, rev, revision_tree):
+def _install_revision(repository, rev, revision_tree, signature):
     """Install all revision data into a repository."""
     present_parents = []
     parent_trees = {}
@@ -1683,6 +1697,8 @@
         repository.add_inventory(rev.revision_id, inv, present_parents)
     except errors.RevisionAlreadyPresent:
         pass
+    if signature is not None:
+        repository.add_signature_text(rev.revision_id, signature)
     repository.add_revision(rev.revision_id, rev, inv)
 
 
@@ -1983,6 +1999,12 @@
     'RepositoryFormatKnit3',
     )
 
+format_registry.register_lazy(
+    'Bazaar Knit Repository Format 4 (bzr 1.0)\n',
+    'bzrlib.repofmt.knitrepo',
+    'RepositoryFormatKnit4',
+    )
+
 # Pack-based formats. There is one format for pre-subtrees, and one for
 # post-subtrees to allow ease of testing.
 # NOTE: These are experimental in 0.92.
@@ -2495,6 +2517,43 @@
         return f.count_copied, f.failed_revisions
 
 
+class InterDifferingSerializer(InterKnitRepo):
+
+    @classmethod
+    def _get_repo_format_to_test(self):
+        return None
+
+    @staticmethod
+    def is_compatible(source, target):
+        """Be compatible with Knit2 source and Knit3 target"""
+        if source.supports_rich_root() != target.supports_rich_root():
+            return False
+        # Ideally, we'd support fetching if the source had no tree references
+        # even if it supported them...
+        if (getattr(source, '_format.supports_tree_reference', False) and
+            not getattr(target, '_format.supports_tree_reference', False)):
+            return False
+        return True
+
+    @needs_write_lock
+    def fetch(self, revision_id=None, pb=None, find_ghosts=False):
+        """See InterRepository.fetch()."""
+        revision_ids = self.target.missing_revision_ids(self.source,
+                                                        revision_id)
+        def revisions_iterator():
+            for current_revision_id in revision_ids:
+                revision = self.source.get_revision(current_revision_id)
+                tree = self.source.revision_tree(current_revision_id)
+                try:
+                    signature = self.source.get_signature_text(
+                        current_revision_id)
+                except errors.NoSuchRevision:
+                    signature = None
+                yield revision, tree, signature
+        install_revisions(self.target, revisions_iterator())
+        return len(revision_ids), 0
+
+
 class InterRemoteToOther(InterRepository):
 
     def __init__(self, source, target):
@@ -2564,6 +2623,7 @@
         return None
 
 
+InterRepository.register_optimiser(InterDifferingSerializer)
 InterRepository.register_optimiser(InterSameDataRepository)
 InterRepository.register_optimiser(InterWeaveRepo)
 InterRepository.register_optimiser(InterKnitRepo)

=== modified file 'bzrlib/tests/blackbox/test_info.py'
--- a/bzrlib/tests/blackbox/test_info.py	2007-10-25 04:57:32 +0000
+++ b/bzrlib/tests/blackbox/test_info.py	2007-11-15 04:08:32 +0000
@@ -263,7 +263,8 @@
         branch5 = tree5.branch
         out, err = self.run_bzr('info -v lightcheckout')
         self.assertEqualDiff(
-"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
+"""Lightweight checkout (format: dirstate or dirstate-tags or \
+knitpack-experimental or rich-root)
 Location:
   light checkout root: lightcheckout
    checkout of branch: standalone
@@ -441,7 +442,8 @@
         # Out of date lightweight checkout
         out, err = self.run_bzr('info lightcheckout --verbose')
         self.assertEqualDiff(
-"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
+"""Lightweight checkout (format: dirstate or dirstate-tags or \
+knitpack-experimental or rich-root)
 Location:
   light checkout root: lightcheckout
    checkout of branch: standalone
@@ -579,7 +581,8 @@
         datestring_first = format_date(rev.timestamp, rev.timezone)
         out, err = self.run_bzr('info tree/lightcheckout --verbose')
         self.assertEqualDiff(
-"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
+"""Lightweight checkout (format: dirstate or dirstate-tags or \
+knitpack-experimental or rich-root)
 Location:
   light checkout root: tree/lightcheckout
    checkout of branch: repo/branch
@@ -710,7 +713,8 @@
         datestring_last = format_date(rev.timestamp, rev.timezone)
         out, err = self.run_bzr('info tree/lightcheckout --verbose')
         self.assertEqualDiff(
-"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
+"""Lightweight checkout (format: dirstate or dirstate-tags or \
+knitpack-experimental or rich-root)
 Location:
   light checkout root: tree/lightcheckout
    checkout of branch: repo/branch
@@ -1149,7 +1153,8 @@
             (False, True): 'Lightweight checkout',
             (False, False): 'Checkout',
             }[(shared_repo is not None, light_checkout)]
-        format = {True: 'dirstate or dirstate-tags or knitpack-experimental',
+        format = {True: 'dirstate or dirstate-tags or knitpack-experimental'
+                        ' or rich-root',
                   False: 'dirstate'}[light_checkout]
         if repo_locked or branch_locked or tree_locked:
             def locked_message(a_bool):

=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py	2007-10-17 09:39:41 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py	2007-11-17 17:54:25 +0000
@@ -28,7 +28,7 @@
     )
 from bzrlib.delta import TreeDelta
 from bzrlib.inventory import Inventory, InventoryDirectory
-from bzrlib.revision import NULL_REVISION
+from bzrlib.revision import NULL_REVISION, Revision
 from bzrlib.tests import TestCaseWithTransport, TestSkipped
 from bzrlib.tests.repository_implementations import TestCaseWithRepository
 from bzrlib.transport import get_transport
@@ -533,6 +533,41 @@
         list(repo._find_inconsistent_revision_parents())
         repo._check_for_inconsistent_revision_parents()
 
+    def test_add_signature_text(self):
+        repo = self.make_repository('repo')
+        repo.lock_write()
+        self.addCleanup(repo.unlock)
+        self.addCleanup(repo.commit_write_group)
+        repo.start_write_group()
+        inv = Inventory(revision_id='A')
+        inv.root.revision = 'A'
+        repo.add_inventory('A', inv, [])
+        repo.add_revision('A', Revision('A', committer='A', timestamp=0,
+                          inventory_sha1='', timezone=0, message='A'))
+        repo.add_signature_text('A', 'This might be a signature')
+        self.assertEqual('This might be a signature',
+                         repo.get_signature_text('A'))
+
+    def test_install_revisions(self):
+        wt = self.make_branch_and_tree('source')
+        wt.commit('A', allow_pointless=True, rev_id='A')
+        repo = wt.branch.repository
+        repo.lock_write()
+        repo.start_write_group()
+        repo.sign_revision('A', bzrlib.gpg.LoopbackGPGStrategy(None))
+        repo.commit_write_group()
+        repo.unlock()
+        repo.lock_read()
+        self.addCleanup(repo.unlock)
+        repo2 = self.make_repository('repo2')
+        revision = repo.get_revision('A')
+        tree = repo.revision_tree('A')
+        signature = repo.get_signature_text('A')
+        repo2.lock_write()
+        self.addCleanup(repo2.unlock)
+        repository.install_revisions(repo2, [(revision, tree, signature)])
+        self.assertEqual(revision, repo2.get_revision('A'))
+        self.assertEqual(signature, repo2.get_signature_text('A'))
 
 class TestRepositoryLocking(TestCaseWithRepository):
 

=== modified file 'bzrlib/tests/test_info.py'
--- a/bzrlib/tests/test_info.py	2007-10-25 04:57:32 +0000
+++ b/bzrlib/tests/test_info.py	2007-11-15 04:08:32 +0000
@@ -139,8 +139,10 @@
                 continue
             expected = None
             if key in ('dirstate', 'dirstate-tags', 'dirstate-with-subtree',
-                'knitpack-experimental', 'knitpack-subtree-experimental'):
-                expected = 'dirstate or dirstate-tags or knitpack-experimental'
+                'knitpack-experimental', 'knitpack-subtree-experimental',
+                'rich-root'):
+                expected = 'dirstate or dirstate-tags or'\
+                    ' knitpack-experimental or rich-root'
             if key in ('knit', 'metaweave'):
                 expected = 'knit or metaweave'
             self.assertCheckoutDescription(key, expected)




More information about the bazaar-commits mailing list