Rev 3566: * The generic fetch code now uses two attributes on Repository objects in http://people.ubuntu.com/~robertc/baz2.0/btree-graphindex

Robert Collins robertc at robertcollins.net
Mon Jul 28 06:12:11 BST 2008


At http://people.ubuntu.com/~robertc/baz2.0/btree-graphindex

------------------------------------------------------------
revno: 3566
revision-id: robertc at robertcollins.net-20080728050954-iyok0yyqonml80q7
parent: pqm at pqm.ubuntu.com-20080718100017-segv2csk7ux2xs9p
committer: Robert Collins <robertc at robertcollins.net>
branch nick: btree-graphindex
timestamp: Mon 2008-07-28 15:09:54 +1000
message:
   * The generic fetch code now uses two attributes on Repository objects
     to control the requested streams: ``_fetch_order`` and
     ``_fetch_uses_deltas``. Setting these appropriately allows different
     repository implementations to recieve data in their optimial form.
     (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/_patiencediff_py.py     cdvdifflib.py-20051106064558-f8f8097fbf0db4e4
  bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-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/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
  bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
=== modified file 'NEWS'
--- a/NEWS	2008-07-18 08:40:57 +0000
+++ b/NEWS	2008-07-28 05:09:54 +0000
@@ -36,6 +36,11 @@
 
   API CHANGES:
 
+    * The generic fetch code now uses two attributes on Repository objects
+      to control the requested streams: ``_fetch_order`` and
+      ``_fetch_uses_deltas``. Setting these appropriately allows different
+      repository implementations to recieve data in their optimial form.
+      (Robert Collins)
 
   INTERNALS:
 

=== modified file 'bzrlib/_patiencediff_py.py'
--- a/bzrlib/_patiencediff_py.py	2008-05-08 04:12:06 +0000
+++ b/bzrlib/_patiencediff_py.py	2008-07-28 05:09:54 +0000
@@ -176,7 +176,7 @@
     length = 0
     for i_a, i_b in matches:
         if (start_a is not None
-            and (i_a == start_a + length) 
+            and (i_a == start_a + length)
             and (i_b == start_b + length)):
             length += 1
         else:

=== modified file 'bzrlib/fetch.py'
--- a/bzrlib/fetch.py	2008-06-25 10:06:48 +0000
+++ b/bzrlib/fetch.py	2008-07-28 05:09:54 +0000
@@ -179,7 +179,8 @@
                     to_texts = self.to_repository.texts
                     from_texts = self.from_repository.texts
                     to_texts.insert_record_stream(from_texts.get_record_stream(
-                        text_keys, 'topological', False))
+                        text_keys, self.to_repository._fetch_order,
+                        self.to_repository._fetch_uses_deltas))
                     # Cause an error if a text occurs after we have done the
                     # copy.
                     text_keys = None
@@ -239,7 +240,8 @@
             # corrupt.
             to_weave.insert_record_stream(from_weave.get_record_stream(
                 [(rev_id,) for rev_id in revs],
-                'topological', False))
+                self.to_repository._fetch_order,
+                self.to_repository._fetch_uses_deltas))
         finally:
             child_pb.finished()
 
@@ -301,7 +303,8 @@
         # A missing signature is just skipped.
         to_sf.insert_record_stream(filter_absent(from_sf.get_record_stream(
             [(rev_id,) for rev_id in revs],
-            'unordered', False)))
+            self.to_repository._fetch_order,
+            self.to_repository._fetch_uses_deltas)))
         self._fetch_just_revision_texts(revs)
 
     def _fetch_just_revision_texts(self, version_ids):
@@ -309,7 +312,8 @@
         from_rf = self.from_repository.revisions
         to_rf.insert_record_stream(from_rf.get_record_stream(
             [(rev_id,) for rev_id in version_ids],
-            'topological', False))
+            self.to_repository._fetch_order,
+            self.to_repository._fetch_uses_deltas))
 
 
 class Inter1and2Helper(object):

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2008-07-17 00:43:32 +0000
+++ b/bzrlib/remote.py	2008-07-28 05:09:54 +0000
@@ -820,6 +820,26 @@
         self._ensure_real()
         return self._real_repository.iter_files_bytes(desired_files)
 
+    @property
+    def _fetch_order(self):
+        """Decorate the real repository for now.
+
+        In the long term getting this back from the remote repository as part
+        of open would be more efficient.
+        """
+        self._ensure_real()
+        return self._real_repository._fetch_order
+
+    @property
+    def _fetch_uses_deltas(self):
+        """Decorate the real repository for now.
+
+        In the long term getting this back from the remote repository as part
+        of open would be more efficient.
+        """
+        self._ensure_real()
+        return self._real_repository._fetch_uses_deltas
+
     def get_parent_map(self, keys):
         """See bzrlib.Graph.get_parent_map()."""
         # Hack to build up the caching logic.

=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py	2008-06-11 07:22:00 +0000
+++ b/bzrlib/repofmt/knitrepo.py	2008-07-28 05:09:54 +0000
@@ -130,6 +130,8 @@
         self._commit_builder_class = _commit_builder_class
         self._serializer = _serializer
         self._reconcile_fixes_text_parents = True
+        self._fetch_uses_deltas = True
+        self._fetch_order = 'topological'
 
     def _warn_if_deprecated(self):
         # This class isn't deprecated

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2008-07-16 00:45:57 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2008-07-28 05:09:54 +0000
@@ -1728,6 +1728,7 @@
         self._reconcile_does_inventory_gc = True
         self._reconcile_fixes_text_parents = True
         self._reconcile_backsup_inventory = False
+        self._fetch_order = 'unsorted'
 
     def _abort_write_group(self):
         self._pack_collection._abort_write_group()

=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py	2008-06-18 07:56:09 +0000
+++ b/bzrlib/repofmt/weaverepo.py	2008-07-28 05:09:54 +0000
@@ -85,6 +85,7 @@
             self.inventory_store = get_store('inventory-store')
             self._text_store = get_store('text-store')
         super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files)
+        self._fetch_order = 'topological'
 
     @needs_read_lock
     def _all_possible_ids(self):
@@ -178,6 +179,10 @@
 
     _serializer = xml5.serializer_v5
 
+    def __init__(self, _format, a_bzrdir, control_files):
+        super(WeaveMetaDirRepository, self).__init__(_format, a_bzrdir, control_files)
+        self._fetch_order = 'topological'
+
     @needs_read_lock
     def _all_possible_ids(self):
         """Return all the possible revisions that we could find."""
@@ -317,6 +322,7 @@
 
     def __init__(self):
         super(RepositoryFormat4, self).__init__()
+        self._fetch_order = 'topological'
 
     def get_format_description(self):
         """See RepositoryFormat.get_format_description()."""
@@ -368,6 +374,7 @@
 
     def __init__(self):
         super(RepositoryFormat5, self).__init__()
+        self._fetch_order = 'topological'
 
     def get_format_description(self):
         """See RepositoryFormat.get_format_description()."""
@@ -410,6 +417,7 @@
 
     def __init__(self):
         super(RepositoryFormat6, self).__init__()
+        self._fetch_order = 'topological'
 
     def get_format_description(self):
         """See RepositoryFormat.get_format_description()."""

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2008-07-16 14:23:05 +0000
+++ b/bzrlib/repository.py	2008-07-28 05:09:54 +0000
@@ -691,6 +691,15 @@
         self._write_group = None
         # Additional places to query for data.
         self._fallback_repositories = []
+        # What order should fetch operations request streams in?
+        # The default is unsorted as that is the cheapest for an origin to
+        # provide.
+        self._fetch_order = 'unsorted'
+        # Does this repository use deltas that can be fetched as-deltas ?
+        # (E.g. knits, where the knit deltas can be transplanted intact.
+        # We default to False, which will ensure that enough data to get
+        # a full text out of any fetch stream will be grabbed.
+        self._fetch_uses_deltas = False
 
     def __repr__(self):
         return '%s(%r)' % (self.__class__.__name__,

=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py	2008-07-15 05:06:13 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py	2008-07-28 05:09:54 +0000
@@ -64,6 +64,18 @@
 
 class TestRepository(TestCaseWithRepository):
 
+    def test_attribute__fetch_order(self):
+        """Test the the _fetch_order attribute."""
+        tree = self.make_branch_and_tree('tree')
+        repo = tree.branch.repository
+        self.assertTrue(repo._fetch_order in ('topological', 'unsorted'))
+
+    def test_attribute__fetch_uses_deltas(self):
+        """Test the the _fetch_uses_deltas attribute."""
+        tree = self.make_branch_and_tree('tree')
+        repo = tree.branch.repository
+        self.assertTrue(repo._fetch_uses_deltas in (True, False))
+
     def test_attribute_inventories_store(self):
         """Test the existence of the inventories attribute."""
         tree = self.make_branch_and_tree('tree')

=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py	2008-07-14 06:39:43 +0000
+++ b/bzrlib/tests/test_repository.py	2008-07-28 05:09:54 +0000
@@ -162,6 +162,18 @@
 
 class TestFormat6(TestCaseWithTransport):
 
+    def test_attribute__fetch_order(self):
+        """Weaves need topological data insertion."""
+        control = bzrdir.BzrDirFormat6().initialize(self.get_url())
+        repo = weaverepo.RepositoryFormat6().initialize(control)
+        self.assertEqual('topological', repo._fetch_order)
+
+    def test_attribute__fetch_uses_deltas(self):
+        """Weaves do not reuse deltas."""
+        control = bzrdir.BzrDirFormat6().initialize(self.get_url())
+        repo = weaverepo.RepositoryFormat6().initialize(control)
+        self.assertEqual(False, repo._fetch_uses_deltas)
+
     def test_no_ancestry_weave(self):
         control = bzrdir.BzrDirFormat6().initialize(self.get_url())
         repo = weaverepo.RepositoryFormat6().initialize(control)
@@ -178,7 +190,19 @@
 
 
 class TestFormat7(TestCaseWithTransport):
-    
+
+    def test_attribute__fetch_order(self):
+        """Weaves need topological data insertion."""
+        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
+        repo = weaverepo.RepositoryFormat7().initialize(control)
+        self.assertEqual('topological', repo._fetch_order)
+
+    def test_attribute__fetch_uses_deltas(self):
+        """Weaves do not reuse deltas."""
+        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
+        repo = weaverepo.RepositoryFormat7().initialize(control)
+        self.assertEqual(False, repo._fetch_uses_deltas)
+
     def test_disk_layout(self):
         control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
         repo = weaverepo.RepositoryFormat7().initialize(control)
@@ -307,6 +331,18 @@
 
 class TestFormatKnit1(TestCaseWithTransport):
     
+    def test_attribute__fetch_order(self):
+        """Knits need topological data insertion."""
+        repo = self.make_repository('.',
+                format=bzrdir.format_registry.get('knit')())
+        self.assertEqual('topological', repo._fetch_order)
+
+    def test_attribute__fetch_uses_deltas(self):
+        """Knits reuse deltas."""
+        repo = self.make_repository('.',
+                format=bzrdir.format_registry.get('knit')())
+        self.assertEqual(True, repo._fetch_uses_deltas)
+
     def test_disk_layout(self):
         control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
         repo = knitrepo.RepositoryFormatKnit1().initialize(control)
@@ -558,6 +594,20 @@
 
 class TestRepositoryFormatKnit3(TestCaseWithTransport):
 
+    def test_attribute__fetch_order(self):
+        """Knits need topological data insertion."""
+        format = bzrdir.BzrDirMetaFormat1()
+        format.repository_format = knitrepo.RepositoryFormatKnit3()
+        repo = self.make_repository('.', format=format)
+        self.assertEqual('topological', repo._fetch_order)
+
+    def test_attribute__fetch_uses_deltas(self):
+        """Knits reuse deltas."""
+        format = bzrdir.BzrDirMetaFormat1()
+        format.repository_format = knitrepo.RepositoryFormatKnit3()
+        repo = self.make_repository('.', format=format)
+        self.assertEqual(True, repo._fetch_uses_deltas)
+
     def test_convert(self):
         """Ensure the upgrade adds weaves for roots"""
         format = bzrdir.BzrDirMetaFormat1()
@@ -682,6 +732,18 @@
     def get_format(self):
         return bzrdir.format_registry.make_bzrdir('pack-0.92')
 
+    def test_attribute__fetch_order(self):
+        """Packs do not need ordered data retrieval."""
+        format = self.get_format()
+        repo = self.make_repository('.', format=format)
+        self.assertEqual('unsorted', repo._fetch_order)
+
+    def test_attribute__fetch_uses_deltas(self):
+        """Packs reuse deltas."""
+        format = self.get_format()
+        repo = self.make_repository('.', format=format)
+        self.assertEqual(True, repo._fetch_uses_deltas)
+
     def test_disk_layout(self):
         format = self.get_format()
         repo = self.make_repository('.', format=format)




More information about the bazaar-commits mailing list