Rev 2808: * The ``VersionedFile`` interface no longer protects against misuse when in http://people.ubuntu.com/~robertc/baz2.0/knits

Robert Collins robertc at robertcollins.net
Mon Sep 10 04:37:53 BST 2007


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

------------------------------------------------------------
revno: 2808
revision-id: robertc at robertcollins.net-20070910033719-nqsmg72617f0tvyo
parent: robertc at robertcollins.net-20070910025423-qeqnv361y8yukjzc
committer: Robert Collins <robertc at robertcollins.net>
branch nick: knits
timestamp: Mon 2007-09-10 13:37:19 +1000
message:
  * The ``VersionedFile`` interface no longer protects against misuse when
    lines that are not lines, or are not strings are supplied. This saves
    nearly 30% of the minimum cost to store a version of a file.
    (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
=== modified file 'NEWS'
--- a/NEWS	2007-09-07 13:33:03 +0000
+++ b/NEWS	2007-09-10 03:37:19 +0000
@@ -186,6 +186,11 @@
      allows the avoidance of double-sha1 calculations during commit.
      (Robert Collins)
 
+   * The ``VersionedFile`` interface no longer protects against misuse when
+     lines that are not lines, or are not strings are supplied. This saves
+     nearly 30% of the minimum cost to store a version of a file.
+     (Robert Collins)
+
    * ``Transport.should_cache`` has been removed.  It was not called in the
      previous release.  (Martin Pool)
 

=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2007-09-10 02:54:23 +0000
+++ b/bzrlib/knit.py	2007-09-10 03:37:19 +0000
@@ -858,8 +858,6 @@
         #   larger percentage.
         if self.has_version(version_id):
             raise RevisionAlreadyPresent(version_id, self.filename)
-        self._check_lines_not_unicode(lines)
-        self._check_lines_are_lines(lines)
 
     def _add(self, version_id, lines, parents, delta, parent_texts,
              left_matching_blocks, nostore_sha):

=== modified file 'bzrlib/tests/test_versionedfile.py'
--- a/bzrlib/tests/test_versionedfile.py	2007-09-06 05:58:13 +0000
+++ b/bzrlib/tests/test_versionedfile.py	2007-09-10 03:37:19 +0000
@@ -115,16 +115,6 @@
         f = self.reopen_file()
         verify_file(f)
 
-    def test_add_unicode_content(self):
-        # unicode content is not permitted in versioned files. 
-        # versioned files version sequences of bytes only.
-        vf = self.get_file()
-        self.assertRaises(errors.BzrBadParameterUnicode,
-            vf.add_lines, 'a', [], ['a\n', u'b\n', 'c\n'])
-        self.assertRaises(
-            (errors.BzrBadParameterUnicode, NotImplementedError),
-            vf.add_lines_with_ghosts, 'a', [], ['a\n', u'b\n', 'c\n'])
-
     def test_add_follows_left_matching_blocks(self):
         """If we change left_matching_blocks, delta changes
 
@@ -142,21 +132,6 @@
                      left_matching_blocks=[(0, 2, 1), (1, 3, 0)])
         self.assertEqual(['a\n', 'a\n', 'a\n'], vf.get_lines('3'))
 
-    def test_inline_newline_throws(self):
-        # \r characters are not permitted in lines being added
-        vf = self.get_file()
-        self.assertRaises(errors.BzrBadParameterContainsNewline, 
-            vf.add_lines, 'a', [], ['a\n\n'])
-        self.assertRaises(
-            (errors.BzrBadParameterContainsNewline, NotImplementedError),
-            vf.add_lines_with_ghosts, 'a', [], ['a\n\n'])
-        # but inline CR's are allowed
-        vf.add_lines('a', [], ['a\r\n'])
-        try:
-            vf.add_lines_with_ghosts('b', [], ['a\r\n'])
-        except NotImplementedError:
-            pass
-
     def test_add_reserved(self):
         vf = self.get_file()
         self.assertRaises(errors.ReservedId,

=== modified file 'bzrlib/versionedfile.py'
--- a/bzrlib/versionedfile.py	2007-09-05 22:25:01 +0000
+++ b/bzrlib/versionedfile.py	2007-09-10 03:37:19 +0000
@@ -86,11 +86,19 @@
 
         Must raise RevisionNotPresent if any of the given parents are
         not present in file history.
+
+        :param lines: A list of lines. Each line must be a bytestring. And all
+            of them except the last must be terminated with \n and contain no
+            other \n's. The last line may either contain no \n's or a single
+            terminated \n. If the lines list does meet this constraint the add
+            routine may error or may succeed - but you will be unable to read
+            the data back accurately. (Checking the lines have been split
+            correctly is expensive and extermely unlikely to catch bugs so it
+            is not done at runtime.)
         :param parent_texts: An optional dictionary containing the opaque 
-             representations of some or all of the parents of 
-             version_id to allow delta optimisations. 
-             VERY IMPORTANT: the texts must be those returned
-             by add_lines or data corruption can be caused.
+            representations of some or all of the parents of version_id to
+            allow delta optimisations.  VERY IMPORTANT: the texts must be those
+            returned by add_lines or data corruption can be caused.
         :param left_matching_blocks: a hint about which areas are common
             between the text and its left-hand-parent.  The format is
             the SequenceMatcher.get_matching_blocks format.



More information about the bazaar-commits mailing list