Rev 2724: Fix bundle installation wrong-versionedfile bug in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Aug 17 18:49:36 BST 2007


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

------------------------------------------------------------
revno: 2724
revision-id: pqm at pqm.ubuntu.com-20070817174934-5094ol577uv7ys4u
parent: pqm at pqm.ubuntu.com-20070817132000-jr6dro4qkhf7uzwp
parent: abentley at panoramicfeedback.com-20070817161909-91z4kplou7hzk2uf
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-08-17 18:49:34 +0100
message:
  Fix bundle installation wrong-versionedfile bug
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/bundle/serializer/v4.py v10.py-20070611062757-5ggj7k18s9dej0fr-1
  bzrlib/tests/test_bundle.py    test.py-20050630184834-092aa401ab9f039c
    ------------------------------------------------------------
    revno: 2520.4.151.1.5
    merged: abentley at panoramicfeedback.com-20070817161909-91z4kplou7hzk2uf
    parent: aaron.bentley at utoronto.ca-20070817152057-mo73o1wy3xj4176a
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: bundle-fix
    timestamp: Fri 2007-08-17 12:19:09 -0400
    message:
      Skip for bundle formats that don't provide get_bundle_reader
    ------------------------------------------------------------
    revno: 2520.4.151.1.4
    merged: aaron.bentley at utoronto.ca-20070817152057-mo73o1wy3xj4176a
    parent: aaron.bentley at utoronto.ca-20070817151901-uq7s6qusfxdeqguv
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: bundle-fix
    timestamp: Fri 2007-08-17 11:20:57 -0400
    message:
      Update NEWS
    ------------------------------------------------------------
    revno: 2520.4.151.1.3
    merged: aaron.bentley at utoronto.ca-20070817151901-uq7s6qusfxdeqguv
    parent: aaron.bentley at utoronto.ca-20070817005348-2pypollw3p9diii8
    parent: pqm at pqm.ubuntu.com-20070817132000-jr6dro4qkhf7uzwp
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: bundle-fix
    timestamp: Fri 2007-08-17 11:19:01 -0400
    message:
      merge bzr.dev
    ------------------------------------------------------------
    revno: 2520.4.151.1.2
    merged: aaron.bentley at utoronto.ca-20070817005348-2pypollw3p9diii8
    parent: abentley at panoramicfeedback.com-20070815161519-aw3u3mgqelrwg0hy
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: bundle-fix
    timestamp: Thu 2007-08-16 20:53:48 -0400
    message:
      Fix bundle installation wrong-versionedfile bug
    ------------------------------------------------------------
    revno: 2520.4.151.1.1
    merged: abentley at panoramicfeedback.com-20070815161519-aw3u3mgqelrwg0hy
    parent: abentley at panoramicfeedback.com-20070727194336-vowoapmp4oae10ik
    parent: pqm at pqm.ubuntu.com-20070815155635-7o7uhuh1ggjomeh4
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: bzr.mpbundle
    timestamp: Wed 2007-08-15 12:15:19 -0400
    message:
      Merge bzr.dev
=== modified file 'NEWS'
--- a/NEWS	2007-08-17 05:16:14 +0000
+++ b/NEWS	2007-08-17 15:20:57 +0000
@@ -17,6 +17,9 @@
     * Suppress warning "integer argument expected, got float" from Paramiko,
       which sometimes caused false test failures.  (Martin Pool)
 
+    * Fix bug in bunle 4 that could cause attempts to write data to wrong
+      versionedfile.  (Aaron Bentley)
+
   IMPROVEMENTS:
 
     * ``pull`` and ``merge`` are much faster at installing bundle format 4.

=== modified file 'bzrlib/bundle/serializer/v4.py'
--- a/bzrlib/bundle/serializer/v4.py	2007-08-14 23:56:36 +0000
+++ b/bzrlib/bundle/serializer/v4.py	2007-08-17 00:53:48 +0000
@@ -479,10 +479,10 @@
             if repo_kind == 'info':
                 assert self._info is None
                 self._handle_info(metadata)
-            if ((repo_kind, file_id) != ('file', current_file) and
-                len(pending_file_records) > 0):
-                self._install_mp_records(current_versionedfile,
-                    pending_file_records)
+            if (repo_kind, file_id) != ('file', current_file):
+                if len(pending_file_records) > 0:
+                    self._install_mp_records(current_versionedfile,
+                                             pending_file_records)
                 current_file = None
                 current_versionedfile = None
                 pending_file_records = []

=== modified file 'bzrlib/tests/test_bundle.py'
--- a/bzrlib/tests/test_bundle.py	2007-08-14 23:35:48 +0000
+++ b/bzrlib/tests/test_bundle.py	2007-08-17 16:19:09 +0000
@@ -1063,6 +1063,33 @@
                               " slashes")
         bundle = self.get_valid_bundle('null:', 'rev/id')
 
+    def test_skip_file(self):
+        """Make sure we don't accidentally write to the wrong versionedfile"""
+        self.tree1 = self.make_branch_and_tree('tree')
+        self.b1 = self.tree1.branch
+        # rev1 is not present in bundle, done by fetch
+        self.build_tree_contents([('tree/file2', 'contents1')])
+        self.tree1.add('file2', 'file2-id')
+        self.tree1.commit('rev1', rev_id='reva')
+        self.build_tree_contents([('tree/file3', 'contents2')])
+        # rev2 is present in bundle, and done by fetch
+        # having file1 in the bunle causes file1's versionedfile to be opened.
+        self.tree1.add('file3', 'file3-id')
+        self.tree1.commit('rev2')
+        # Updating file2 should not cause an attempt to add to file1's vf
+        target = self.tree1.bzrdir.sprout('target').open_workingtree()
+        self.build_tree_contents([('tree/file2', 'contents3')])
+        self.tree1.commit('rev3', rev_id='rev3')
+        bundle = self.get_valid_bundle('reva', 'rev3')
+        if getattr(bundle, 'get_bundle_reader', None) is None:
+            raise TestSkipped('Bundle format cannot provide reader')
+        # be sure that file1 comes before file2
+        for b, m, k, r, f in bundle.get_bundle_reader().iter_records():
+            if f == 'file3-id':
+                break
+            self.assertNotEqual(f, 'file2-id')
+        bundle.install_revisions(target.branch.repository)
+
 
 class V08BundleTester(BundleTester, TestCaseWithTransport):
 




More information about the bazaar-commits mailing list