~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/bundle_data.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-01 23:48:08 UTC
  • mfrom: (2225.1.6 revert)
  • Revision ID: pqm@pqm.ubuntu.com-20070201234808-3b1302d73474bd8c
Display changes made by revert

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
223
223
            if repository.has_revision(revision_id):
224
224
                testament = StrictTestament.from_revision(repository, 
225
225
                                                          revision_id)
226
 
                local_sha1 = testament.as_sha1()
 
226
                local_sha1 = self._testament_sha1_from_revision(repository,
 
227
                                                                revision_id)
227
228
                if sha1 != local_sha1:
228
229
                    raise BzrError('sha1 mismatch. For revision id {%s}' 
229
230
                            'local: %s, bundle: %s' % (revision_id, local_sha1, sha1))
281
282
        rev_info = self.get_revision_info(revision_id)
282
283
        assert rev.revision_id == rev_info.revision_id
283
284
        assert rev.revision_id == revision_id
284
 
        sha1 = StrictTestament(rev, inventory).as_sha1()
 
285
        sha1 = self._testament_sha1(rev, inventory)
285
286
        if sha1 != rev_info.sha1:
286
287
            raise TestamentMismatch(rev.revision_id, rev_info.sha1, sha1)
287
 
        if rev_to_sha1.has_key(rev.revision_id):
 
288
        if rev.revision_id in rev_to_sha1:
288
289
            raise BzrError('Revision {%s} given twice in the list'
289
290
                    % (rev.revision_id))
290
291
        rev_to_sha1[rev.revision_id] = sha1
445
446
 
446
447
    def note_rename(self, old_path, new_path):
447
448
        """A file/directory has been renamed from old_path => new_path"""
448
 
        assert not self._renamed.has_key(new_path)
449
 
        assert not self._renamed_r.has_key(old_path)
 
449
        assert new_path not in self._renamed
 
450
        assert old_path not in self._renamed_r
450
451
        self._renamed[new_path] = old_path
451
452
        self._renamed_r[old_path] = new_path
452
453
 
457
458
        self._kinds[new_id] = kind
458
459
 
459
460
    def note_last_changed(self, file_id, revision_id):
460
 
        if (self._last_changed.has_key(file_id)
 
461
        if (file_id in self._last_changed
461
462
                and self._last_changed[file_id] != revision_id):
462
463
            raise BzrError('Mismatched last-changed revision for file_id {%s}'
463
464
                    ': %s != %s' % (file_id,
500
501
            old_path = new_path
501
502
        #If the new path wasn't in renamed, the old one shouldn't be in
502
503
        #renamed_r
503
 
        if self._renamed_r.has_key(old_path):
 
504
        if old_path in self._renamed_r:
504
505
            return None
505
506
        return old_path 
506
507
 
512
513
        new_path = self._renamed_r.get(old_path)
513
514
        if new_path is not None:
514
515
            return new_path
515
 
        if self._renamed.has_key(new_path):
 
516
        if new_path in self._renamed:
516
517
            return None
517
518
        dirname,basename = os.path.split(old_path)
518
519
        if dirname != '':
525
526
            new_path = old_path
526
527
        #If the old path wasn't in renamed, the new one shouldn't be in
527
528
        #renamed_r
528
 
        if self._renamed.has_key(new_path):
 
529
        if new_path in self._renamed:
529
530
            return None
530
531
        return new_path 
531
532
 
539
540
            return None
540
541
        if old_path in self.deleted:
541
542
            return None
542
 
        if hasattr(self.base_tree, 'path2id'):
 
543
        if getattr(self.base_tree, 'path2id', None) is not None:
543
544
            return self.base_tree.path2id(old_path)
544
545
        else:
545
546
            return self.base_tree.inventory.path2id(old_path)
577
578
                then be cached.
578
579
        """
579
580
        base_id = self.old_contents_id(file_id)
580
 
        if base_id is not None:
 
581
        if (base_id is not None and
 
582
            base_id != self.base_tree.inventory.root.file_id):
581
583
            patch_original = self.base_tree.get_file(base_id)
582
584
        else:
583
585
            patch_original = None
646
648
 
647
649
        assert self.base_tree is not None
648
650
        base_inv = self.base_tree.inventory
649
 
        root_id = base_inv.root.file_id
650
 
        try:
651
 
            # New inventories have a unique root_id
652
 
            inv = Inventory(root_id, self.revision_id)
653
 
        except TypeError:
654
 
            inv = Inventory(revision_id=self.revision_id)
 
651
        inv = Inventory(None, self.revision_id)
655
652
 
656
653
        def add_entry(file_id):
657
654
            path = self.id2path(file_id)
658
655
            if path is None:
659
656
                return
660
 
            parent_path = dirname(path)
661
 
            if parent_path == u'':
662
 
                parent_id = root_id
 
657
            if path == '':
 
658
                parent_id = None
663
659
            else:
 
660
                parent_path = dirname(path)
664
661
                parent_id = self.path2id(parent_path)
665
662
 
666
663
            kind = self.get_kind(file_id)
687
684
 
688
685
        sorted_entries = self.sorted_path_id()
689
686
        for path, file_id in sorted_entries:
690
 
            if file_id == inv.root.file_id:
691
 
                continue
692
687
            add_entry(file_id)
693
688
 
694
689
        return inv