Rev 4850: Add a flag that controls if we will return InventoryEntries from the cache. in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b4-xml8
John Arbash Meinel
john at arbash-meinel.com
Tue Dec 1 21:27:12 GMT 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b4-xml8
------------------------------------------------------------
revno: 4850
revision-id: john at arbash-meinel.com-20091201212708-bjlq7ydk7xtmzuhd
parent: pqm at pqm.ubuntu.com-20091201152410-bc1esog34wsur9hh
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0b4-xml8
timestamp: Tue 2009-12-01 15:27:08 -0600
message:
Add a flag that controls if we will return InventoryEntries from the cache.
Setting this to true makes conversion a lot faster, but isn't safe to do
all the time, as callers might mutate the returned object.
-------------- next part --------------
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2009-11-30 03:34:09 +0000
+++ b/bzrlib/repository.py 2009-12-01 21:27:08 +0000
@@ -3840,6 +3840,7 @@
pending_revisions = []
parent_map = self.source.get_parent_map(revision_ids)
self._fetch_parent_invs_for_stacking(parent_map, cache)
+ self.source._format._serializer.safe_to_use_cache_items = True
for tree in self.source.revision_trees(revision_ids):
# Find a inventory delta for this revision.
# Find text entries that need to be copied, too.
@@ -3893,6 +3894,7 @@
pending_revisions.append(revision)
cache[current_revision_id] = tree
basis_id = current_revision_id
+ self.source._format._serializer.safe_to_use_cache_items = False
# Copy file texts
from_texts = self.source.texts
to_texts = self.target.texts
@@ -3977,6 +3979,7 @@
basis_id = self._fetch_batch(batch, basis_id, cache,
a_graph=a_graph)
except:
+ self.source._format._serializer.safe_to_use_cache_items = False
self.target.abort_write_group()
raise
else:
=== modified file 'bzrlib/serializer.py'
--- a/bzrlib/serializer.py 2009-07-29 17:44:34 +0000
+++ b/bzrlib/serializer.py 2009-12-01 21:27:08 +0000
@@ -26,6 +26,11 @@
squashes_xml_invalid_characters = False
+ # Setting this true will return InventoryEntry items directly from the
+ # cache, rather than copying them. It can be much faster for some
+ # operations, but the callers must not mutate the returned objects
+ safe_to_use_cache_items = False
+
def write_inventory(self, inv, f):
"""Write inventory to a file.
=== modified file 'bzrlib/xml8.py'
--- a/bzrlib/xml8.py 2009-07-07 04:32:13 +0000
+++ b/bzrlib/xml8.py 2009-12-01 21:27:08 +0000
@@ -433,9 +433,10 @@
pass
else:
# Only copying directory entries drops us 2.85s => 2.35s
- # if cached_ie.kind == 'directory':
- # return cached_ie.copy()
- # return cached_ie
+ if self.safe_to_use_cache_items:
+ if cached_ie.kind == 'directory':
+ return cached_ie.copy()
+ return cached_ie
return cached_ie.copy()
kind = elt.tag
More information about the bazaar-commits
mailing list