~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Martin Pool
  • Date: 2010-02-09 19:04:02 UTC
  • mfrom: (5010 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5019.
  • Revision ID: mbp@canonical.com-20100209190402-2xbzrchmb4dfi2j7
Resolve conflicts with trunk

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".'
 
705
    _fmt = 'Not a branch: "%(path)s"%(detail)s.'
706
706
 
707
 
    def __init__(self, path):
 
707
    def __init__(self, path, detail=None, bzrdir=None):
708
708
       import bzrlib.urlutils as urlutils
709
 
       self.path = urlutils.unescape_for_display(path, 'ascii')
 
709
       path = urlutils.unescape_for_display(path, 'ascii')
 
710
       if detail is not None:
 
711
           detail = ': ' + detail
 
712
       self.detail = detail
 
713
       self.bzrdir = bzrdir
 
714
       PathError.__init__(self, path=path)
 
715
 
 
716
    def _format(self):
 
717
        # XXX: Ideally self.detail would be a property, but Exceptions in
 
718
        # Python 2.4 have to be old-style classes so properties don't work.
 
719
        # Instead we override _format.
 
720
        if self.detail is None:
 
721
            if self.bzrdir is not None:
 
722
                try:
 
723
                    self.bzrdir.open_repository()
 
724
                except NoRepositoryPresent:
 
725
                    self.detail = ''
 
726
                else:
 
727
                    self.detail = ': location is a repository'
 
728
            else:
 
729
                self.detail = ''
 
730
        return PathError._format(self)
710
731
 
711
732
 
712
733
class NoSubmitBranch(PathError):
3093
3114
    def __init__(self, source_branch, target_branch):
3094
3115
        self.source_branch = source_branch
3095
3116
        self.target_branch = target_branch
 
3117
 
 
3118
 
 
3119
class FileTimestampUnavailable(BzrError):
 
3120
 
 
3121
    _fmt = "The filestamp for %(path)s is not available."
 
3122
 
 
3123
    internal_error = True
 
3124
 
 
3125
    def __init__(self, path):
 
3126
        self.path = path