Rev 6028: (jameinel) Use a set during Inventory.filter() to handle when a file is in file:///home/pqm/archives/thelove/bzr/2.4/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Aug 10 09:38:12 UTC 2011
At file:///home/pqm/archives/thelove/bzr/2.4/
------------------------------------------------------------
revno: 6028 [merge]
revision-id: pqm at pqm.ubuntu.com-20110810093809-perfac4es3i9goy3
parent: pqm at pqm.ubuntu.com-20110809201657-03q8kptf7tn1c9mw
parent: bastian.bowe at gmail.com-20110808160256-9rjnro7w66n1e3sm
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.4
timestamp: Wed 2011-08-10 09:38:09 +0000
message:
(jameinel) Use a set during Inventory.filter() to handle when a file is
referenced multiple times. (bug #809901) (Bastian)
modified:
bzrlib/inventory.py inventory.py-20050309040759-6648b84ca2005b37
bzrlib/tests/test_inv.py testinv.py-20050722220913-1dc326138d1a5892
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py 2011-06-14 02:21:41 +0000
+++ b/bzrlib/inventory.py 2011-08-08 12:47:07 +0000
@@ -1490,8 +1490,8 @@
if entry.kind == 'directory':
directories_to_expand.add(entry.file_id)
interesting.add(entry.parent_id)
- children_of_parent_id.setdefault(entry.parent_id, []
- ).append(entry.file_id)
+ children_of_parent_id.setdefault(entry.parent_id, set()
+ ).add(entry.file_id)
# Now, interesting has all of the direct parents, but not the
# parents of those parents. It also may have some duplicates with
@@ -1505,8 +1505,8 @@
next_parents = set()
for entry in self._getitems(remaining_parents):
next_parents.add(entry.parent_id)
- children_of_parent_id.setdefault(entry.parent_id, []
- ).append(entry.file_id)
+ children_of_parent_id.setdefault(entry.parent_id, set()
+ ).add(entry.file_id)
# Remove any search tips we've already processed
remaining_parents = next_parents.difference(interesting)
interesting.update(remaining_parents)
@@ -1525,8 +1525,8 @@
for entry in self._getitems(next_file_ids):
if entry.kind == 'directory':
directories_to_expand.add(entry.file_id)
- children_of_parent_id.setdefault(entry.parent_id, []
- ).append(entry.file_id)
+ children_of_parent_id.setdefault(entry.parent_id, set()
+ ).add(entry.file_id)
return interesting, children_of_parent_id
def filter(self, specific_fileids):
=== modified file 'bzrlib/tests/test_inv.py'
--- a/bzrlib/tests/test_inv.py 2011-05-19 14:42:05 +0000
+++ b/bzrlib/tests/test_inv.py 2011-08-08 12:47:07 +0000
@@ -1393,6 +1393,26 @@
self.assertEqual([u'ch\xefld'],
sorted(ie_dir._children.keys()))
+ def test_filter_change_in_renamed_subfolder(self):
+ inv = Inventory('tree-root')
+ src_ie = inv.add_path('src', 'directory', 'src-id')
+ inv.add_path('src/sub/', 'directory', 'sub-id')
+ a_ie = inv.add_path('src/sub/a', 'file', 'a-id')
+ a_ie.text_sha1 = osutils.sha_string('content\n')
+ a_ie.text_size = len('content\n')
+ chk_bytes = self.get_chk_bytes()
+ inv = CHKInventory.from_inventory(chk_bytes, inv)
+ inv = inv.create_by_apply_delta([
+ ("src/sub/a", "src/sub/a", "a-id", a_ie),
+ ("src", "src2", "src-id", src_ie),
+ ], 'new-rev-2')
+ new_inv = inv.filter(['a-id', 'src-id'])
+ self.assertEqual([
+ ('', 'tree-root'),
+ ('src', 'src-id'),
+ ('src/sub', 'sub-id'),
+ ('src/sub/a', 'a-id'),
+ ], [(path, ie.file_id) for path, ie in new_inv.iter_entries()])
class TestCHKInventoryExpand(tests.TestCaseWithMemoryTransport):
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-08-09 09:11:17 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-08-10 09:38:09 +0000
@@ -32,6 +32,11 @@
.. Fixes for situations where bzr would previously crash or give incorrect
or undesirable results.
+* A call to CHKInventory's filter-method will not result in a
+ DuplicateFileId error, if you move a subfolder and change a file in
+ that subfolder.
+ (Bastian Bowe, #809901)
+
* Accessing a packaging branch on Launchpad (eg, ``lp:ubuntu/bzr``) now
checks to see if the most recent published source package version for
that project is present in the branch tags. This should help developers
More information about the bazaar-commits
mailing list