/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/bundle/bundle_data.py

Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
            for property in self.properties:
79
79
                key_end = property.find(': ')
80
80
                if key_end == -1:
81
 
                    assert property.endswith(':')
 
81
                    if not property.endswith(':'):
 
82
                        raise ValueError(property)
82
83
                    key = str(property[:-1])
83
84
                    value = ''
84
85
                else:
196
197
    def revision_tree(self, repository, revision_id, base=None):
197
198
        revision = self.get_revision(revision_id)
198
199
        base = self.get_base(revision)
199
 
        assert base != revision_id
 
200
        if base == revision_id:
 
201
            raise AssertionError()
200
202
        if not self._validated_revisions_against_repo:
201
203
            self._validate_references_from_repository(repository)
202
204
        revision_info = self.get_revision_info(revision_id)
271
273
        """At this point we should have generated the BundleTree,
272
274
        so build up an inventory, and make sure the hashes match.
273
275
        """
274
 
 
275
 
        assert inv is not None
276
 
 
277
276
        # Now we should have a complete inventory entry.
278
277
        s = serializer_v5.write_inventory_to_string(inv)
279
278
        sha1 = sha_string(s)
280
279
        # Target revision is the last entry in the real_revisions list
281
280
        rev = self.get_revision(revision_id)
282
 
        assert rev.revision_id == revision_id
 
281
        if rev.revision_id != revision_id:
 
282
            raise AssertionError()
283
283
        if sha1 != rev.inventory_sha1:
284
284
            open(',,bogus-inv', 'wb').write(s)
285
285
            warning('Inventory sha hash mismatch for revision %s. %s'
293
293
        
294
294
        rev = self.get_revision(revision_id)
295
295
        rev_info = self.get_revision_info(revision_id)
296
 
        assert rev.revision_id == rev_info.revision_id
297
 
        assert rev.revision_id == revision_id
 
296
        if not (rev.revision_id == rev_info.revision_id):
 
297
            raise AssertionError()
 
298
        if not (rev.revision_id == revision_id):
 
299
            raise AssertionError()
298
300
        sha1 = self._testament_sha1(rev, inventory)
299
301
        if sha1 != rev_info.sha1:
300
302
            raise TestamentMismatch(rev.revision_id, rev_info.sha1, sha1)
332
334
                if name == 'last-changed':
333
335
                    last_changed = value
334
336
                elif name == 'executable':
335
 
                    assert value in ('yes', 'no'), value
336
337
                    val = (value == 'yes')
337
338
                    bundle_tree.note_executable(new_path, val)
338
339
                elif name == 'target':
342
343
            return last_changed, encoding
343
344
 
344
345
        def do_patch(path, lines, encoding):
345
 
            if encoding is not None:
346
 
                assert encoding == 'base64'
 
346
            if encoding == 'base64':
347
347
                patch = base64.decodestring(''.join(lines))
348
 
            else:
 
348
            elif encoding is None:
349
349
                patch =  ''.join(lines)
 
350
            else:
 
351
                raise ValueError(encoding)
350
352
            bundle_tree.note_patch(path, patch)
351
353
 
352
354
        def renamed(kind, extra, lines):
480
482
 
481
483
    def note_rename(self, old_path, new_path):
482
484
        """A file/directory has been renamed from old_path => new_path"""
483
 
        assert new_path not in self._renamed
484
 
        assert old_path not in self._renamed_r
 
485
        if new_path in self._renamed:
 
486
            raise AssertionError(new_path)
 
487
        if old_path in self._renamed_r:
 
488
            raise AssertionError(old_path)
485
489
        self._renamed[new_path] = old_path
486
490
        self._renamed_r[old_path] = new_path
487
491
 
517
521
 
518
522
    def old_path(self, new_path):
519
523
        """Get the old_path (path in the base_tree) for the file at new_path"""
520
 
        assert new_path[:1] not in ('\\', '/')
 
524
        if new_path[:1] in ('\\', '/'):
 
525
            raise ValueError(new_path)
521
526
        old_path = self._renamed.get(new_path)
522
527
        if old_path is not None:
523
528
            return old_path
543
548
        """Get the new_path (path in the target_tree) for the file at old_path
544
549
        in the base tree.
545
550
        """
546
 
        assert old_path[:1] not in ('\\', '/')
 
551
        if old_path[:1] in ('\\', '/'):
 
552
            raise ValueError(old_path)
547
553
        new_path = self._renamed_r.get(old_path)
548
554
        if new_path is not None:
549
555
            return new_path
622
628
            if (patch_original is None and 
623
629
                self.get_kind(file_id) == 'directory'):
624
630
                return StringIO()
625
 
            assert patch_original is not None, "None: %s" % file_id
 
631
            if patch_original is None:
 
632
                raise AssertionError("None: %s" % file_id)
626
633
            return patch_original
627
634
 
628
 
        assert not file_patch.startswith('\\'), \
629
 
            'Malformed patch for %s, %r' % (file_id, file_patch)
 
635
        if file_patch.startswith('\\'):
 
636
            raise ValueError(
 
637
                'Malformed patch for %s, %r' % (file_id, file_patch))
630
638
        return patched_file(file_patch, patch_original)
631
639
 
632
640
    def get_symlink_target(self, file_id):
679
687
        This need to be called before ever accessing self.inventory
680
688
        """
681
689
        from os.path import dirname, basename
682
 
 
683
 
        assert self.base_tree is not None
684
690
        base_inv = self.base_tree.inventory
685
691
        inv = Inventory(None, self.revision_id)
686
692