Merge lp:~jameinel/bzr/2.4-tree-root-dirstate-830947 into lp:bzr/2.4

Proposed by John A Meinel
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 6075
Proposed branch: lp:~jameinel/bzr/2.4-tree-root-dirstate-830947
Merge into: lp:bzr/2.4
Diff against target: 53 lines (+14/-7)
2 files modified
bzrlib/dirstate.py (+10/-7)
doc/en/release-notes/bzr-2.4.txt (+4/-0)
To merge this branch: bzr merge lp:~jameinel/bzr/2.4-tree-root-dirstate-830947
Reviewer Review Type Date Requested Status
Richard Wilbur Approve
Review via email: mp+164617@code.launchpad.net

Commit message

Fix bug #830947. Dirstate.set_root_id() should update the id_index correctly.

The symptom is that if you have a tree with the file_id TREE_ROOT somewhere other than at '', it could cause 'bzr co' to fail because it tries to lookup the file in the id_index map, but it incorrectly points to a location ('') where the id never existed.

Description of the change

This fixes bug #830947.

Basically, there was a patch from Ian that I wasn't sure about, but we merged it. Turns out it introduced a bug. Specifically, when changing the root id of a newly created tree, it was forcing the old root id into the id_index map. However, that entry doesn't actually exist (because we are forcibly removing it.) So we don't want to add it.

update_minimal should be doing the right thing anyway.

This updates Dirstate._validate to validate the id_index more carefully.

I backported the patch the 2.4 because that is the first release that has the bug.

To post a comment you must log in.
Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

Thanks for the fix and for back-porting it to 2.4. Does this affect 2.5 and trunk?
Seems like this would be a great candidate for merging into all affected, maintained versions.
+1

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2013-05-20 9:15, Richard Wilbur wrote:
> Review: Approve
>
> Thanks for the fix and for back-porting it to 2.4. Does this
> affect 2.5 and trunk? Seems like this would be a great candidate
> for merging into all affected, maintained versions. +1
>

Yes it does. Which is why I targeted 2.4 and intend to merge it up the
stack.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlGZyhcACgkQJdeBCYSNAAO06QCfZRz46AsH5cRhGp5LssIjUCHt
2wsAoLzd1Pu6MVxB2irZYDgN/yVAjulG
=DSG5
-----END PGP SIGNATURE-----

Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/dirstate.py'
--- bzrlib/dirstate.py 2011-09-28 15:41:38 +0000
+++ bzrlib/dirstate.py 2013-05-23 08:02:28 +0000
@@ -2609,13 +2609,6 @@
2609 self.update_minimal(('', '', new_id), 'd',2609 self.update_minimal(('', '', new_id), 'd',
2610 path_utf8='', packed_stat=entry[1][0][4])2610 path_utf8='', packed_stat=entry[1][0][4])
2611 self._mark_modified()2611 self._mark_modified()
2612 # XXX: This was added by Ian, we need to make sure there
2613 # are tests for it, because it isn't in bzr.dev TRUNK
2614 # It looks like the only place it is called is in setting the root
2615 # id of the tree. So probably we never had an _id_index when we
2616 # don't even have a root yet.
2617 if self._id_index is not None:
2618 self._add_to_id_index(self._id_index, entry[0])
26192612
2620 def set_parent_trees(self, trees, ghosts):2613 def set_parent_trees(self, trees, ghosts):
2621 """Set the parent trees for the dirstate.2614 """Set the parent trees for the dirstate.
@@ -3328,10 +3321,20 @@
3328 if self._id_index is not None:3321 if self._id_index is not None:
3329 for file_id, entry_keys in self._id_index.iteritems():3322 for file_id, entry_keys in self._id_index.iteritems():
3330 for entry_key in entry_keys:3323 for entry_key in entry_keys:
3324 # Check that the entry in the map is pointing to the same
3325 # file_id
3331 if entry_key[2] != file_id:3326 if entry_key[2] != file_id:
3332 raise AssertionError(3327 raise AssertionError(
3333 'file_id %r did not match entry key %s'3328 'file_id %r did not match entry key %s'
3334 % (file_id, entry_key))3329 % (file_id, entry_key))
3330 # And that from this entry key, we can look up the original
3331 # record
3332 block_index, present = self._find_block_index_from_key(entry_key)
3333 if not present:
3334 raise AssertionError('missing block for entry key: %r', entry_key)
3335 entry_index, present = self._find_entry_index(entry_key, self._dirblocks[block_index][1])
3336 if not present:
3337 raise AssertionError('missing entry for key: %r', entry_key)
3335 if len(entry_keys) != len(set(entry_keys)):3338 if len(entry_keys) != len(set(entry_keys)):
3336 raise AssertionError(3339 raise AssertionError(
3337 'id_index contained non-unique data for %s'3340 'id_index contained non-unique data for %s'
33383341
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- doc/en/release-notes/bzr-2.4.txt 2012-06-08 06:59:50 +0000
+++ doc/en/release-notes/bzr-2.4.txt 2013-05-23 08:02:28 +0000
@@ -35,6 +35,10 @@
35* Cope with Unix filesystems, such as smbfs, where chmod gives 'permission35* Cope with Unix filesystems, such as smbfs, where chmod gives 'permission
36 denied'. (Martin Pool, #606537)36 denied'. (Martin Pool, #606537)
3737
38* Fix a traceback when trying to checkout a tree that also has an entry
39 with file-id `TREE_ROOT` somewhere other than at the root directory.
40 (John Arbash Meinel, #830947)
41
38* When the ``limbo`` or ``pending-deletion`` directories exist, typically42* When the ``limbo`` or ``pending-deletion`` directories exist, typically
39 because of an interrupted tree update, but are empty, bzr no longer43 because of an interrupted tree update, but are empty, bzr no longer
40 errors out, because there is nothing for the user to clean up. Also,44 errors out, because there is nothing for the user to clean up. Also,

Subscribers

People subscribed via source and target branches