Rev 4184: Add RepositoryFormat.fast_deltas to signal fast delta creation. in http://people.ubuntu.com/~robertc/baz2.0/pending/commit-uses-ric

Robert Collins robertc at robertcollins.net
Mon Mar 23 05:48:21 GMT 2009


At http://people.ubuntu.com/~robertc/baz2.0/pending/commit-uses-ric

------------------------------------------------------------
revno: 4184
revision-id: robertc at robertcollins.net-20090323054814-0y1yph3zuafxgen6
parent: pqm at pqm.ubuntu.com-20090323043327-txb4jri5i3gssuj5
committer: Robert Collins <robertc at robertcollins.net>
branch nick: commit-uses-ric
timestamp: Mon 2009-03-23 16:48:14 +1100
message:
  Add RepositoryFormat.fast_deltas to signal fast delta creation.
=== modified file 'NEWS'
--- a/NEWS	2009-03-23 03:07:13 +0000
+++ b/NEWS	2009-03-23 05:48:14 +0000
@@ -160,6 +160,10 @@
 Internals
 *********
 
+* ``bzr selftest`` now accepts ``--subunit`` to run in subunit output
+  mode. Requires ``lp:subunit`` installed to work, but is not a hard
+  dependency. (Robert Collins)
+
 * ``BtreeIndex._spill_mem_keys_to_disk()`` now generates disk index with
   optmizations turned off. This only has effect when processing > 100,000
   keys during something like ``bzr pack``. (John Arbash Meinel)
@@ -187,9 +191,9 @@
   ``InterPackToRemotePack`` classes, as they are now unnecessary.
   (Andrew Bennetts)
 
-* ``bzr selftest`` now accepts ``--subunit`` to run in subunit output
-  mode. Requires ``lp:subunit`` installed to work, but is not a hard
-  dependency. (Robert Collins)
+* ``RepositoryFormat`` as a new attribute ``fast_deltas`` to indicate
+  whether the repository can efficiently generate deltas between trees
+  regardless of tree size. (Robert Collins)
 
 * ``_walk_to_common_revisions`` will now batch up at least 50
   revisions before calling ``get_parent_map`` on the target,

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2009-03-22 01:30:44 +0000
+++ b/bzrlib/remote.py	2009-03-23 05:48:14 +0000
@@ -417,6 +417,11 @@
         self._rich_root_data = None
 
     @property
+    def fast_deltas(self):
+        self._ensure_real()
+        return self._custom_format.fast_deltas
+
+    @property
     def rich_root_data(self):
         if self._rich_root_data is None:
             self._ensure_real()

=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py	2009-03-16 05:05:52 +0000
+++ b/bzrlib/repofmt/knitrepo.py	2009-03-23 05:48:14 +0000
@@ -299,6 +299,7 @@
     supports_external_lookups = False
     _fetch_order = 'topological'
     _fetch_uses_deltas = True
+    fast_deltas = False
 
     def _get_inventories(self, repo_transport, repo, name='inventory'):
         mapper = versionedfile.ConstantMapper(name)

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2009-03-16 05:33:31 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2009-03-23 05:48:14 +0000
@@ -2271,6 +2271,7 @@
     index_builder_class = None
     index_class = None
     _fetch_uses_deltas = True
+    fast_deltas = False
 
     def initialize(self, a_bzrdir, shared=False):
         """Create a pack based repository.
@@ -2666,6 +2667,9 @@
     # What index classes to use
     index_builder_class = BTreeBuilder
     index_class = BTreeGraphIndex
+    # Set to true to get the fast-commit code path tested until a really fast
+    # format lands in trunk. Not actually fast in this format.
+    fast_deltas = True
 
     @property
     def _serializer(self):

=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py	2009-02-27 01:02:40 +0000
+++ b/bzrlib/repofmt/weaverepo.py	2009-03-23 05:48:14 +0000
@@ -268,6 +268,7 @@
     supports_external_lookups = False
     _fetch_order = 'topological'
     _fetch_reconcile = True
+    fast_deltas = False
 
     def initialize(self, a_bzrdir, shared=False, _internal=False):
         """Create a weave repository."""
@@ -475,6 +476,7 @@
     supports_ghosts = False
     _fetch_order = 'topological'
     _fetch_reconcile = True
+    fast_deltas = False
     @property
     def _serializer(self):
         return xml5.serializer_v5

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2009-03-23 03:46:02 +0000
+++ b/bzrlib/repository.py	2009-03-23 05:48:14 +0000
@@ -2661,6 +2661,9 @@
     # Should fetch trigger a reconcile after the fetch? Only needed for
     # some repository formats that can suffer internal inconsistencies.
     _fetch_reconcile = False
+    # Does this format have < O(tree_size) delta generation. Used to hint what
+    # code path for commit, amongst other things.
+    fast_deltas = None
 
     def __str__(self):
         return "<%s>" % self.__class__.__name__

=== modified file 'bzrlib/tests/per_repository/test_repository.py'
--- a/bzrlib/tests/per_repository/test_repository.py	2009-03-22 01:30:44 +0000
+++ b/bzrlib/tests/per_repository/test_repository.py	2009-03-23 05:48:14 +0000
@@ -78,6 +78,12 @@
         repo = tree.branch.repository
         self.assertTrue(repo._format._fetch_uses_deltas in (True, False))
 
+    def test_attribute_fast_deltas(self):
+        """Test the format.fast_deltas attribute."""
+        tree = self.make_branch_and_tree('tree')
+        repo = tree.branch.repository
+        self.assertTrue(repo._format.fast_deltas in (True, False))
+
     def test_attribute__fetch_reconcile(self):
         """Test the the _fetch_reconcile attribute."""
         tree = self.make_branch_and_tree('tree')

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2009-03-18 01:27:58 +0000
+++ b/bzrlib/tests/test_remote.py	2009-03-23 05:48:14 +0000
@@ -46,7 +46,9 @@
     RemoteBzrDir,
     RemoteBzrDirFormat,
     RemoteRepository,
+    RemoteRepositoryFormat,
     )
+from bzrlib.repofmt import pack_repo
 from bzrlib.revision import NULL_REVISION
 from bzrlib.smart import server, medium
 from bzrlib.smart.client import _SmartClient
@@ -1450,6 +1452,19 @@
         return repo, client
 
 
+class TestRepositoryFormat(TestRemoteRepository):
+
+    def test_fast_delta(self):
+        true_name = pack_repo.RepositoryFormatPackDevelopment2().network_name()
+        true_format = RemoteRepositoryFormat()
+        true_format._network_name = true_name
+        self.assertEqual(True, true_format.fast_deltas)
+        false_name = pack_repo.RepositoryFormatKnitPack1().network_name()
+        false_format = RemoteRepositoryFormat()
+        false_format._network_name = false_name
+        self.assertEqual(False, false_format.fast_deltas)
+
+
 class TestRepositoryGatherStats(TestRemoteRepository):
 
     def test_revid_none(self):




More information about the bazaar-commits mailing list