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

  • Committer: Andrew Bennetts
  • Date: 2010-01-11 02:07:30 UTC
  • mto: This revision was merged to the branch mainline in revision 4965.
  • Revision ID: andrew.bennetts@canonical.com-20100111020730-1dctpvfgburfrgkk
Defer checking for a repository in NotBranchError case until we format the error as a string. (test_smart currently fails)

Show diffs side-by-side

added added

removed removed

Lines of Context:
702
702
# TODO: Probably this behavior of should be a common superclass
703
703
class NotBranchError(PathError):
704
704
 
705
 
    _fmt = 'Not a branch: "%(path)s"%(extra)s.'
 
705
    _fmt = 'Not a branch: "%(path)s"%(detail)s.'
706
706
 
707
 
    def __init__(self, path, detail=None):
 
707
    def __init__(self, path, bzrdir=None):
708
708
       import bzrlib.urlutils as urlutils
709
709
       path = urlutils.unescape_for_display(path, 'ascii')
710
710
       # remember the detail in case of remote serialization
711
 
       self.detail = detail
712
 
       PathError.__init__(self, path=path, extra=self.detail)
 
711
       self.detail = None
 
712
       self.bzrdir = bzrdir
 
713
       PathError.__init__(self, path=path)
 
714
 
 
715
    def _format(self):
 
716
        # XXX: Ideally self.detail would be a property, but Exceptions in
 
717
        # Python 2.4 have to be old-style classes so properties don't work.
 
718
        # Instead we override _format.
 
719
        if self.detail is None:
 
720
            if self.bzrdir is not None:
 
721
                try:
 
722
                    self.bzrdir.open_repository()
 
723
                except NoRepositoryPresent:
 
724
                    self.detail = ''
 
725
                else:
 
726
                    self.detail = ': location is a repository'
 
727
            else:
 
728
                self.detail = ''
 
729
        return PathError._format(self)
713
730
 
714
731
 
715
732
class NoSubmitBranch(PathError):