Merge lp:~vila/bzr/494221-unversion-children into lp:bzr/2.0

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 4752
Proposed branch: lp:~vila/bzr/494221-unversion-children
Merge into: lp:bzr/2.0
Diff against target: 67 lines (+27/-3)
3 files modified
NEWS (+3/-0)
bzrlib/tests/test_workingtree_4.py (+21/-1)
bzrlib/workingtree_4.py (+3/-2)
To merge this branch: bzr merge lp:~vila/bzr/494221-unversion-children
Reviewer Review Type Date Requested Status
John A Meinel Needs Fixing
Review via email: mp+29782@code.launchpad.net

Commit message

Ensure we don't try to remove entries twice from the in-memory inventory.

Description of the change

This fixes bug #494221, with a test reproducing it.

While working on it with John, we encounter several bugs that made it harder to implement a better fix.

So this fix is minimal and targeted at 2.0 but better fixes will be targeted at trunk.

The issue at hand is that the in-memory inventory needs to be updated if it has already been loaded which occurs more often on windows than on linux.

We probably fixed the original bug on linux long ago so this fix should mostly concern windows.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

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

Vincent Ladeuil wrote:
> Vincent Ladeuil has proposed merging lp:~vila/bzr/494221-unversion-children into lp:bzr/2.0.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> #494221 KeyError in remove_recursive_id during commit
> https://bugs.launchpad.net/bugs/494221
>
>
> This fixes bug #494221, with a test reproducing it.
>
> While working on it with John, we encounter several bugs that made it harder to implement a better fix.
>
> So this fix is minimal and targeted at 2.0 but better fixes will be targeted at trunk.
>
> The issue at hand is that the in-memory inventory needs to be updated if it has already been loaded which occurs more often on windows than on linux.
>
> We probably fixed the original bug on linux long ago so this fix should mostly concern windows.
>

 review: needsfixing

Small tweak. The test should check that the file-ids are actually
removed from the inventory. Otherwise good to merge.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkw8P9wACgkQJdeBCYSNAAP7wACfahJWOqloMEIsQUo+CwwKWcgR
fHkAniiNRT/eUPWxmvoteiWdle0DxMpS
=wWQQ
-----END PGP SIGNATURE-----

review: Needs Fixing
Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-05-28 17:59:55 +0000
3+++ NEWS 2010-07-13 10:31:38 +0000
4@@ -26,6 +26,9 @@
5 permissions as ``.bzr`` directory on a POSIX OS.
6 (Parth Malwankar, #262450)
7
8+* Don't traceback trying to unversion children files of an already
9+ unversioned directory. (Vincent Ladeuil, #494221)
10+
11 * Raise ValueError instead of a string exception.
12 (John Arbash Meinel, #586926)
13
14
15=== modified file 'bzrlib/tests/test_workingtree_4.py'
16--- bzrlib/tests/test_workingtree_4.py 2009-08-26 03:20:32 +0000
17+++ bzrlib/tests/test_workingtree_4.py 2010-07-13 10:31:38 +0000
18@@ -1,4 +1,4 @@
19-# Copyright (C) 2005, 2006 Canonical Ltd
20+# Copyright (C) 2007-2010 Canonical Ltd
21 # Authors: Robert Collins <robert.collins@canonical.com>
22 #
23 # This program is free software; you can redistribute it and/or modify
24@@ -761,3 +761,23 @@
25 ('', [(('', 'dir', 'dir-id'), ['d', 'd'])]),
26 ('dir', [(('dir', 'file', 'file-id'), ['a', 'f'])]),
27 ], self.get_simple_dirblocks(state))
28+
29+
30+class TestInventoryCoherency(TestCaseWithTransport):
31+
32+ def test_inventory_is_synced_when_unversioning_a_dir(self):
33+ """Unversioning the root of a subtree unversions the entire subtree."""
34+ tree = self.make_branch_and_tree('.')
35+ self.build_tree(['a/', 'a/b', 'c/'])
36+ tree.add(['a', 'a/b', 'c'], ['a-id', 'b-id', 'c-id'])
37+ # within a lock unversion should take effect
38+ tree.lock_write()
39+ self.addCleanup(tree.unlock)
40+ # Force access to the in memory inventory to trigger bug #494221: try
41+ # maintaining the in-memory inventory
42+ inv = tree.inventory
43+ self.assertTrue(inv.has_id('a-id'))
44+ self.assertTrue(inv.has_id('b-id'))
45+ tree.unversion(['a-id', 'b-id'])
46+ self.assertFalse(inv.has_id('a-id'))
47+ self.assertFalse(inv.has_id('b-id'))
48
49=== modified file 'bzrlib/workingtree_4.py'
50--- bzrlib/workingtree_4.py 2009-09-30 21:38:49 +0000
51+++ bzrlib/workingtree_4.py 2010-07-13 10:31:38 +0000
52@@ -1,4 +1,4 @@
53-# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
54+# Copyright (C) 2007-2010 Canonical Ltd
55 #
56 # This program is free software; you can redistribute it and/or modify
57 # it under the terms of the GNU General Public License as published by
58@@ -1236,7 +1236,8 @@
59 # have to change the legacy inventory too.
60 if self._inventory is not None:
61 for file_id in file_ids:
62- self._inventory.remove_recursive_id(file_id)
63+ if self._inventory.has_id(file_id):
64+ self._inventory.remove_recursive_id(file_id)
65
66 @needs_tree_write_lock
67 def rename_one(self, from_rel, to_rel, after=False):

Subscribers

People subscribed via source and target branches