/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-18 14:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120118140919-rlvdrhpc0nq1lbwi
Change set/remove to require a lock for the branch config files.

This means that tests (or any plugin for that matter) do not requires an
explicit lock on the branch anymore to change a single option. This also
means the optimisation becomes "opt-in" and as such won't be as
spectacular as it may be and/or harder to get right (nothing fails
anymore).

This reduces the diff by ~300 lines.

Code/tests that were updating more than one config option is still taking
a lock to at least avoid some IOs and demonstrate the benefits through
the decreased number of hpss calls.

The duplication between BranchStack and BranchOnlyStack will be removed
once the same sharing is in place for local config files, at which point
the Stack class itself may be able to host the changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
from bzrlib import (
18
20
    cache_utf8,
19
21
    errors,
20
22
    inventory,
21
23
    xml6,
22
 
    xml8,
23
 
    )
 
24
    )
 
25
from bzrlib.xml_serializer import (
 
26
    encode_and_escape,
 
27
    get_utf8_or_ascii,
 
28
    unpack_inventory_entry,
 
29
    )
 
30
 
24
31
 
25
32
class Serializer_v5(xml6.Serializer_v6):
26
33
    """Version 5 serializer
35
42
        """Construct from XML Element
36
43
        """
37
44
        root_id = elt.get('file_id') or inventory.ROOT_ID
38
 
        root_id = xml8._get_utf8_or_ascii(root_id)
 
45
        root_id = get_utf8_or_ascii(root_id)
39
46
 
40
47
        format = elt.get('format')
41
48
        if format is not None:
52
59
        #   avoiding attributes     2.46s
53
60
        #   adding assertions       2.50s
54
61
        #   last_parent cache       2.52s (worse, removed)
55
 
        unpack_entry = self._unpack_entry
56
62
        byid = inv._byid
57
63
        for e in elt:
58
 
            ie = unpack_entry(e, entry_cache=entry_cache,
 
64
            ie = unpack_inventory_entry(e, entry_cache=entry_cache,
59
65
                              return_from_cache=return_from_cache)
60
66
            parent_id = ie.parent_id
61
67
            if parent_id is None:
92
98
        """Append the inventory root to output."""
93
99
        if inv.root.file_id not in (None, inventory.ROOT_ID):
94
100
            fileid1 = ' file_id="'
95
 
            fileid2 = xml8._encode_and_escape(inv.root.file_id)
 
101
            fileid2 = encode_and_escape(inv.root.file_id)
96
102
        else:
97
103
            fileid1 = ""
98
104
            fileid2 = ""
99
105
        if inv.revision_id is not None:
100
106
            revid1 = ' revision_id="'
101
 
            revid2 = xml8._encode_and_escape(inv.revision_id)
 
107
            revid2 = encode_and_escape(inv.revision_id)
102
108
        else:
103
109
            revid1 = ""
104
110
            revid2 = ""