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

  • Committer: Martin Pool
  • Date: 2005-08-01 20:25:24 UTC
  • Revision ID: mbp@sourcefrog.net-20050801202524-cc49f230ffa9c4e3
- correctly exclude root_directory from search for added files
  in compare_trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
     splitpath, \
25
25
     sha_file, appendpath, file_kind
26
26
from bzrlib.errors import BzrError, InvalidRevisionNumber, InvalidRevisionId
27
 
import bzrlib.errors
28
27
from bzrlib.textui import show_status
29
28
from bzrlib.revision import Revision
30
29
from bzrlib.xml import unpack_xml
130
129
        Exception.__init__(self, "These branches have diverged.")
131
130
 
132
131
 
 
132
class NoSuchRevision(BzrError):
 
133
    def __init__(self, branch, revision):
 
134
        self.branch = branch
 
135
        self.revision = revision
 
136
        msg = "Branch %s has no revision %d" % (branch, revision)
 
137
        BzrError.__init__(self, msg)
 
138
 
 
139
 
133
140
######################################################################
134
141
# branch objects
135
142
 
584
591
            f.close()
585
592
 
586
593
 
587
 
    def get_revision_xml(self, revision_id):
588
 
        """Return XML file object for revision object."""
589
 
        if not revision_id or not isinstance(revision_id, basestring):
590
 
            raise InvalidRevisionId(revision_id)
591
 
 
592
 
        self.lock_read()
593
 
        try:
594
 
            try:
595
 
                return self.revision_store[revision_id]
596
 
            except IndexError:
597
 
                raise bzrlib.errors.NoSuchRevision(revision_id)
598
 
        finally:
599
 
            self.unlock()
600
 
 
601
 
 
602
594
    def get_revision(self, revision_id):
603
595
        """Return the Revision object for a named revision"""
604
 
        xml_file = self.get_revision_xml(revision_id)
605
 
 
 
596
        self.lock_read()
606
597
        try:
607
 
            r = unpack_xml(Revision, xml_file)
608
 
        except SyntaxError, e:
609
 
            raise bzrlib.errors.BzrError('failed to unpack revision_xml',
610
 
                                         [revision_id,
611
 
                                          str(e)])
 
598
            if not revision_id or not isinstance(revision_id, basestring):
 
599
                raise InvalidRevisionId(revision_id)
 
600
            r = unpack_xml(Revision, self.revision_store[revision_id])
 
601
        finally:
 
602
            self.unlock()
612
603
            
613
604
        assert r.revision_id == revision_id
614
605
        return r
645
636
        # the revision, (add signatures/remove signatures) and still
646
637
        # have all hash pointers stay consistent.
647
638
        # But for now, just hash the contents.
648
 
        return bzrlib.osutils.sha_file(self.get_revision_xml(revision_id))
 
639
        return sha_file(self.revision_store[revision_id])
649
640
 
650
641
 
651
642
    def get_inventory(self, inventory_id):
1038
1029
        # TODO: refactor this to use an existing revision object
1039
1030
        # so we don't need to read it in twice.
1040
1031
        if revision_id == None:
1041
 
            return EmptyTree()
 
1032
            return EmptyTree(self.get_root_id())
1042
1033
        else:
1043
1034
            inv = self.get_revision_inventory(revision_id)
1044
1035
            return RevisionTree(self.text_store, inv)
1057
1048
        """
1058
1049
        r = self.last_patch()
1059
1050
        if r == None:
1060
 
            return EmptyTree()
 
1051
            return EmptyTree(self.get_root_id())
1061
1052
        else:
1062
1053
            return RevisionTree(self.text_store, self.get_revision_inventory(r))
1063
1054