/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: Michael Ellerman
  • Date: 2006-05-31 08:44:29 UTC
  • mto: (1711.2.63 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1792.
  • Revision ID: michael@ellerman.id.au-20060531084429-35e5429abda9f560
Add optional location to ancestry and fix behaviour for checkouts.

This adds an optional location parameter to the ancestry command. It also
changes the behaviour of ancestry on checkouts such that if they have
been created with a subset of the branch history, only the subset is
shown by 'bzr ancestry'. Tests for all of that as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
... except:
35
35
...   print sys.exc_type
36
36
...   print sys.exc_value
37
 
...   path = getattr(sys.exc_value, 'path')
 
37
...   path = getattr(sys.exc_value, 'path', None)
38
38
...   if path is not None:
39
39
...     print path
40
40
bzrlib.errors.NotBranchError
68
68
# TODO: Convert all the other error classes here to BzrNewError, and eliminate
69
69
# the old one.
70
70
 
 
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
 
71
75
 
72
76
class BzrError(StandardError):
73
77
    def __str__(self):
130
134
class InvalidRevisionId(BzrNewError):
131
135
    """Invalid revision-id {%(revision_id)s} in %(branch)s"""
132
136
    def __init__(self, revision_id, branch):
 
137
        # branch can be any string or object with __str__ defined
133
138
        BzrNewError.__init__(self)
134
139
        self.revision_id = revision_id
135
140
        self.branch = branch
136
141
 
137
142
 
138
143
class NoWorkingTree(BzrNewError):
139
 
    """No WorkingTree exists for %s(base)."""
 
144
    """No WorkingTree exists for %(base)s."""
140
145
    
141
146
    def __init__(self, base):
142
147
        BzrNewError.__init__(self)
144
149
 
145
150
 
146
151
class NotLocalUrl(BzrNewError):
147
 
    """%s(url) is not a local path."""
 
152
    """%(url)s is not a local path."""
148
153
    
149
154
    def __init__(self, url):
150
155
        BzrNewError.__init__(self)
172
177
    """Commit refused because there are unknowns in the tree."""
173
178
 
174
179
 
 
180
# XXX: Should be unified with TransportError; they seem to represent the
 
181
# same thing
175
182
class PathError(BzrNewError):
176
183
    """Generic path error: %(path)r%(extra)s)"""
177
184
 
221
228
 
222
229
 
223
230
class AlreadyBranchError(PathError):
224
 
    """Already a branch: %(path)s. Use `bzr checkout` to build a working tree."""
 
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"""
225
237
 
226
238
 
227
239
class NoRepositoryPresent(BzrNewError):
228
 
    """Not repository present: %(path)r"""
 
240
    """No repository present: %(path)r"""
229
241
    def __init__(self, bzrdir):
230
242
        BzrNewError.__init__(self)
231
243
        self.path = bzrdir.transport.clone('..').base
280
292
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
281
293
 
282
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
 
283
309
class BadFileKindError(BzrError):
284
310
    """Specified file is of a kind that cannot be added.
285
311
 
764
790
    """Parameter $(param)s is required but not present."""
765
791
 
766
792
 
 
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
 
767
801
class DependencyNotPresent(BzrNewError):
768
802
    """Unable to import library "%(library)s": %(error)s"""
769
803
 
857
891
        self.method = method
858
892
        self.mname = method.__name__
859
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):
 
904
        BzrNewError.__init__(self)
 
905
        self.path = path