Merge lp:~jelmer/bzr-search/lazy-xml into lp:bzr-search

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Robert Collins
Approved revision: 86
Merged at revision: 86
Proposed branch: lp:~jelmer/bzr-search/lazy-xml
Merge into: lp:bzr-search
Diff against target: 79 lines (+35/-27)
1 file modified
index.py (+35/-27)
To merge this branch: bzr merge lp:~jelmer/bzr-search/lazy-xml
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+53394@code.launchpad.net

This proposal supersedes a proposal from 2011-03-14.

Description of the change

Add lazy function for determining XML serializers.

This prevents them from being imported every time bzr-search is loaded.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote : Posted in a previous version of this proposal

This seems to be much more than that - have you included your rejected
other branch perhaps?

Revision history for this message
Jelmer Vernooij (jelmer) wrote : Posted in a previous version of this proposal

Argh. Cherrypicked the right changes now. I should not call things I've modified "trunk".

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

ping?

Revision history for this message
Robert Collins (lifeless) :
review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks! Can you merge?

Revision history for this message
Robert Collins (lifeless) wrote :

Future request, can you please include NEWS entries? Thanks.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'index.py'
2--- index.py 2011-02-01 04:20:25 +0000
3+++ index.py 2011-03-15 10:18:32 +0000
4@@ -46,32 +46,40 @@
5 from bzrlib.plugins.search.transport import FileView
6 from bzrlib.multiparent import NewText
7 from bzrlib.revision import NULL_REVISION
8-xml_serializers = []
9-try:
10- from bzrlib.xml4 import _Serializer_v4
11- xml_serializers.append(_Serializer_v4)
12-except ImportError:
13- pass
14-try:
15- from bzrlib.xml5 import Serializer_v5
16- xml_serializers.append(Serializer_v5)
17-except ImportError:
18- pass
19-try:
20- from bzrlib.xml6 import Serializer_v6
21- xml_serializers.append(Serializer_v6)
22-except ImportError:
23- pass
24-try:
25- from bzrlib.xml7 import Serializer_v7
26- xml_serializers.append(Serializer_v7)
27-except ImportError:
28- pass
29-try:
30- from bzrlib.xml8 import Serializer_v8
31- xml_serializers.append(Serializer_v8)
32-except ImportError:
33- pass
34+
35+_xml_serializers = None
36+def xml_serializers():
37+ global _xml_serializers
38+ if _xml_serializers is not None:
39+ return _xml_serializers
40+ _xml_serializers = []
41+ try:
42+ from bzrlib.xml4 import _Serializer_v4
43+ _xml_serializers.append(_Serializer_v4)
44+ except ImportError:
45+ pass
46+ try:
47+ from bzrlib.xml5 import Serializer_v5
48+ _xml_serializers.append(Serializer_v5)
49+ except ImportError:
50+ pass
51+ try:
52+ from bzrlib.xml6 import Serializer_v6
53+ _xml_serializers.append(Serializer_v6)
54+ except ImportError:
55+ pass
56+ try:
57+ from bzrlib.xml7 import Serializer_v7
58+ _xml_serializers.append(Serializer_v7)
59+ except ImportError:
60+ pass
61+ try:
62+ from bzrlib.xml8 import Serializer_v8
63+ _xml_serializers.append(Serializer_v8)
64+ except ImportError:
65+ pass
66+ return _xml_serializers
67+
68 from bzrlib.transport import get_transport
69 from bzrlib.tsort import topo_sort
70
71@@ -717,7 +725,7 @@
72 bar.update("Extract revision paths", offset, groups)
73 inventory_group = order[offset * group_size:(offset + 1) * group_size]
74 serializer = repository._serializer
75- if type(serializer) in xml_serializers:
76+ if type(serializer) in xml_serializers():
77 # Fast path for flat-file serializers.
78 group_keys = [(revid,) for revid in inventory_group]
79 stream = repository.inventories.get_record_stream(

Subscribers

People subscribed via source and target branches

to all changes: