1
# Copyright (C) 2005-2010 Canonical Ltd
1
# Copyright (C) 2005 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
291
290
_inventory_v5a, revision_id='test-rev-id')
292
291
self.assertEqual('test-rev-id', inv.root.revision)
294
def test_unpack_inventory_5a_cache_and_copy(self):
295
# Passing an entry_cache should get populated with the objects
296
# But the returned objects should be copies if return_from_cache is
298
entry_cache = fifo_cache.FIFOCache()
299
inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
300
_inventory_v5a, revision_id='test-rev-id',
301
entry_cache=entry_cache, return_from_cache=False)
302
for entry in inv.iter_just_entries():
303
key = (entry.file_id, entry.revision)
304
if entry.file_id is inv.root.file_id:
305
# The root id is inferred for xml v5
306
self.assertFalse(key in entry_cache)
308
self.assertIsNot(entry, entry_cache[key])
310
def test_unpack_inventory_5a_cache_no_copy(self):
311
# Passing an entry_cache should get populated with the objects
312
# The returned objects should be exact if return_from_cache is
314
entry_cache = fifo_cache.FIFOCache()
315
inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
316
_inventory_v5a, revision_id='test-rev-id',
317
entry_cache=entry_cache, return_from_cache=True)
318
for entry in inv.iter_just_entries():
319
key = (entry.file_id, entry.revision)
320
if entry.file_id is inv.root.file_id:
321
# The root id is inferred for xml v5
322
self.assertFalse(key in entry_cache)
324
self.assertIs(entry, entry_cache[key])
326
293
def test_unpack_inventory_5b(self):
327
294
inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
328
295
_inventory_v5b, revision_id='test-rev-id')