~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Aaron Bentley
  • Date: 2006-03-18 23:40:51 UTC
  • mto: This revision was merged to the branch mainline in revision 1615.
  • Revision ID: aaron.bentley@utoronto.ca-20060318234051-415e5fcb51da82e4
Allow merge against self, make fetching self a noop

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
fullstop.
54
54
"""
55
55
 
56
 
from warnings import warn
57
 
 
58
56
# based on Scott James Remnant's hct error classes
59
57
 
60
58
# TODO: is there any value in providing the .args field used by standard
68
66
# TODO: Convert all the other error classes here to BzrNewError, and eliminate
69
67
# the old one.
70
68
 
71
 
# TODO: The pattern (from hct) of using classes docstrings as message
72
 
# templates is cute but maybe not such a great idea - perhaps should have a
73
 
# separate static message_template.
74
 
 
75
69
 
76
70
class BzrError(StandardError):
77
71
    def __str__(self):
134
128
class InvalidRevisionId(BzrNewError):
135
129
    """Invalid revision-id {%(revision_id)s} in %(branch)s"""
136
130
    def __init__(self, revision_id, branch):
137
 
        # branch can be any string or object with __str__ defined
138
131
        BzrNewError.__init__(self)
139
132
        self.revision_id = revision_id
140
133
        self.branch = branch
141
134
 
142
135
 
143
136
class NoWorkingTree(BzrNewError):
144
 
    """No WorkingTree exists for %(base)s."""
 
137
    """No WorkingTree exists for %s(base)."""
145
138
    
146
139
    def __init__(self, base):
147
140
        BzrNewError.__init__(self)
149
142
 
150
143
 
151
144
class NotLocalUrl(BzrNewError):
152
 
    """%(url)s is not a local path."""
 
145
    """%s(url) is not a local path."""
153
146
    
154
147
    def __init__(self, url):
155
148
        BzrNewError.__init__(self)
177
170
    """Commit refused because there are unknowns in the tree."""
178
171
 
179
172
 
180
 
# XXX: Should be unified with TransportError; they seem to represent the
181
 
# same thing
182
173
class PathError(BzrNewError):
183
174
    """Generic path error: %(path)r%(extra)s)"""
184
 
 
185
175
    def __init__(self, path, extra=None):
186
176
        BzrNewError.__init__(self)
187
177
        self.path = path
203
193
    """Directory not empty: %(path)r%(extra)s"""
204
194
 
205
195
 
206
 
class ResourceBusy(PathError):
207
 
    """Device or resource busy: %(path)r%(extra)s"""
208
 
 
209
 
 
210
196
class PermissionDenied(PathError):
211
197
    """Permission denied: %(path)r%(extra)s"""
212
198
 
223
209
            self.extra = ''
224
210
 
225
211
 
226
 
class NotBranchError(PathError):
 
212
class NotBranchError(BzrNewError):
227
213
    """Not a branch: %(path)s"""
228
 
 
229
 
 
230
 
class AlreadyBranchError(PathError):
231
 
    """Already a branch: %(path)s."""
232
 
 
233
 
 
234
 
class BranchExistsWithoutWorkingTree(PathError):
235
 
    """Directory contains a branch, but no working tree \
236
 
(use bzr checkout if you wish to build a working tree): %(path)s"""
 
214
    def __init__(self, path):
 
215
        BzrNewError.__init__(self)
 
216
        self.path = path
237
217
 
238
218
 
239
219
class NoRepositoryPresent(BzrNewError):
240
 
    """No repository present: %(path)r"""
 
220
    """Not repository present: %(path)r"""
241
221
    def __init__(self, bzrdir):
242
222
        BzrNewError.__init__(self)
243
223
        self.path = bzrdir.transport.clone('..').base
281
261
        self.path = path
282
262
 
283
263
 
284
 
class PathsNotVersionedError(BzrNewError):
285
 
    # used when reporting several paths are not versioned
286
 
    """Path(s) are not versioned: %(paths_as_string)s"""
287
 
 
288
 
    def __init__(self, paths):
289
 
        from bzrlib.osutils import quotefn
290
 
        BzrNewError.__init__(self)
291
 
        self.paths = paths
292
 
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
293
 
 
294
 
 
295
 
class PathsDoNotExist(BzrNewError):
296
 
    """Path(s) do not exist: %(paths_as_string)s"""
297
 
 
298
 
    # used when reporting that paths are neither versioned nor in the working
299
 
    # tree
300
 
 
301
 
    def __init__(self, paths):
302
 
        # circular import
303
 
        from bzrlib.osutils import quotefn
304
 
        BzrNewError.__init__(self)
305
 
        self.paths = paths
306
 
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
307
 
 
308
 
 
309
264
class BadFileKindError(BzrError):
310
265
    """Specified file is of a kind that cannot be added.
311
266
 
435
390
 
436
391
 
437
392
class DivergedBranches(BzrError):
438
 
 
439
393
    def __init__(self, branch1, branch2):
440
394
        BzrError.__init__(self, "These branches have diverged.  Try merge.")
441
395
        self.branch1 = branch1
482
436
 
483
437
class AmbiguousBase(BzrError):
484
438
    def __init__(self, bases):
485
 
        warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
486
 
                DeprecationWarning)
487
439
        msg = "The correct base is unclear, becase %s are all equally close" %\
488
440
            ", ".join(bases)
489
441
        BzrError.__init__(self, msg)
790
742
    """Parameter $(param)s is required but not present."""
791
743
 
792
744
 
793
 
class BzrBadParameterUnicode(BzrBadParameter):
794
 
    """Parameter %(param)s is unicode but only byte-strings are permitted."""
795
 
 
796
 
 
797
 
class BzrBadParameterContainsNewline(BzrBadParameter):
798
 
    """Parameter %(param)s contains a newline."""
799
 
 
800
 
 
801
745
class DependencyNotPresent(BzrNewError):
802
746
    """Unable to import library "%(library)s": %(error)s"""
803
747
 
856
800
    """Error in merge modified format"""
857
801
 
858
802
 
859
 
class ConflictFormatError(BzrNewError):
860
 
    """Format error in conflict listings"""
861
 
 
862
 
 
863
803
class CorruptRepository(BzrNewError):
864
804
    """An error has been detected in the repository %(repo_path)s.
865
805
Please run bzr reconcile on this repository."""
885
825
    """A nested progress bar was not 'finished' correctly."""
886
826
 
887
827
 
888
 
class UnsupportedOperation(BzrNewError):
889
 
    """The method %(mname)s is not supported on objects of type %(tname)s."""
890
 
    def __init__(self, method, method_self):
891
 
        self.method = method
892
 
        self.mname = method.__name__
893
 
        self.tname = type(method_self).__name__
894
 
 
895
 
 
896
 
class BinaryFile(BzrNewError):
897
 
    """File is binary but should be text."""
898
 
 
899
 
 
900
 
class IllegalPath(BzrNewError):
901
 
    """The path %(path)s is not permitted on this platform"""
902
 
 
903
 
    def __init__(self, path):
 
828
class CantFetchSelf(BzrNewError):
 
829
    """Cannot fetch from a branch at %(base)s to itself."""
 
830
    def __init__(self, branch):
904
831
        BzrNewError.__init__(self)
905
 
        self.path = path
 
832
        self.branch = branch
 
833
        self.base = branch.base