/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 read_changeset.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-07-01 01:47:06 UTC
  • mto: (0.5.85) (1185.82.1 bzr-w-changeset)
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: aaron.bentley@utoronto.ca-20050701014706-98dcd4dd5cb02eff
ImplementedĀ deletionĀ forĀ ChangesetTrees

Show diffs side-by-side

added added

removed removed

Lines of Context:
422
422
 
423
423
 
424
424
class ChangesetTree:
425
 
    def __init__(self, base_tree):
 
425
    def __init__(self, base_tree=None):
426
426
        self.base_tree = base_tree
427
427
        self._renamed = {}
428
428
        self._renamed_r = {}
429
429
        self._new_id = {}
430
430
        self._new_id_r = {}
431
431
        self.patches = {}
 
432
        self.deleted = []
432
433
 
433
434
    def note_rename(self, old_path, new_path):
434
435
        assert not self._renamed.has_key(old_path)
443
444
    def note_patch(self, new_path, patch):
444
445
        self.patches[new_path] = patch
445
446
 
 
447
    def note_deletion(self, old_path):
 
448
        self.deleted.append(old_path)
 
449
 
446
450
    def old_path(self, new_path):
447
451
        import os.path
448
452
        old_path = self._renamed.get(new_path)
493
497
        old_path = self.old_path(path)
494
498
        if old_path is None:
495
499
            return None
 
500
        if old_path in self.deleted:
 
501
            return None
496
502
        return self.base_tree.path2id(old_path)
497
503
 
498
504
    def id2path(self, file_id):
502
508
        old_path = self.base_tree.id2path(file_id)
503
509
        if old_path is None:
504
510
            return None
 
511
        if old_path in self.deleted:
 
512
            return None
505
513
        return self.new_path(old_path)
506
514
 
507
515
    def get_file(self, file_id):
688
696
            assert ctree.get_file("c").read() == "Hello"
689
697
            assert ctree.get_file("e").read() == "Lemon\n"
690
698
 
 
699
        def test_delete(self):
 
700
            "Deletion by changeset"
 
701
            ctree = self.make_tree_1()[0]
 
702
            assert ctree.get_file("c").read() == "Hello"
 
703
            ctree.note_deletion("grandparent/parent/file")
 
704
            assert ctree.id2path("c") is None
 
705
            assert ctree.path2id("grandparent/parent/file") is None
 
706
 
691
707
    patchesTestSuite = unittest.makeSuite(CTreeTester,'test_')
692
708
    runner = unittest.TextTestRunner()
693
709
    runner.run(patchesTestSuite)