~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Martin Pool
  • Date: 2005-09-09 09:44:03 UTC
  • Revision ID: mbp@sourcefrog.net-20050909094403-ddad5896b0b12c68
- weave commit records per-file ancestors

 - commits of merges are currently forbidden

 - files that existed in the previous revision are recorded with that 
   parent

 'weave annotate' on woven files now gives the correct result!

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
######################################################################
24
24
# exceptions 
25
25
class BzrError(StandardError):
26
 
    pass
 
26
    def __str__(self):
 
27
        if len(self.args) == 1:
 
28
            return self.args[0]
 
29
        elif len(self.args) == 2:
 
30
            # further explanation or suggestions
 
31
            return '\n  '.join([self.args[0]] + self.args[1])
 
32
        else:
 
33
            return `self.args`
 
34
 
27
35
 
28
36
class BzrCheckError(BzrError):
29
37
    pass
30
38
 
31
39
 
 
40
class InvalidRevisionNumber(BzrError):
 
41
    def __init__(self, revno):
 
42
        self.args = [revno]
 
43
        
 
44
    def __str__(self):
 
45
        return 'invalid revision number: %r' % self.args[0]
 
46
 
 
47
 
 
48
class InvalidRevisionId(BzrError):
 
49
    pass
 
50
 
 
51
 
32
52
class BzrCommandError(BzrError):
33
53
    # Error from malformed user command
34
54
    pass
39
59
    pass
40
60
 
41
61
 
 
62
class NotVersionedError(BzrError):
 
63
    """Specified object is not versioned."""
 
64
 
 
65
 
42
66
class BadFileKindError(BzrError):
43
67
    """Specified file is of a kind that cannot be added.
44
68
 
62
86
            Exception.__init__(self, e)
63
87
        else:
64
88
            Exception.__init__(self)
 
89
 
 
90
 
 
91
class PointlessCommit(Exception):
 
92
    """Commit failed because nothing was changed."""
 
93
 
 
94
 
 
95
class NoSuchRevision(BzrError):
 
96
    def __init__(self, branch, revision):
 
97
        self.branch = branch
 
98
        self.revision = revision
 
99
        msg = "Branch %s has no revision %s" % (branch, revision)
 
100
        BzrError.__init__(self, msg)
 
101
 
 
102
 
 
103
class HistoryMissing(BzrError):
 
104
    def __init__(self, branch, object_type, object_id):
 
105
        self.branch = branch
 
106
        BzrError.__init__(self,
 
107
                          '%s is missing %s {%s}'
 
108
                          % (branch, object_type, object_id))
 
109
 
 
110
 
 
111
class UnrelatedBranches(BzrCommandError):
 
112
    def __init__(self):
 
113
        msg = "Branches have no common ancestor, and no base revision"\
 
114
            " specified."
 
115
        BzrCommandError.__init__(self, msg)
 
116
 
 
117
 
 
118
class NotAncestor(BzrError):
 
119
    def __init__(self, rev_id, not_ancestor_id):
 
120
        self.rev_id = rev_id
 
121
        self.not_ancestor_id = not_ancestor_id
 
122
        msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id, 
 
123
                                                        rev_id)
 
124
        BzrError.__init__(self, msg)
 
125
 
 
126
 
 
127
class InstallFailed(BzrError):
 
128
    def __init__(self, revisions):
 
129
        self.revisions = revisions
 
130
        msg = "Could not install revisions:\n%s" % " ,".join(revisions)
 
131
        BzrError.__init__(self, msg)
 
132
 
 
133
 
 
134
class AmbiguousBase(BzrError):
 
135
    def __init__(self, bases):
 
136
        msg = "The correct base is unclear, becase %s are all equally close" %\
 
137
            ", ".join(bases)
 
138
        BzrError.__init__(self, msg)
 
139
        self.bases = bases
 
140