~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-08-02 23:14:41 UTC
  • Revision ID: mbp@sourcefrog.net-20050802231441-d738a6e6ffd03c3e
- new error RevisionNotPresent

- raise this when trying to fetch a revision that's mentioned but not 
  in the revision store

- Store raises an IndexError from getitem method if key is not found

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
27
28
from bzrlib.textui import show_status
28
29
from bzrlib.revision import Revision
29
30
from bzrlib.xml import unpack_xml
591
592
            f.close()
592
593
 
593
594
 
 
595
    def get_revision_xml(self, revision_id):
 
596
        """Return XML string for revision object."""
 
597
        if not revision_id or not isinstance(revision_id, basestring):
 
598
            raise InvalidRevisionId(revision_id)
 
599
 
 
600
        self.lock_read()
 
601
        try:
 
602
            try:
 
603
                return self.revision_store[revision_id]
 
604
            except IndexError:
 
605
                raise bzrlib.errors.RevisionNotPresent(revision_id)
 
606
        finally:
 
607
            self.unlock()
 
608
 
 
609
 
594
610
    def get_revision(self, revision_id):
595
611
        """Return the Revision object for a named revision"""
596
 
        self.lock_read()
597
 
        try:
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
        r = unpack_xml(Revision, self.get_revision_xml(revision_id))
603
613
            
604
614
        assert r.revision_id == revision_id
605
615
        return r
636
646
        # the revision, (add signatures/remove signatures) and still
637
647
        # have all hash pointers stay consistent.
638
648
        # But for now, just hash the contents.
639
 
        return sha_file(self.revision_store[revision_id])
 
649
        return bzrlib.osutils.sha_file(self.get_revision_xml(revision_id))
640
650
 
641
651
 
642
652
    def get_inventory(self, inventory_id):