~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory_delta.py

  • Committer: Andrew Bennetts
  • Date: 2009-08-04 14:07:42 UTC
  • mto: This revision was merged to the branch mainline in revision 4608.
  • Revision ID: andrew.bennetts@canonical.com-20090804140742-elu5athah3e0s4uj
Fix deserialization of deletes in inventory deltas, don't give up on serialized deltas from a supports_tree_refs repo unless the delta contains tree refs, and experiment to add automatic_root param to branchbuilder.

Show diffs side-by-side

added added

removed removed

Lines of Context:
228
228
            if newpath_utf8 == '/' and not self._versioned_root:
229
229
                # This is an entry for the root, this inventory does not
230
230
                # support versioned roots.  So this must be an unversioned
231
 
                # root, i.e. id == TREE_ROOT and last_modified == new revision.
232
 
                # Otherwise, this delta is nonsensical.
233
 
                if file_id != 'TREE_ROOT':
234
 
                    from bzrlib.trace import mutter
235
 
                    mutter('delta_item: %r', delta_item)
236
 
                    mutter('self._versioned_root: %r', self._versioned_root)
237
 
                    raise errors.BzrError(
238
 
                        'file_id %s is not TREE_ROOT for /' % file_id)
 
231
                # root, i.e. last_modified == new revision.  Otherwise, this
 
232
                # delta is invalid.
 
233
                # Note: the non-rich-root repositories *can* have roots with
 
234
                # file-ids other than TREE_ROOT, e.g. repo formats that use the
 
235
                # xml5 serializer.
239
236
                if last_modified != new_version:
240
237
                    raise errors.BzrError(
241
238
                        'Version present for / in %s (%s != %s)'
308
305
                raise errors.BzrError(
309
306
                    "duplicate file id in inventory delta %r" % lines)
310
307
            seen_ids.add(file_id)
311
 
            if newpath_utf8 == '/' and not delta_versioned_root and (
312
 
                last_modified != delta_version_id or file_id != 'TREE_ROOT'):
 
308
            if (newpath_utf8 == '/' and not delta_versioned_root and
 
309
                last_modified != delta_version_id):
313
310
                    # Delta claims to be not rich root, yet here's a root entry
314
 
                    # with either a non-default ID or a non-default version,
315
 
                    # i.e.  it's rich...
 
311
                    # with either non-default version, i.e. it's rich...
316
312
                    raise errors.BzrError("Versioned root found: %r" % line)
317
 
            elif last_modified[-1] == ':':
318
 
                    raise errors.BzrError('special revisionid found: %r' % line)
 
313
            elif newpath_utf8 != 'None' and last_modified[-1] == ':':
 
314
                # Deletes have a last_modified of null:, but otherwise special
 
315
                # revision ids should not occur.
 
316
                raise errors.BzrError('special revisionid found: %r' % line)
319
317
            if delta_tree_references is False and content.startswith('tree\x00'):
320
318
                raise errors.BzrError("Tree reference found: %r" % line)
321
319
            if oldpath_utf8 == 'None':
338
336
                newpath_utf8 = newpath_utf8[1:]
339
337
                newpath = newpath_utf8.decode('utf8')
340
338
            content_tuple = tuple(content.split('\x00'))
341
 
            entry = _parse_entry(
342
 
                newpath_utf8, file_id, parent_id, last_modified, content_tuple)
 
339
            if content_tuple[0] == 'deleted':
 
340
                # XXX: No test coverage for deletes!!!
 
341
                entry = None
 
342
            else:
 
343
                entry = _parse_entry(
 
344
                    newpath_utf8, file_id, parent_id, last_modified,
 
345
                    content_tuple)
343
346
            delta_item = (oldpath, newpath, file_id, entry)
344
347
            result.append(delta_item)
345
348
        return (delta_parent_id, delta_version_id, delta_versioned_root,