18.1.39
by James Westby
Place the package under the GPL |
1 |
# errors.py -- Error classes
|
18.1.43
by James Westby
Correct (C) statements. Add copyright to setup.py |
2 |
# Copyright (C) 2006 James Westby <jw+debian@jameswestby.net>
|
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
3 |
#
|
18.1.39
by James Westby
Place the package under the GPL |
4 |
# This file is part of bzr-builddeb.
|
5 |
#
|
|
75.1.2
by Jelmer Vernooij
Fix some typos |
6 |
# bzr-builddeb is free software; you can redistribute it and/or modify
|
18.1.39
by James Westby
Place the package under the GPL |
7 |
# it under the terms of the GNU General Public License as published by
|
8 |
# the Free Software Foundation; either version 2 of the License, or
|
|
9 |
# (at your option) any later version.
|
|
10 |
#
|
|
11 |
# bzr-builddeb is distributed in the hope that it will be useful,
|
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
# GNU General Public License for more details.
|
|
15 |
#
|
|
16 |
# You should have received a copy of the GNU General Public License
|
|
17 |
# along with bzr-builddeb; if not, write to the Free Software
|
|
18 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
#
|
|
18.1.35
by James Westby
Refactored code to use multiple files. |
20 |
|
42.1.1
by Jelmer Vernooij
Use new style errors (BzrNewError was deprecated in bzr 0.13). |
21 |
from bzrlib.errors import BzrError |
22 |
||
23 |
||
24 |
class DebianError(BzrError): |
|
327.1.4
by James Westby
Fix unprintable DebianError |
25 |
_fmt = "A Debian packaging error occurred: %(cause)s" |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
26 |
|
27 |
def __init__(self, cause): |
|
292
by James Westby
Fix thinko in errors.py changes. |
28 |
BzrError.__init__(self, cause=cause) |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
29 |
|
30 |
||
31 |
class NoSourceDirError(BzrError): |
|
32 |
_fmt = ("There is no existing source directory to use. Use " |
|
33 |
"--export-only or --dont-purge to get one that can be used") |
|
34 |
||
35 |
||
327.2.1
by James Westby
Create UpstreamProvider to extract out the pristine-tar/uscan/etc. logic |
36 |
class MissingUpstreamTarball(BzrError): |
569.1.3
by Jelmer Vernooij
Support multiple upstream tarballs in a couple more places. |
37 |
_fmt = ("Unable to find the needed upstream tarball for package %(package)s, " |
38 |
"version %(version)s.") |
|
327.2.1
by James Westby
Create UpstreamProvider to extract out the pristine-tar/uscan/etc. logic |
39 |
|
569.1.3
by Jelmer Vernooij
Support multiple upstream tarballs in a couple more places. |
40 |
def __init__(self, package, version): |
41 |
BzrError.__init__(self, package=package, version=version) |
|
327.2.1
by James Westby
Create UpstreamProvider to extract out the pristine-tar/uscan/etc. logic |
42 |
|
43 |
||
327.2.6
by James Westby
Improve MergeModeDistiller. |
44 |
class TarFailed(BzrError): |
45 |
_fmt = "There was an error executing tar to %(operation)s %(tarball)s." |
|
46 |
||
47 |
def __init__(self, operation, tarball): |
|
48 |
BzrError.__init__(self, operation=operation, tarball=tarball) |
|
49 |
||
50 |
||
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
51 |
class BuildFailedError(BzrError): |
52 |
_fmt = "The build failed." |
|
53 |
||
54 |
||
327.1.3
by James Westby
Catch and wrap ChangelogParseError to avoid the traceback (LP: #215732) |
55 |
class UnparseableChangelog(BzrError): |
56 |
_fmt = "There was an error parsing the changelog: %(error)s" |
|
57 |
||
58 |
def __init__(self, error): |
|
59 |
BzrError.__init__(self, error=error) |
|
60 |
||
61 |
||
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
62 |
class StopBuild(BzrError): |
63 |
_fmt = "Stopping the build: %(reason)s." |
|
64 |
||
65 |
def __init__(self, reason): |
|
321.1.1
by James Westby
Make errors printable again. |
66 |
BzrError.__init__(self, reason=reason) |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
67 |
|
68 |
||
69 |
class MissingChangelogError(BzrError): |
|
678.3.1
by Jelmer Vernooij
Include full changelog paths that were checked in error message. LP: |
70 |
_fmt = 'Could not find changelog at %(location)s in tree.' |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
71 |
|
72 |
def __init__(self, locations): |
|
321.1.1
by James Westby
Make errors printable again. |
73 |
BzrError.__init__(self, location=locations) |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
74 |
|
75 |
||
76 |
class AddChangelogError(BzrError): |
|
77 |
_fmt = 'Please add "%(changelog)s" to the branch using bzr add.' |
|
78 |
||
79 |
def __init__(self, changelog): |
|
321.1.1
by James Westby
Make errors printable again. |
80 |
BzrError.__init__(self, changelog=changelog) |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
81 |
|
82 |
||
83 |
class ImportError(BzrError): |
|
84 |
_fmt = "The files could not be imported: %(reason)s" |
|
85 |
||
86 |
def __init__(self, reason): |
|
321.1.1
by James Westby
Make errors printable again. |
87 |
BzrError.__init__(self, reason=reason) |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
88 |
|
130
by James Westby
Improve the handling of strange .dsc files. |
89 |
|
178.1.13
by James Westby
Internal hook execution support. |
90 |
class HookFailedError(BzrError): |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
91 |
_fmt = 'The "%(hook_name)s" hook failed.' |
178.1.13
by James Westby
Internal hook execution support. |
92 |
|
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
93 |
def __init__(self, hook_name): |
321.1.1
by James Westby
Make errors printable again. |
94 |
BzrError.__init__(self, hook_name=hook_name) |
178.1.13
by James Westby
Internal hook execution support. |
95 |
|
178.1.29
by James Westby
Add support for incremental import dsc. |
96 |
|
97 |
class OnlyImportSingleDsc(BzrError): |
|
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
98 |
_fmt = "You are only allowed to import one version in incremental mode." |
99 |
||
178.1.29
by James Westby
Add support for incremental import dsc. |
100 |
|
210
by James Westby
* Don't silently skip unkown types when extracting a tarball, error |
101 |
class UnknownType(BzrError): |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
102 |
_fmt = 'Cannot extract "%(path)s" from archive as it is an unknown type.' |
210
by James Westby
* Don't silently skip unkown types when extracting a tarball, error |
103 |
|
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
104 |
def __init__(self, path): |
321.1.1
by James Westby
Make errors printable again. |
105 |
BzrError.__init__(self, path=path) |
210
by James Westby
* Don't silently skip unkown types when extracting a tarball, error |
106 |
|
247
by James Westby
Use standard locations for the directories. |
107 |
|
108 |
class MissingChanges(BzrError): |
|
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
109 |
_fmt = "Could not find .changes file: %(changes)s." |
247
by James Westby
Use standard locations for the directories. |
110 |
|
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
111 |
def __init__(self, changes): |
321.1.1
by James Westby
Make errors printable again. |
112 |
BzrError.__init__(self, changes=changes) |
247
by James Westby
Use standard locations for the directories. |
113 |
|
114 |
||
254
by James Westby
Switch to DistributionBranch for merge-upstream. |
115 |
class UpstreamAlreadyImported(BzrError): |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
116 |
_fmt = 'Upstream version "%(version)s" has already been imported.' |
254
by James Westby
Switch to DistributionBranch for merge-upstream. |
117 |
|
118 |
def __init__(self, version): |
|
321.1.1
by James Westby
Make errors printable again. |
119 |
BzrError.__init__(self, version=str(version)) |
254
by James Westby
Switch to DistributionBranch for merge-upstream. |
120 |
|
121 |
||
321.1.11
by James Westby
Don't try and carry on when upstream branch is already merged. |
122 |
class UpstreamBranchAlreadyMerged(BzrError): |
123 |
_fmt = 'That revision of the upstream branch has already been merged.' |
|
124 |
||
125 |
||
266.1.4
by James Westby
Add a revisionspec that allows you to specify revisions by package versions. |
126 |
class AmbiguousPackageSpecification(BzrError): |
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
127 |
_fmt = ('You didn\'t specify a distribution with the package ' |
128 |
'specification, and tags exists that state that the '
|
|
129 |
'version that you specified has been uploaded to more '
|
|
130 |
'than one distribution. Please specify which version '
|
|
131 |
'you wish to refer to by by appending ":debian" or '
|
|
132 |
'":ubuntu" to the revision specifier: %(specifier)s') |
|
266.1.4
by James Westby
Add a revisionspec that allows you to specify revisions by package versions. |
133 |
|
134 |
def __init__(self, specifier): |
|
321.1.1
by James Westby
Make errors printable again. |
135 |
BzrError.__init__(self, specifier=specifier) |
266.1.4
by James Westby
Add a revisionspec that allows you to specify revisions by package versions. |
136 |
|
137 |
||
138 |
class UnknownVersion(BzrError): |
|
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
139 |
_fmt = ('No tag exists in this branch indicating that version ' |
140 |
'"%(version)s" has been uploaded.') |
|
266.1.4
by James Westby
Add a revisionspec that allows you to specify revisions by package versions. |
141 |
|
142 |
def __init__(self, version): |
|
321.1.1
by James Westby
Make errors printable again. |
143 |
BzrError.__init__(self, version=version) |
266.1.4
by James Westby
Add a revisionspec that allows you to specify revisions by package versions. |
144 |
|
145 |
||
146 |
class VersionNotSpecified(BzrError): |
|
147 |
_fmt = "You did not specify a package version." |
|
148 |
||
149 |
||
334.4.11
by Jelmer Vernooij
use exception to indicate missing package versions rather than boolean return value |
150 |
class PackageVersionNotPresent(BzrError): |
151 |
_fmt = "%(package)s %(version)s was not found in %(upstream)s." |
|
152 |
||
153 |
def __init__(self, package, version, upstream): |
|
154 |
BzrError.__init__(self, package=package, version=version, |
|
155 |
upstream=upstream) |
|
156 |
||
157 |
||
290
by James Westby
Cleanup of the repack tarball code, splitting out the work for each type. |
158 |
class UnsupportedRepackFormat(BzrError): |
159 |
_fmt = ('Either the file extension of "%(location)s" indicates that ' |
|
160 |
'it is a format unsupported for repacking or it is a '
|
|
161 |
'remote directory.') |
|
162 |
||
163 |
def __init__(self, location): |
|
321.1.1
by James Westby
Make errors printable again. |
164 |
BzrError.__init__(self, location=location) |
321.1.2
by James Westby
Initial support for pristine-tar. |
165 |
|
166 |
||
360.1.39
by Muharem Hrnjadovic
Enhancements stemming from James' review comments, round 7 |
167 |
class SharedUpstreamConflictsWithTargetPackaging(BzrError): |
677
by Jelmer Vernooij
Merge new pre_merge hook which has the same behaviour as 'bzr merge-package'. |
168 |
|
360.1.49
by Muharem Hrnjadovic
Better formating of error string. |
169 |
_fmt = ('The upstream branches for the merge source and target have ' |
170 |
'diverged. Unfortunately, the attempt to fix this problem '
|
|
171 |
'resulted in conflicts. Please resolve these, commit and '
|
|
677
by Jelmer Vernooij
Merge new pre_merge hook which has the same behaviour as 'bzr merge-package'. |
172 |
're-run the "%(cmd)s" command to finish. ' |
360.1.49
by Muharem Hrnjadovic
Better formating of error string. |
173 |
'Alternatively, until you commit you can use "bzr revert" to '
|
174 |
'restore the state of the unmerged branch.') |
|
443.3.2
by Jelmer Vernooij
Make it possible to require per file timestamps. |
175 |
|
677
by Jelmer Vernooij
Merge new pre_merge hook which has the same behaviour as 'bzr merge-package'. |
176 |
def __init__(self, cmd): |
177 |
self.cmd = cmd |
|
178 |
||
443.3.2
by Jelmer Vernooij
Make it possible to require per file timestamps. |
179 |
|
180 |
class PerFileTimestampsNotSupported(BzrError): |
|
181 |
||
182 |
_fmt = ("Per file timestamps are not supported by the " |
|
183 |
"currently loaded version of bzrlib.") |
|
451
by James Westby
Add a --package-merge option to builddeb. |
184 |
|
185 |
||
186 |
class NoPreviousUpload(BzrError): |
|
187 |
||
188 |
_fmt = ("There was no previous upload to %(distribution)s.") |
|
189 |
||
190 |
def __init__(self, distribution): |
|
191 |
BzrError.__init__(self, distribution=distribution) |
|
458.1.1
by James Westby
Re-parse the changelog if --package-merge is used so we can see all blocks. |
192 |
|
193 |
||
194 |
class UnableToFindPreviousUpload(BzrError): |
|
195 |
||
196 |
_fmt = ("Unable to determine the previous upload for --package-merge.") |
|
486.3.4
by Jelmer Vernooij
Add more tests, raise exception if there is an inconsistency between source format nativity and version nativity. |
197 |
|
198 |
||
199 |
class InconsistentSourceFormatError(BzrError): |
|
200 |
||
201 |
_fmt = ("Inconsistency between source format and version: version is " |
|
202 |
"%(version_bool)snative, format is %(format_bool)snative.") |
|
203 |
||
204 |
def __init__(self, version_native, format_native): |
|
205 |
if version_native: |
|
206 |
version_bool = "" |
|
207 |
else: |
|
208 |
version_bool = "not " |
|
209 |
if format_native: |
|
210 |
format_bool = "" |
|
211 |
else: |
|
212 |
format_bool = "not " |
|
213 |
BzrError.__init__(self, version_bool=version_bool, format_bool=format_bool) |
|
494.2.11
by Jelmer Vernooij
Implement UScanSource.get_latest_version. |
214 |
|
215 |
||
216 |
class WatchFileMissing(BzrError): |
|
217 |
||
218 |
_fmt = "No watch file found." |
|
508.4.1
by Jelmer Vernooij
Add --strict argument to 'bzr builddeb'. LP: #521341 |
219 |
|
220 |
||
221 |
class StrictBuildFailed(BzrError): |
|
222 |
||
508.4.4
by Jelmer Vernooij
Fix tests to check that 'bzr unknowns' is mentioned. |
223 |
_fmt = ("Build refused because there are unknown files in the tree. " |
508.4.3
by Jelmer Vernooij
Hint the user at 'bzr unknowns'. |
224 |
"To list all known files, run 'bzr unknowns'.") |
558.1.1
by Max Bowsher
Do something a little more useful when dch fails. |
225 |
|
226 |
||
227 |
class DchError(BzrError): |
|
228 |
_fmt = 'There was an error using dch: %(error)s.' |
|
229 |
||
230 |
def __init__(self, error): |
|
231 |
BzrError.__init__(self, error=error) |
|
565.1.1
by Max Bowsher
When attempting to import a package with multiple upstream tarballs, raise |
232 |
|
233 |
||
234 |
class MultipleUpstreamTarballsNotSupported(BzrError): |
|
235 |
||
236 |
_fmt = ("Importing packages using source format 3.0 multiple tarballs " |
|
237 |
"is not yet supported.") |
|
670.1.8
by Jelmer Vernooij
Clean up temp dirs. |
238 |
|
239 |
||
240 |
class QuiltUnapplyError(BzrError): |
|
241 |
||
242 |
_fmt = ("Unable to unapply quilt patches for %(kind)r tree: %(msg)s") |
|
243 |
||
244 |
def __init__(self, kind, msg): |
|
245 |
BzrError.__init__(self) |
|
246 |
self.kind = kind |
|
732.1.1
by Jelmer Vernooij
Cope with quilt output being empty in error message. LP: #1014543 |
247 |
if msg is not None and msg.count("\n") == 1: |
670.1.8
by Jelmer Vernooij
Clean up temp dirs. |
248 |
msg = msg.strip() |
249 |
self.msg = msg |