/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/xml6.py

  • Committer: Robert Collins
  • Date: 2006-09-10 23:42:17 UTC
  • mto: This revision was merged to the branch mainline in revision 2000.
  • Revision ID: robertc@robertcollins.net-20060910234217-0ae24d8e666d60d6
All WorkingTree methods which write to the tree, but not to the branch
have been converted to use ``needs_tree_write_lock`` rather than 
``needs_write_lock``. Also converted is the revert, conflicts and tree
transform modules. This provides a modest performance improvement on 
metadir style trees, due to the reduce lock-acquisition, and a more
significant performance improvement on lightweight checkouts from 
remote branches, where trivial operations used to pay a significant 
penalty. It also provides the basis for allowing readonly checkouts.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from bzrlib import cache_utf8, inventory, errors, xml5
 
2
 
 
3
 
 
4
class Serializer_v6(xml5.Serializer_v5):
 
5
 
 
6
    def _append_inventory_root(self, append, inv):
 
7
        """Append the inventory root to output."""
 
8
        append('<inventory')
 
9
        append(' format="6"')
 
10
        if inv.revision_id is not None:
 
11
            append(' revision_id="')
 
12
            append(xml5._encode_and_escape(inv.revision_id))
 
13
        append('>\n')
 
14
        self._append_entry(append, inv.root)
 
15
 
 
16
    def _parent_condition(self, ie):
 
17
        return ie.parent_id is not None
 
18
 
 
19
    def _unpack_inventory(self, elt):
 
20
        """Construct from XML Element"""
 
21
        if elt.tag != 'inventory':
 
22
            raise errors.UnexpectedInventoryFormat('Root tag is %r' % elt.tag)
 
23
        format = elt.get('format')
 
24
        if format != '6':
 
25
            raise errors.UnexpectedInventoryFormat('Invalid format version %r'
 
26
                                                   % format)
 
27
        revision_id = elt.get('revision_id')
 
28
        if revision_id is not None:
 
29
            revision_id = cache_utf8.get_cached_unicode(revision_id)
 
30
        inv = inventory.Inventory(root_id=None, revision_id=revision_id)
 
31
        for e in elt:
 
32
            ie = self._unpack_entry(e, none_parents=True)
 
33
            inv.add(ie)
 
34
        return inv
 
35
 
 
36
 
 
37
serializer_v6 = Serializer_v6()