1
# arch-tag: f82e5927-7118-40ff-b2ca-71279a6e68aa
2
# Copyright (C) 2004 David Allouche <david@allouche.net>
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
class ExecProblem(RuntimeError):
25
def __init__(self, proc):
26
info = [ proc.command ]
28
if proc.signal is not None:
29
status.append("got signal %d" % proc.signal)
30
if proc.status is not None:
31
status.append("exited with code %d" % proc.status)
32
info.append(",".join(status))
33
if proc.status is not None:
34
codes = ' '.join(map(str, proc.expected))
35
if len(proc.expected) == 1:
36
info.append("(expected exit code %s)" % codes)
38
info.append("(expected exit codes %s)" % codes)
39
lines = [' '.join(info)]
40
if proc.args: lines.append('argv: ' + ", ".join(map(repr, proc.args)))
41
if proc.chdir: lines.append('chdir: ' + repr(proc.chdir))
42
if proc.error is not None:
43
error = proc.error.rstrip()
46
if error: lines.extend(("* error report", error))
47
RuntimeError.__init__(self, '\n'.join(lines))
51
class TreeRootError(Exception):
53
"""Could not find the Arch tree-root of a directory."""
55
def __init__(self, dirname):
56
message = "directory is not inside a project tree: %r" % (dirname,)
57
Exception.__init__(self, message)
58
self.dirname = str(dirname)
61
class TreeVersionError(Exception):
63
"""Arch source tree does not have a valid default version."""
65
def __init__(self, tree, bad_version=None):
66
if bad_version is None:
67
message = "tree has no default version set: %r" % (tree,)
69
message = "invalid default version for tree: tree=%r, version=%r" \
71
Exception.__init__(self, message)
73
self.bad_version = bad_version
76
class NamespaceError(Exception):
78
"""Invalid Arch namespace name, or incorrect kind of name.
80
A value that does not make sense in the Arch namespace was
81
provided, or the wrong kind of name was used, for example a
82
revision where a patchlevel is expected.
85
def __init__(self, name, expected=None):
87
message = "invalid name: %s" % (name,)
89
message = "invalid %s: %s" % (expected, name)
90
Exception.__init__(self, message)
92
self.expected = expected
95
class ArchiveNotRegistered(Exception):
97
"""Tried to access an unregistered archive.
99
Namespace existence predicates, implementing `NamespaceObject.exists`,
100
return a boolean value for the existence of a name in the Arch namespace.
101
When the archive a name belongs to is not registered, existence cannot be
102
decided, so this exception is raised.
105
def __init__(self, name):
106
message = "archive not registered: %s" % (name,)
107
Exception.__init__(self, message)
111
class UntaggedFileError(Exception):
113
"""Tried to get the id-tag of file which has none.
115
The id-tag of a file is an id which is set by an explicit id or a
116
tagline. Implicit-style taglines ("tag:") and name-based ids do
120
def __init__(self, name):
121
message = "file has not explicit id nor tagline: %s" % (name,)
122
Exception.__init__(self, message)
125
class IllegalEscapeSequence(Exception):
127
"""Illegal syntax in a pika-escaped string.
129
Pika-escaping is the syntax used to represent spaces, control
130
characters and non-ASCII characters in file names with Arch.
133
def __init__(self, text):
134
message = "illegal escape sequence in %r" % text
135
Exception.__init__(self, message)
139
class NoPristineFoundError(Exception):
141
"""Failed to find a pristine for the given revision.
143
`WorkingTree.find_pristine` raises this exception if no pristine
144
tree can be found for the given revision.
147
def __init__(self, tree, revision):
148
message = "no pristine found for revision %s in tree %r" \
149
% (revision.fullname, str(tree))
150
Exception.__init__(self, message)
151
self.revision, self.tree = revision, tree
154
class MissingFileError(Exception):
156
"""A request file is not present in the given revision.
158
`ArchSourceTree.file_find` raises this exception if the requested
159
does not exist in the specified revision.
162
def __init__(self, tree, name, revision):
163
message = "file %r from the tree %r is not present in revision %s" \
164
% (str(name), str(tree), revision)
165
Exception.__init__(self, message)
166
self.tree, self.name, self.revision = tree, name, revision