~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Jelmer Vernooij
  • Date: 2010-12-20 02:23:31 UTC
  • mto: This revision was merged to the branch mainline in revision 5577.
  • Revision ID: jelmer@samba.org-20101220022331-hbm91o1ps9gjrlns
Add testr magic for bzr selftest --list

Show diffs side-by-side

added added

removed removed

Lines of Context:
680
680
 
681
681
    _fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
682
682
 
683
 
    internal_error = True
 
683
    internal_error = False
684
684
 
685
685
    def __init__(self, path, base, extra=None):
686
686
        BzrError.__init__(self)
713
713
       self.bzrdir = bzrdir
714
714
       PathError.__init__(self, path=path)
715
715
 
 
716
    def __repr__(self):
 
717
        return '<%s %r>' % (self.__class__.__name__, self.__dict__)
 
718
 
716
719
    def _format(self):
717
720
        # XXX: Ideally self.detail would be a property, but Exceptions in
718
721
        # Python 2.4 have to be old-style classes so properties don't work.
723
726
                    self.bzrdir.open_repository()
724
727
                except NoRepositoryPresent:
725
728
                    self.detail = ''
 
729
                except Exception:
 
730
                    # Just ignore unexpected errors.  Raising arbitrary errors
 
731
                    # during str(err) can provoke strange bugs.  Concretely
 
732
                    # Launchpad's codehosting managed to raise NotBranchError
 
733
                    # here, and then get stuck in an infinite loop/recursion
 
734
                    # trying to str() that error.  All this error really cares
 
735
                    # about that there's no working repository there, and if
 
736
                    # open_repository() fails, there probably isn't.
 
737
                    self.detail = ''
726
738
                else:
727
739
                    self.detail = ': location is a repository'
728
740
            else:
782
794
 
783
795
    _fmt = 'File "%(path)s" is not in branch %(branch_base)s.'
784
796
 
 
797
    # use PathNotChild instead
 
798
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 3, 0)))
785
799
    def __init__(self, branch, path):
786
800
        BzrError.__init__(self)
787
801
        self.branch = branch
1187
1201
class InvalidRevisionSpec(BzrError):
1188
1202
 
1189
1203
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
1190
 
            " %(branch)s%(extra)s")
 
1204
            " %(branch_url)s%(extra)s")
1191
1205
 
1192
1206
    def __init__(self, spec, branch, extra=None):
1193
1207
        BzrError.__init__(self, branch=branch, spec=spec)
 
1208
        self.branch_url = getattr(branch, 'user_url', str(branch))
1194
1209
        if extra:
1195
1210
            self.extra = '\n' + str(extra)
1196
1211
        else:
1392
1407
 
1393
1408
class WeaveInvalidChecksum(WeaveError):
1394
1409
 
1395
 
    _fmt = "Text did not match it's checksum: %(msg)s"
 
1410
    _fmt = "Text did not match its checksum: %(msg)s"
1396
1411
 
1397
1412
 
1398
1413
class WeaveTextDiffers(WeaveError):
1993
2008
        "Use --keep to not delete them, or --force to delete them regardless.")
1994
2009
 
1995
2010
    def __init__(self, tree_delta):
 
2011
        symbol_versioning.warn(symbol_versioning.deprecated_in((2, 3, 0)) %
 
2012
            "BzrRemoveChangedFilesError", DeprecationWarning, stacklevel=2)
1996
2013
        BzrError.__init__(self)
1997
2014
        self.changes_as_text = tree_delta.get_changes_as_text()
1998
2015
        #self.paths_as_string = '\n'.join(changed_files)
2852
2869
        else:
2853
2870
            more = ' ' + more
2854
2871
        import bzrlib.urlutils as urlutils
2855
 
        display_url = urlutils.unescape_for_display(
2856
 
            tree.user_url, 'ascii')
 
2872
        user_url = getattr(tree, "user_url", None)
 
2873
        if user_url is None:
 
2874
            display_url = str(tree)
 
2875
        else:
 
2876
            display_url = urlutils.unescape_for_display(user_url, 'ascii')
2857
2877
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2858
2878
 
2859
2879
 
2937
2957
        self.user_encoding = osutils.get_user_encoding()
2938
2958
 
2939
2959
 
 
2960
class NoSuchConfig(BzrError):
 
2961
 
 
2962
    _fmt = ('The "%(config_id)s" configuration does not exist.')
 
2963
 
 
2964
    def __init__(self, config_id):
 
2965
        BzrError.__init__(self, config_id=config_id)
 
2966
 
 
2967
 
 
2968
class NoSuchConfigOption(BzrError):
 
2969
 
 
2970
    _fmt = ('The "%(option_name)s" configuration option does not exist.')
 
2971
 
 
2972
    def __init__(self, option_name):
 
2973
        BzrError.__init__(self, option_name=option_name)
 
2974
 
 
2975
 
2940
2976
class NoSuchAlias(BzrError):
2941
2977
 
2942
2978
    _fmt = ('The alias "%(alias_name)s" does not exist.')