~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-09-10 18:57:20 UTC
  • mfrom: (1910.2.48 format-bumps)
  • Revision ID: pqm@pqm.ubuntu.com-20060910185720-1bcc17b99fe77687
Add new format to support nested trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
    
98
98
    __slots__ = []
99
99
 
 
100
    support_altered_by_hack = True
 
101
    # This format supports the altered-by hack that reads file ids directly out
 
102
    # of the versionedfile, without doing XML parsing.
 
103
 
100
104
    def write_inventory_to_string(self, inv):
101
105
        """Just call write_inventory with a StringIO and return the value"""
102
106
        sio = cStringIO.StringIO()
150
154
        append(_encode_and_escape(ie.file_id))
151
155
        append(' name="')
152
156
        append(_encode_and_escape(ie.name))
153
 
        if ie.parent_id != ROOT_ID:
 
157
        if self._parent_condition(ie):
154
158
            assert isinstance(ie.parent_id, basestring)
155
159
            append(' parent_id="')
156
160
            append(_encode_and_escape(ie.parent_id))
169
173
        append(" />\n")
170
174
        return
171
175
 
 
176
    def _parent_condition(self, ie):
 
177
        return ie.parent_id != ROOT_ID
 
178
 
172
179
    def _pack_revision(self, rev):
173
180
        """Revision object -> xml tree"""
174
181
        root = Element('revision',
228
235
            inv.add(ie)
229
236
        return inv
230
237
 
231
 
    def _unpack_entry(self, elt):
 
238
    def _unpack_entry(self, elt, none_parents=False):
232
239
        kind = elt.tag
233
240
        if not InventoryEntry.versionable_kind(kind):
234
241
            raise AssertionError('unsupported entry kind %s' % kind)
236
243
        get_cached = cache_utf8.get_cached_unicode
237
244
 
238
245
        parent_id = elt.get('parent_id')
239
 
        if parent_id is None:
 
246
        if parent_id is None and not none_parents:
240
247
            parent_id = ROOT_ID
241
248
        # TODO: jam 20060817 At present, caching file ids costs us too 
242
249
        #       much time. It slows down overall read performances from