Rev 3326: * ``VersionedFile.clone_text`` is deprecated. This performance optimisation in http://people.ubuntu.com/~robertc/baz2.0/versioned_files

Robert Collins robertc at robertcollins.net
Tue Apr 8 05:13:22 BST 2008


At http://people.ubuntu.com/~robertc/baz2.0/versioned_files

------------------------------------------------------------
revno: 3326
revision-id: robertc at robertcollins.net-20080408041308-lfbh0gmvwfhc53yx
parent: robertc at robertcollins.net-20080408033943-ihbgs5wyqnh61bit
committer: Robert Collins <robertc at robertcollins.net>
branch nick: api-cleanup
timestamp: Tue 2008-04-08 14:13:08 +1000
message:
   * ``VersionedFile.clone_text`` is deprecated. This performance optimisation
     is no longer used - reading the content of a file that is undergoing a
     file level merge to identical state on two branches is rare enough, and
     not expensive enough to special case. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
  bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
  bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
  bzrlib/weave.py                knit.py-20050627021749-759c29984154256b
=== modified file 'NEWS'
--- a/NEWS	2008-04-08 03:39:43 +0000
+++ b/NEWS	2008-04-08 04:13:08 +0000
@@ -140,6 +140,11 @@
       than using a call to ``transaction_finished``, allowing the removal of
       the fixed list of versioned files per repository. (Robert Collins)
 
+    * ``VersionedFile.clone_text`` is deprecated. This performance optimisation
+      is no longer used - reading the content of a file that is undergoing a
+      file level merge to identical state on two branches is rare enough, and
+      not expensive enough to special case. (Robert Collins)
+
     * ``VersionedFile.create_empty`` is removed. This method presupposed a
       sensible mapping to a transport for individual files, but pack backed
       versioned files have no such mapping. (Robert Collins)

=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2008-04-08 03:39:43 +0000
+++ b/bzrlib/knit.py	2008-04-08 04:13:08 +0000
@@ -1101,12 +1101,6 @@
     def check(self, progress_bar=None):
         """See VersionedFile.check()."""
 
-    def _clone_text(self, new_version_id, old_version_id, parents):
-        """See VersionedFile.clone_text()."""
-        # FIXME RBC 20060228 make fast by only inserting an index with null 
-        # delta.
-        self.add_lines(new_version_id, parents, self.get_lines(old_version_id))
-
     def get_lines(self, version_id):
         """See VersionedFile.get_lines()."""
         return self.get_line_list([version_id])[0]

=== modified file 'bzrlib/tests/test_versionedfile.py'
--- a/bzrlib/tests/test_versionedfile.py	2008-04-08 03:39:43 +0000
+++ b/bzrlib/tests/test_versionedfile.py	2008-04-08 04:13:08 +0000
@@ -359,7 +359,6 @@
         self.assertRaises(errors.OutSideTransaction, f.add_lines, '', [], [])
         self.assertRaises(errors.OutSideTransaction, f.add_lines_with_ghosts, '', [], [])
         self.assertRaises(errors.OutSideTransaction, f.join, '')
-        self.assertRaises(errors.OutSideTransaction, f.clone_text, 'base', 'bar', ['foo'])
         
     def test_clear_cache(self):
         f = self.get_file()
@@ -373,15 +372,15 @@
     def test_clone_text(self):
         f = self.get_file()
         f.add_lines('r0', [], ['a\n', 'b\n'])
-        f.clone_text('r1', 'r0', ['r0'])
+        self.applyDeprecated(one_four, f.clone_text, 'r1', 'r0', ['r0'])
         def verify_file(f):
             self.assertEquals(f.get_lines('r1'), f.get_lines('r0'))
             self.assertEquals(f.get_lines('r1'), ['a\n', 'b\n'])
             self.assertEqual({'r1':('r0',)}, f.get_parent_map(['r1']))
             self.assertRaises(RevisionNotPresent,
-                f.clone_text, 'r2', 'rX', [])
+                self.applyDeprecated, one_four, f.clone_text, 'r2', 'rX', [])
             self.assertRaises(RevisionAlreadyPresent,
-                f.clone_text, 'r1', 'r0', [])
+                self.applyDeprecated, one_four, f.clone_text, 'r1', 'r0', [])
         verify_file(f)
         verify_file(self.reopen_file())
 
@@ -704,7 +703,6 @@
                           [],
                           [])
         self.assertRaises(errors.ReadOnlyError, vf.join, 'base')
-        self.assertRaises(errors.ReadOnlyError, vf.clone_text, 'base', 'bar', ['foo'])
     
     def test_get_sha1s(self):
         # check the sha1 data is available

=== modified file 'bzrlib/versionedfile.py'
--- a/bzrlib/versionedfile.py	2008-04-08 03:39:43 +0000
+++ b/bzrlib/versionedfile.py	2008-04-08 04:13:08 +0000
@@ -171,6 +171,7 @@
         """
         pass
 
+    @deprecated_method(one_four)
     def clone_text(self, new_version_id, old_version_id, parents):
         """Add an identical text to old_version_id as new_version_id.
 
@@ -180,11 +181,8 @@
         Must raise RevisionAlreadyPresent if the new version is
         already present in file history."""
         self._check_write_ok()
-        return self._clone_text(new_version_id, old_version_id, parents)
-
-    def _clone_text(self, new_version_id, old_version_id, parents):
-        """Helper function to do the _clone_text work."""
-        raise NotImplementedError(self.clone_text)
+        return self.add_lines(new_version_id, parents,
+            self.get_lines(old_version_id))
 
     def get_format_signature(self):
         """Get a text description of the data encoding in this file.

=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py	2008-04-08 03:39:43 +0000
+++ b/bzrlib/weave.py	2008-04-08 04:13:08 +0000
@@ -419,11 +419,6 @@
                 offset += 2 + (j2 - j1)
         return new_version
 
-    def _clone_text(self, new_version_id, old_version_id, parents):
-        """See VersionedFile.clone_text."""
-        old_lines = self.get_text(old_version_id)
-        self.add_lines(new_version_id, parents, old_lines)
-
     def _inclusions(self, versions):
         """Return set of all ancestors of given version(s)."""
         if not len(versions):
@@ -905,11 +900,6 @@
         self._save()
         return result
 
-    def _clone_text(self, new_version_id, old_version_id, parents):
-        """See VersionedFile.clone_text."""
-        super(WeaveFile, self)._clone_text(new_version_id, old_version_id, parents)
-        self._save
-
     def copy_to(self, name, transport):
         """See VersionedFile.copy_to()."""
         # as we are all in memory always, just serialise to the new place.




More information about the bazaar-commits mailing list