bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
1910.2.22
by Aaron Bentley
 Make commits preserve root entry data  | 
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"')  | 
|
| 
1910.2.23
by Aaron Bentley
 Fix up test cases that manually construct inventories  | 
10  | 
if inv.revision_id is not None:  | 
11  | 
append(' revision_id="')  | 
|
12  | 
append(xml5._encode_and_escape(inv.revision_id))  | 
|
| 
1910.2.22
by Aaron Bentley
 Make commits preserve root entry data  | 
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"""  | 
|
| 
1910.2.31
by Aaron Bentley
 Fix bugs in basis inventory handling, change filename  | 
21  | 
if elt.tag != 'inventory':  | 
22  | 
raise errors.UnexpectedInventoryFormat('Root tag is %r' % elt.tag)  | 
|
| 
1910.2.22
by Aaron Bentley
 Make commits preserve root entry data  | 
23  | 
format = elt.get('format')  | 
| 
1910.2.31
by Aaron Bentley
 Fix bugs in basis inventory handling, change filename  | 
24  | 
if format != '6':  | 
25  | 
raise errors.UnexpectedInventoryFormat('Invalid format version %r'  | 
|
26  | 
% format)  | 
|
| 
1910.2.22
by Aaron Bentley
 Make commits preserve root entry data  | 
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()  |