Rev 6516: Merge lp:bzr/2.4 @6078. in http://bazaar.launchpad.net/~jameinel/2.5/2.5-merges-2.4

John Arbash Meinel john at arbash-meinel.com
Thu May 30 11:42:38 UTC 2013


At http://bazaar.launchpad.net/~jameinel/2.5/2.5-merges-2.4

------------------------------------------------------------
revno: 6516 [merge]
revision-id: john at arbash-meinel.com-20130530114230-821cc73oq682lqtd
parent: john at arbash-meinel.com-20130530113859-jhexdbtzd8firdnw
parent: pqm at pqm.ubuntu.com-20130529083855-0l5uxl8yjrp7gskp
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.5-merges-2.4
timestamp: Thu 2013-05-30 12:42:30 +0100
message:
  Merge lp:bzr/2.4 @6078.
  
  This brings in the fix for bug #855155 (Dirstate.update_basis_by_delta).
modified:
  bzrlib/dirstate.py             dirstate.py-20060728012006-d6mvoihjb3je9peu-1
  bzrlib/tests/blackbox/test_uncommit.py test_uncommit.py-20051027212835-84944b63adae51be
  bzrlib/tests/per_workingtree/test_parents.py test_set_parents.py-20060807231740-yicmnlci1mj8smu1-1
  bzrlib/tests/test_dirstate.py  test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
  doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2013-05-23 09:27:10 +0000
+++ b/bzrlib/dirstate.py	2013-05-30 11:42:30 +0000
@@ -1648,9 +1648,18 @@
             entry_key = st(dirname, basename, file_id)
             block_index, present = self._find_block_index_from_key(entry_key)
             if not present:
-                self._raise_invalid(new_path, file_id,
-                    "Unable to find block for this record."
-                    " Was the parent added?")
+                # The block where we want to put the file is not present.
+                # However, it might have just been an empty directory. Look for
+                # the parent in the basis-so-far before throwing an error.
+                parent_dir, parent_base = osutils.split(dirname)
+                parent_block_idx, parent_entry_idx, _, parent_present = \
+                    self._get_block_entry_index(parent_dir, parent_base, 1)
+                if not parent_present:
+                    self._raise_invalid(new_path, file_id,
+                        "Unable to find block for this record."
+                        " Was the parent added?")
+                self._ensure_block(parent_block_idx, parent_entry_idx, dirname)
+
             block = self._dirblocks[block_index][1]
             entry_index, present = self._find_entry_index(entry_key, block)
             if real_add:

=== modified file 'bzrlib/tests/blackbox/test_uncommit.py'
--- a/bzrlib/tests/blackbox/test_uncommit.py	2011-12-14 20:21:52 +0000
+++ b/bzrlib/tests/blackbox/test_uncommit.py	2013-05-30 11:42:30 +0000
@@ -314,3 +314,20 @@
         self.assertLength(14, self.hpss_calls)
         self.assertLength(1, self.hpss_connections)
         self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
+
+
+class TestInconsistentDelta(TestCaseWithTransport):
+    # See https://bugs.launchpad.net/bzr/+bug/855155
+    # See https://bugs.launchpad.net/bzr/+bug/1100385
+    # bzr uncommit may result in error
+    # 'An inconsistent delta was supplied involving'
+
+    def test_inconsistent_delta(self):
+        # Script taken from https://bugs.launchpad.net/bzr/+bug/855155/comments/26
+        wt = self.make_branch_and_tree('test')
+        self.build_tree(['test/a/', 'test/a/b', 'test/a/c'])
+        wt.add(['a', 'a/b', 'a/c'])
+        wt.commit('initial commit', rev_id='a1')
+        wt.remove(['a/b', 'a/c'])
+        wt.commit('remove b and c', rev_id='a2')
+        self.run_bzr("uncommit --force test")

=== modified file 'bzrlib/tests/per_workingtree/test_parents.py'
--- a/bzrlib/tests/per_workingtree/test_parents.py	2012-09-06 09:00:45 +0000
+++ b/bzrlib/tests/per_workingtree/test_parents.py	2013-05-30 11:42:30 +0000
@@ -450,7 +450,7 @@
             self.add_dir(new_shape, new_revid, 'root-id', None, '')
 
     def assertTransitionFromBasisToShape(self, basis_shape, basis_revid,
-        new_shape, new_revid, extra_parent=None):
+        new_shape, new_revid, extra_parent=None, set_current_inventory=True):
         # set the inventory revision ids.
         basis_shape.revision_id = basis_revid
         new_shape.revision_id = new_revid
@@ -465,8 +465,9 @@
                 parents.append(extra_parent)
             tree.set_parent_ids(parents)
         self.fake_up_revision(tree, new_revid, new_shape)
-        # give tree an inventory of new_shape
-        tree._write_inventory(new_shape)
+        if set_current_inventory:
+            # give tree an inventory of new_shape
+            tree._write_inventory(new_shape)
         self.assertDeltaApplicationResultsInExpectedBasis(tree, new_revid,
             delta, new_shape)
         # The tree should be internally consistent; while this is a moderately
@@ -764,3 +765,17 @@
         self.add_link(new_shape, old_revid, 'link-id-C', 'dir-id-B', 'C', 'D')
         self.assertTransitionFromBasisToShape(basis_shape, old_revid,
             new_shape, new_revid)
+
+    def test_add_files_to_empty_directory(self):
+        old_revid = 'old-parent'
+        basis_shape = Inventory(root_id=None)
+        self.add_dir(basis_shape, old_revid, 'root-id', None, '')
+        self.add_dir(basis_shape, old_revid, 'dir-id-A', 'root-id', 'A')
+        new_revid = 'new-parent'
+        new_shape = Inventory(root_id=None)
+        self.add_new_root(new_shape, old_revid, new_revid)
+        self.add_dir(new_shape, old_revid, 'dir-id-A', 'root-id', 'A')
+        self.add_file(new_shape, new_revid, 'file-id-B', 'dir-id-A', 'B',
+            '1' * 32, 24)
+        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
+                new_shape, new_revid, set_current_inventory=False)

=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py	2011-06-14 01:26:41 +0000
+++ b/bzrlib/tests/test_dirstate.py	2013-05-30 11:42:30 +0000
@@ -2480,7 +2480,12 @@
     def create_tree_from_shape(self, rev_id, shape):
         dir_ids = {'': 'root-id'}
         inv = inventory.Inventory('root-id', rev_id)
-        for path, file_id in shape:
+        for info in shape:
+            if len(info) == 2:
+                path, file_id = info
+                ie_rev_id = rev_id
+            else:
+                path, file_id, ie_rev_id = info
             if path == '':
                 # Replace the root entry
                 del inv._byid[inv.root.file_id]
@@ -2488,7 +2493,7 @@
                 inv._byid[file_id] = inv.root
                 dir_ids[''] = file_id
                 continue
-            inv.add(self.path_to_ie(path, file_id, rev_id, dir_ids))
+            inv.add(self.path_to_ie(path, file_id, ie_rev_id, dir_ids))
         return revisiontree.InventoryRevisionTree(_Repo(), inv, rev_id)
 
     def create_empty_dirstate(self):
@@ -2616,6 +2621,13 @@
             target=[('file', 'file-id')],
             )
 
+    def test_add_file_in_empty_dir_not_matching_active_state(self):
+        state = self.assertUpdate(
+                active=[],
+                basis=[('dir/', 'dir-id')],
+                target=[('dir/', 'dir-id', 'basis'), ('dir/file', 'file-id')],
+                )
+
     def test_add_file_missing_in_active_state(self):
         state = self.assertUpdate(
             active=[],

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2013-05-30 11:38:59 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2013-05-30 11:42:30 +0000
@@ -140,6 +140,10 @@
 * Fixed loading of external merge tools from config to properly decode
   command-lines which contain embedded quotes. (Gordon Tyler, #828803)
 
+* Handle when an uncommit/update tries to add a file to an otherwise empty
+  directory. The ``Dirstate.update_basis_by_delta`` would end up
+  incorrectly flagging the delta as invalid. (Brian de Alwis, #855155)
+
 * Include declaration of 'changed' to avoid an UnboundLocalError in dirstate
   pyrex code with new Cython versions. (Denys Duchier, #837221)
 



More information about the bazaar-commits mailing list