Rev 4539: Move the fix for bug 395556 to update_minimal, avoiding fallout in other set_state_from_inventory calls, as aliasing is actually needed. in http://bazaar.launchpad.net/~lifeless/bzr/bug-395556

Robert Collins robertc at robertcollins.net
Thu Jul 16 01:38:22 BST 2009


At http://bazaar.launchpad.net/~lifeless/bzr/bug-395556

------------------------------------------------------------
revno: 4539
revision-id: robertc at robertcollins.net-20090716003813-aww7uc3s7zf67yym
parent: robertc at robertcollins.net-20090716000117-u7kc320lzvg5tbaa
committer: Robert Collins <robertc at robertcollins.net>
branch nick: bug-395556
timestamp: Thu 2009-07-16 10:38:13 +1000
message:
  Move the fix for bug 395556 to update_minimal, avoiding fallout in other set_state_from_inventory calls, as aliasing is actually needed.
=== modified file 'NEWS'
--- a/NEWS	2009-07-15 01:13:20 +0000
+++ b/NEWS	2009-07-16 00:38:13 +0000
@@ -27,8 +27,7 @@
 
 * Renames to lexographically lower basenames in trees that have never been
   committed to will no longer corrupt the dirstate. This was caused by an
-  aliasing bug in the dirstate set_state_from_inventory method.
-  (Robert Collins, #395556)
+  bug in the dirstate update_minimal method. (Robert Collins, #395556)
 
 Improvements
 ************

=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2009-07-16 00:01:17 +0000
+++ b/bzrlib/dirstate.py	2009-07-16 00:38:13 +0000
@@ -2644,17 +2644,29 @@
                     # relocations when updating an existing record but its not:
                     # the test for existing kinds is different: this can be
                     # factored out to a helper though.
-                    other_block_index, present = self._find_block_index_from_key(other_key)
+                    other_block_index, present = self._find_block_index_from_key(
+                        other_key)
                     if not present:
-                        raise AssertionError('could not find block for %s' % (other_key,))
+                        raise AssertionError('could not find block for %s' % (
+                            other_key,))
                     other_entry_index, present = self._find_entry_index(other_key,
                                             self._dirblocks[other_block_index][1])
                     if not present:
-                        raise AssertionError('could not find entry for %s' % (other_key,))
+                        raise AssertionError('could not find entry for %s' % (
+                            other_key,))
                     if path_utf8 is None:
                         raise AssertionError('no path')
-                    self._dirblocks[other_block_index][1][other_entry_index][1][0] = \
+                    other_block = self._dirblocks[other_block_index][1]
+                    # Turn this other location into a reference to the new
+                    # location. This also updates the aliased iterator that
+                    # set_state_from_inventory uses so that the old entry, if
+                    # not already examined, is skipped over.
+                    other_block[other_entry_index][1][0] = \
                         ('r', path_utf8, 0, False, '')
+                    if len(other_block[other_entry_index][1]) == 1:
+                        # We only have one tree in use, so an 'r' record is not
+                        # needed: remove it.
+                        other_block.pop(other_entry_index)
 
                 num_present_parents = self._num_present_parents()
                 for lookup_index in xrange(1, num_present_parents + 1):




More information about the bazaar-commits mailing list