/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-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:
130
130
        Exception.__init__(self, "These branches have diverged.")
131
131
 
132
132
 
 
133
class NoSuchRevision(BzrError):
 
134
    def __init__(self, branch, revision):
 
135
        self.branch = branch
 
136
        self.revision = revision
 
137
        msg = "Branch %s has no revision %d" % (branch, revision)
 
138
        BzrError.__init__(self, msg)
 
139
 
 
140
 
133
141
######################################################################
134
142
# branch objects
135
143
 
585
593
 
586
594
 
587
595
    def get_revision_xml(self, revision_id):
588
 
        """Return XML file object for revision object."""
 
596
        """Return XML string for revision object."""
589
597
        if not revision_id or not isinstance(revision_id, basestring):
590
598
            raise InvalidRevisionId(revision_id)
591
599
 
594
602
            try:
595
603
                return self.revision_store[revision_id]
596
604
            except IndexError:
597
 
                raise bzrlib.errors.NoSuchRevision(revision_id)
 
605
                raise bzrlib.errors.RevisionNotPresent(revision_id)
598
606
        finally:
599
607
            self.unlock()
600
608
 
601
609
 
602
610
    def get_revision(self, revision_id):
603
611
        """Return the Revision object for a named revision"""
604
 
        xml_file = self.get_revision_xml(revision_id)
605
 
 
606
 
        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)])
 
612
        r = unpack_xml(Revision, self.get_revision_xml(revision_id))
612
613
            
613
614
        assert r.revision_id == revision_id
614
615
        return r