Show More
@@ -0,0 +1,26 b'' | |||||
|
1 | """ | |||
|
2 | error.py - Mercurial exceptions | |||
|
3 | ||||
|
4 | This allows us to catch exceptions at higher levels without forcing imports | |||
|
5 | ||||
|
6 | Copyright 2005-2008 Matt Mackall <mpm@selenic.com> | |||
|
7 | ||||
|
8 | This software may be used and distributed according to the terms | |||
|
9 | of the GNU General Public License, incorporated herein by reference. | |||
|
10 | """ | |||
|
11 | ||||
|
12 | # Do not import anything here, please | |||
|
13 | ||||
|
14 | class RevlogError(Exception): | |||
|
15 | pass | |||
|
16 | ||||
|
17 | class LookupError(RevlogError, KeyError): | |||
|
18 | def __init__(self, name, index, message): | |||
|
19 | self.name = name | |||
|
20 | if isinstance(name, str) and len(name) == 20: | |||
|
21 | from node import short | |||
|
22 | name = short(name) | |||
|
23 | RevlogError.__init__(self, '%s@%s: %s' % (index, name, message)) | |||
|
24 | ||||
|
25 | def __str__(self): | |||
|
26 | return RevlogError.__str__(self) |
@@ -17,7 +17,7 b' import os, time' | |||||
17 | from mercurial.i18n import _ |
|
17 | from mercurial.i18n import _ | |
18 | from mercurial.repo import RepoError |
|
18 | from mercurial.repo import RepoError | |
19 | from mercurial.node import bin, hex, nullid |
|
19 | from mercurial.node import bin, hex, nullid | |
20 |
from mercurial import hg, |
|
20 | from mercurial import hg, util, context, error | |
21 |
|
21 | |||
22 | from common import NoRepo, commit, converter_source, converter_sink |
|
22 | from common import NoRepo, commit, converter_source, converter_sink | |
23 |
|
23 | |||
@@ -244,7 +244,7 b' class mercurial_source(converter_source)' | |||||
244 | def getfile(self, name, rev): |
|
244 | def getfile(self, name, rev): | |
245 | try: |
|
245 | try: | |
246 | return self.changectx(rev)[name].data() |
|
246 | return self.changectx(rev)[name].data() | |
247 |
except |
|
247 | except error.LookupError, err: | |
248 | raise IOError(err) |
|
248 | raise IOError(err) | |
249 |
|
249 | |||
250 | def getmode(self, name, rev): |
|
250 | def getmode(self, name, rev): | |
@@ -283,7 +283,7 b' class mercurial_source(converter_source)' | |||||
283 | copies[name] = copysource |
|
283 | copies[name] = copysource | |
284 | except TypeError: |
|
284 | except TypeError: | |
285 | pass |
|
285 | pass | |
286 |
except |
|
286 | except error.LookupError, e: | |
287 | if not self.ignoreerrors: |
|
287 | if not self.ignoreerrors: | |
288 | raise |
|
288 | raise | |
289 | self.ignored[name] = 1 |
|
289 | self.ignored[name] = 1 |
@@ -8,7 +8,7 b' imerge - interactive merge' | |||||
8 | from mercurial.i18n import _ |
|
8 | from mercurial.i18n import _ | |
9 | from mercurial.node import hex, short |
|
9 | from mercurial.node import hex, short | |
10 | from mercurial import commands, cmdutil, dispatch, fancyopts |
|
10 | from mercurial import commands, cmdutil, dispatch, fancyopts | |
11 |
from mercurial import hg, filemerge, util, |
|
11 | from mercurial import hg, filemerge, util, error | |
12 | import os, tarfile |
|
12 | import os, tarfile | |
13 |
|
13 | |||
14 | class InvalidStateFileException(Exception): pass |
|
14 | class InvalidStateFileException(Exception): pass | |
@@ -78,7 +78,7 b' class Imerge(object):' | |||||
78 |
|
78 | |||
79 | try: |
|
79 | try: | |
80 | parents = [self.repo.changectx(n) for n in status[:2]] |
|
80 | parents = [self.repo.changectx(n) for n in status[:2]] | |
81 |
except |
|
81 | except error.LookupError, e: | |
82 | raise util.Abort(_('merge parent %s not in repository') % |
|
82 | raise util.Abort(_('merge parent %s not in repository') % | |
83 | short(e.name)) |
|
83 | short(e.name)) | |
84 |
|
84 |
@@ -16,7 +16,7 b' from a changeset hash to its hash in the' | |||||
16 | from mercurial.i18n import _ |
|
16 | from mercurial.i18n import _ | |
17 | import os, tempfile |
|
17 | import os, tempfile | |
18 | from mercurial import bundlerepo, changegroup, cmdutil, hg, merge |
|
18 | from mercurial import bundlerepo, changegroup, cmdutil, hg, merge | |
19 | from mercurial import patch, revlog, util |
|
19 | from mercurial import patch, revlog, util, error | |
20 |
|
20 | |||
21 | class transplantentry: |
|
21 | class transplantentry: | |
22 | def __init__(self, lnode, rnode): |
|
22 | def __init__(self, lnode, rnode): | |
@@ -380,7 +380,7 b' class transplanter:' | |||||
380 | def hasnode(repo, node): |
|
380 | def hasnode(repo, node): | |
381 | try: |
|
381 | try: | |
382 | return repo.changelog.rev(node) != None |
|
382 | return repo.changelog.rev(node) != None | |
383 |
except |
|
383 | except error.RevlogError: | |
384 | return False |
|
384 | return False | |
385 |
|
385 | |||
386 | def browserevs(ui, repo, nodes, opts): |
|
386 | def browserevs(ui, repo, nodes, opts): |
@@ -13,7 +13,7 b' of the GNU General Public License, incor' | |||||
13 | from node import hex, nullid, short |
|
13 | from node import hex, nullid, short | |
14 | from i18n import _ |
|
14 | from i18n import _ | |
15 | import changegroup, util, os, struct, bz2, zlib, tempfile, shutil, mdiff |
|
15 | import changegroup, util, os, struct, bz2, zlib, tempfile, shutil, mdiff | |
16 | import repo, localrepo, changelog, manifest, filelog, revlog, context |
|
16 | import repo, localrepo, changelog, manifest, filelog, revlog, context, error | |
17 |
|
17 | |||
18 | class bundlerevlog(revlog.revlog): |
|
18 | class bundlerevlog(revlog.revlog): | |
19 | def __init__(self, opener, indexfile, bundlefile, |
|
19 | def __init__(self, opener, indexfile, bundlefile, | |
@@ -48,8 +48,8 b' class bundlerevlog(revlog.revlog):' | |||||
48 | continue |
|
48 | continue | |
49 | for p in (p1, p2): |
|
49 | for p in (p1, p2): | |
50 | if not p in self.nodemap: |
|
50 | if not p in self.nodemap: | |
51 |
raise |
|
51 | raise error.LookupError(p1, self.indexfile, | |
52 |
|
|
52 | _("unknown parent")) | |
53 | if linkmapper is None: |
|
53 | if linkmapper is None: | |
54 | link = n |
|
54 | link = n | |
55 | else: |
|
55 | else: | |
@@ -119,7 +119,7 b' class bundlerevlog(revlog.revlog):' | |||||
119 |
|
119 | |||
120 | p1, p2 = self.parents(node) |
|
120 | p1, p2 = self.parents(node) | |
121 | if node != revlog.hash(text, p1, p2): |
|
121 | if node != revlog.hash(text, p1, p2): | |
122 |
raise |
|
122 | raise error.RevlogError(_("integrity check failed on %s:%d") | |
123 | % (self.datafile, self.rev(node))) |
|
123 | % (self.datafile, self.rev(node))) | |
124 |
|
124 | |||
125 | self._cache = (node, self.rev(node), text) |
|
125 | self._cache = (node, self.rev(node), text) |
@@ -8,7 +8,7 b'' | |||||
8 | from node import bin, hex, nullid |
|
8 | from node import bin, hex, nullid | |
9 | from revlog import revlog, RevlogError |
|
9 | from revlog import revlog, RevlogError | |
10 | from i18n import _ |
|
10 | from i18n import _ | |
11 | import util |
|
11 | import util, error | |
12 |
|
12 | |||
13 | def _string_escape(text): |
|
13 | def _string_escape(text): | |
14 | """ |
|
14 | """ | |
@@ -179,7 +179,8 b' class changelog(revlog):' | |||||
179 |
|
179 | |||
180 | user = user.strip() |
|
180 | user = user.strip() | |
181 | if "\n" in user: |
|
181 | if "\n" in user: | |
182 |
raise RevlogError(_("username %s contains a newline") |
|
182 | raise error.RevlogError(_("username %s contains a newline") | |
|
183 | % repr(user)) | |||
183 | user, desc = util.fromlocal(user), util.fromlocal(desc) |
|
184 | user, desc = util.fromlocal(user), util.fromlocal(desc) | |
184 |
|
185 | |||
185 | if date: |
|
186 | if date: |
@@ -9,7 +9,7 b' from node import hex, nullid, nullrev, s' | |||||
9 | from repo import RepoError, NoCapability |
|
9 | from repo import RepoError, NoCapability | |
10 | from i18n import _, gettext |
|
10 | from i18n import _, gettext | |
11 | import os, re, sys |
|
11 | import os, re, sys | |
12 | import hg, util, revlog, bundlerepo, extensions, copies, context |
|
12 | import hg, util, revlog, bundlerepo, extensions, copies, context, error | |
13 | import difflib, patch, time, help, mdiff, tempfile, url |
|
13 | import difflib, patch, time, help, mdiff, tempfile, url | |
14 | import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect |
|
14 | import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect | |
15 | import merge as merge_ |
|
15 | import merge as merge_ | |
@@ -1214,7 +1214,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
1214 | copied = getfile(fn).renamed(ctx.filenode(fn)) |
|
1214 | copied = getfile(fn).renamed(ctx.filenode(fn)) | |
1215 | if copied: |
|
1215 | if copied: | |
1216 | copies.setdefault(rev, {})[fn] = copied[0] |
|
1216 | copies.setdefault(rev, {})[fn] = copied[0] | |
1217 |
except |
|
1217 | except error.LookupError: | |
1218 | pass |
|
1218 | pass | |
1219 | elif st == 'iter': |
|
1219 | elif st == 'iter': | |
1220 | for fn, m in util.sort(matches[rev].items()): |
|
1220 | for fn, m in util.sort(matches[rev].items()): | |
@@ -1887,7 +1887,7 b' def log(ui, repo, *pats, **opts):' | |||||
1887 |
|
1887 | |||
1888 | try: |
|
1888 | try: | |
1889 | return repo[rev][fn].renamed() |
|
1889 | return repo[rev][fn].renamed() | |
1890 |
except |
|
1890 | except error.LookupError: | |
1891 | pass |
|
1891 | pass | |
1892 | return None |
|
1892 | return None | |
1893 |
|
1893 | |||
@@ -2086,7 +2086,7 b' def parents(ui, repo, file_=None, **opts' | |||||
2086 | continue |
|
2086 | continue | |
2087 | try: |
|
2087 | try: | |
2088 | filenodes.append(cp.filenode(file_)) |
|
2088 | filenodes.append(cp.filenode(file_)) | |
2089 |
except |
|
2089 | except error.LookupError: | |
2090 | pass |
|
2090 | pass | |
2091 | if not filenodes: |
|
2091 | if not filenodes: | |
2092 | raise util.Abort(_("'%s' not found in manifest!") % file_) |
|
2092 | raise util.Abort(_("'%s' not found in manifest!") % file_) | |
@@ -2857,7 +2857,7 b' def tags(ui, repo):' | |||||
2857 | try: |
|
2857 | try: | |
2858 | hn = hexfunc(n) |
|
2858 | hn = hexfunc(n) | |
2859 | r = "%5d:%s" % (repo.changelog.rev(n), hn) |
|
2859 | r = "%5d:%s" % (repo.changelog.rev(n), hn) | |
2860 |
except |
|
2860 | except error.LookupError: | |
2861 | r = " ?:%s" % hn |
|
2861 | r = " ?:%s" % hn | |
2862 | else: |
|
2862 | else: | |
2863 | spaces = " " * (30 - util.locallen(t)) |
|
2863 | spaces = " " * (30 - util.locallen(t)) |
@@ -7,7 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from node import nullid, nullrev, short, hex |
|
8 | from node import nullid, nullrev, short, hex | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 |
import ancestor, bdiff, |
|
10 | import ancestor, bdiff, error, util, os, errno | |
11 |
|
11 | |||
12 | class propertycache(object): |
|
12 | class propertycache(object): | |
13 | def __init__(self, func): |
|
13 | def __init__(self, func): | |
@@ -125,15 +125,15 b' class changectx(object):' | |||||
125 | try: |
|
125 | try: | |
126 | return self._manifest[path], self._manifest.flags(path) |
|
126 | return self._manifest[path], self._manifest.flags(path) | |
127 | except KeyError: |
|
127 | except KeyError: | |
128 |
raise |
|
128 | raise error.LookupError(self._node, path, | |
129 |
|
|
129 | _('not found in manifest')) | |
130 | if '_manifestdelta' in self.__dict__ or path in self.files(): |
|
130 | if '_manifestdelta' in self.__dict__ or path in self.files(): | |
131 | if path in self._manifestdelta: |
|
131 | if path in self._manifestdelta: | |
132 | return self._manifestdelta[path], self._manifestdelta.flags(path) |
|
132 | return self._manifestdelta[path], self._manifestdelta.flags(path) | |
133 | node, flag = self._repo.manifest.find(self._changeset[0], path) |
|
133 | node, flag = self._repo.manifest.find(self._changeset[0], path) | |
134 | if not node: |
|
134 | if not node: | |
135 |
raise |
|
135 | raise error.LookupError(self._node, path, | |
136 |
|
|
136 | _('not found in manifest')) | |
137 |
|
137 | |||
138 | return node, flag |
|
138 | return node, flag | |
139 |
|
139 | |||
@@ -143,7 +143,7 b' class changectx(object):' | |||||
143 | def flags(self, path): |
|
143 | def flags(self, path): | |
144 | try: |
|
144 | try: | |
145 | return self._fileinfo(path)[1] |
|
145 | return self._fileinfo(path)[1] | |
146 |
except |
|
146 | except error.LookupError: | |
147 | return '' |
|
147 | return '' | |
148 |
|
148 | |||
149 | def filectx(self, path, fileid=None, filelog=None): |
|
149 | def filectx(self, path, fileid=None, filelog=None): | |
@@ -235,7 +235,7 b' class filectx(object):' | |||||
235 | try: |
|
235 | try: | |
236 | n = self._filenode |
|
236 | n = self._filenode | |
237 | return True |
|
237 | return True | |
238 |
except |
|
238 | except error.LookupError: | |
239 | # file is missing |
|
239 | # file is missing | |
240 | return False |
|
240 | return False | |
241 |
|
241 | |||
@@ -316,7 +316,7 b' class filectx(object):' | |||||
316 | try: |
|
316 | try: | |
317 | if fnode == p.filenode(name): |
|
317 | if fnode == p.filenode(name): | |
318 | return None |
|
318 | return None | |
319 |
except |
|
319 | except error.LookupError: | |
320 | pass |
|
320 | pass | |
321 | return renamed |
|
321 | return renamed | |
322 |
|
322 |
@@ -8,7 +8,7 b'' | |||||
8 | from i18n import _ |
|
8 | from i18n import _ | |
9 | from repo import RepoError |
|
9 | from repo import RepoError | |
10 | import os, sys, atexit, signal, pdb, socket, errno, shlex, time |
|
10 | import os, sys, atexit, signal, pdb, socket, errno, shlex, time | |
11 |
import util, commands, hg, lock, fancyopts, |
|
11 | import util, commands, hg, lock, fancyopts, extensions, hook, error | |
12 | import cmdutil |
|
12 | import cmdutil | |
13 | import ui as _ui |
|
13 | import ui as _ui | |
14 |
|
14 | |||
@@ -76,7 +76,7 b' def _runcatch(ui, args):' | |||||
76 | except lock.LockUnavailable, inst: |
|
76 | except lock.LockUnavailable, inst: | |
77 | ui.warn(_("abort: could not lock %s: %s\n") % |
|
77 | ui.warn(_("abort: could not lock %s: %s\n") % | |
78 | (inst.desc or inst.filename, inst.strerror)) |
|
78 | (inst.desc or inst.filename, inst.strerror)) | |
79 |
except |
|
79 | except error.RevlogError, inst: | |
80 | ui.warn(_("abort: %s!\n") % inst) |
|
80 | ui.warn(_("abort: %s!\n") % inst) | |
81 | except util.SignalInterrupt: |
|
81 | except util.SignalInterrupt: | |
82 | ui.warn(_("killed!\n")) |
|
82 | ui.warn(_("killed!\n")) |
@@ -9,8 +9,8 b'' | |||||
9 | import os, mimetypes |
|
9 | import os, mimetypes | |
10 | from mercurial.node import hex, nullid |
|
10 | from mercurial.node import hex, nullid | |
11 | from mercurial.repo import RepoError |
|
11 | from mercurial.repo import RepoError | |
12 | from mercurial import ui, hg, util, hook |
|
12 | from mercurial import ui, hg, util, hook, error | |
13 |
from mercurial import |
|
13 | from mercurial import templater, templatefilters | |
14 | from common import get_mtime, style_map, ErrorResponse |
|
14 | from common import get_mtime, style_map, ErrorResponse | |
15 | from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
|
15 | from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR | |
16 | from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED |
|
16 | from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED | |
@@ -185,13 +185,13 b' class hgweb(object):' | |||||
185 |
|
185 | |||
186 | return content |
|
186 | return content | |
187 |
|
187 | |||
188 |
except |
|
188 | except error.LookupError, err: | |
189 | req.respond(HTTP_NOT_FOUND, ctype) |
|
189 | req.respond(HTTP_NOT_FOUND, ctype) | |
190 | msg = str(err) |
|
190 | msg = str(err) | |
191 | if 'manifest' not in msg: |
|
191 | if 'manifest' not in msg: | |
192 | msg = 'revision not found: %s' % err.name |
|
192 | msg = 'revision not found: %s' % err.name | |
193 | return tmpl('error', error=msg) |
|
193 | return tmpl('error', error=msg) | |
194 |
except (RepoError, |
|
194 | except (RepoError, error.RevlogError), inst: | |
195 | req.respond(HTTP_SERVER_ERROR, ctype) |
|
195 | req.respond(HTTP_SERVER_ERROR, ctype) | |
196 | return tmpl('error', error=str(inst)) |
|
196 | return tmpl('error', error=str(inst)) | |
197 | except ErrorResponse, inst: |
|
197 | except ErrorResponse, inst: |
@@ -7,7 +7,7 b'' | |||||
7 |
|
7 | |||
8 | import os, mimetypes, re, cgi, copy |
|
8 | import os, mimetypes, re, cgi, copy | |
9 | import webutil |
|
9 | import webutil | |
10 |
from mercurial import |
|
10 | from mercurial import error, archival, templatefilters | |
11 | from mercurial.node import short, hex, nullid |
|
11 | from mercurial.node import short, hex, nullid | |
12 | from mercurial.util import binary, datestr |
|
12 | from mercurial.util import binary, datestr | |
13 | from mercurial.repo import RepoError |
|
13 | from mercurial.repo import RepoError | |
@@ -39,7 +39,7 b' def rawfile(web, req, tmpl):' | |||||
39 |
|
39 | |||
40 | try: |
|
40 | try: | |
41 | fctx = webutil.filectx(web.repo, req) |
|
41 | fctx = webutil.filectx(web.repo, req) | |
42 |
except |
|
42 | except error.LookupError, inst: | |
43 | try: |
|
43 | try: | |
44 | content = manifest(web, req, tmpl) |
|
44 | content = manifest(web, req, tmpl) | |
45 | req.respond(HTTP_OK, web.ctype) |
|
45 | req.respond(HTTP_OK, web.ctype) | |
@@ -93,7 +93,7 b' def file(web, req, tmpl):' | |||||
93 | return manifest(web, req, tmpl) |
|
93 | return manifest(web, req, tmpl) | |
94 | try: |
|
94 | try: | |
95 | return _filerevision(web, tmpl, webutil.filectx(web.repo, req)) |
|
95 | return _filerevision(web, tmpl, webutil.filectx(web.repo, req)) | |
96 |
except |
|
96 | except error.LookupError, inst: | |
97 | try: |
|
97 | try: | |
98 | return manifest(web, req, tmpl) |
|
98 | return manifest(web, req, tmpl) | |
99 | except ErrorResponse: |
|
99 | except ErrorResponse: | |
@@ -521,7 +521,7 b' def filelog(web, req, tmpl):' | |||||
521 | fctx = webutil.filectx(web.repo, req) |
|
521 | fctx = webutil.filectx(web.repo, req) | |
522 | f = fctx.path() |
|
522 | f = fctx.path() | |
523 | fl = fctx.filelog() |
|
523 | fl = fctx.filelog() | |
524 |
except |
|
524 | except error.LookupError: | |
525 | f = webutil.cleanpath(web.repo, req.form['file'][0]) |
|
525 | f = webutil.cleanpath(web.repo, req.form['file'][0]) | |
526 | fl = web.repo.file(f) |
|
526 | fl = web.repo.file(f) | |
527 | numrevs = len(fl) |
|
527 | numrevs = len(fl) |
@@ -10,7 +10,7 b' from i18n import _' | |||||
10 | import repo, changegroup |
|
10 | import repo, changegroup | |
11 | import changelog, dirstate, filelog, manifest, context, weakref |
|
11 | import changelog, dirstate, filelog, manifest, context, weakref | |
12 | import lock, transaction, stat, errno, ui, store |
|
12 | import lock, transaction, stat, errno, ui, store | |
13 |
import os |
|
13 | import os, time, util, extensions, hook, inspect, error | |
14 | import match as match_ |
|
14 | import match as match_ | |
15 | import merge as merge_ |
|
15 | import merge as merge_ | |
16 |
|
16 | |||
@@ -177,7 +177,7 b' class localrepository(repo.repository):' | |||||
177 | else: |
|
177 | else: | |
178 | try: |
|
178 | try: | |
179 | prevtags = self.filectx('.hgtags', parent).data() |
|
179 | prevtags = self.filectx('.hgtags', parent).data() | |
180 |
except |
|
180 | except error.LookupError: | |
181 | pass |
|
181 | pass | |
182 | fp = self.wfile('.hgtags', 'wb') |
|
182 | fp = self.wfile('.hgtags', 'wb') | |
183 | if prevtags: |
|
183 | if prevtags: | |
@@ -332,7 +332,7 b' class localrepository(repo.repository):' | |||||
332 | rev = c.rev() |
|
332 | rev = c.rev() | |
333 | try: |
|
333 | try: | |
334 | fnode = c.filenode('.hgtags') |
|
334 | fnode = c.filenode('.hgtags') | |
335 |
except |
|
335 | except error.LookupError: | |
336 | continue |
|
336 | continue | |
337 | ret.append((rev, node, fnode)) |
|
337 | ret.append((rev, node, fnode)) | |
338 | if fnode in last: |
|
338 | if fnode in last: |
@@ -6,9 +6,9 b'' | |||||
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 |
|
7 | |||
8 | from node import bin, hex, nullid |
|
8 | from node import bin, hex, nullid | |
9 |
from revlog import revlog |
|
9 | from revlog import revlog | |
10 | from i18n import _ |
|
10 | from i18n import _ | |
11 | import array, struct, mdiff, parsers, util |
|
11 | import array, struct, mdiff, parsers, util, error | |
12 |
|
12 | |||
13 | class manifestdict(dict): |
|
13 | class manifestdict(dict): | |
14 | def __init__(self, mapping=None, flags=None): |
|
14 | def __init__(self, mapping=None, flags=None): | |
@@ -125,7 +125,8 b' class manifest(revlog):' | |||||
125 | def checkforbidden(l): |
|
125 | def checkforbidden(l): | |
126 | for f in l: |
|
126 | for f in l: | |
127 | if '\n' in f or '\r' in f: |
|
127 | if '\n' in f or '\r' in f: | |
128 | raise RevlogError(_("'\\n' and '\\r' disallowed in filenames")) |
|
128 | raise error.RevlogError( | |
|
129 | _("'\\n' and '\\r' disallowed in filenames")) | |||
129 |
|
130 | |||
130 | # if we're using the listcache, make sure it is valid and |
|
131 | # if we're using the listcache, make sure it is valid and | |
131 | # parented by the same node we're diffing against |
|
132 | # parented by the same node we're diffing against |
@@ -13,7 +13,7 b' of the GNU General Public License, incor' | |||||
13 | from node import bin, hex, nullid, nullrev, short |
|
13 | from node import bin, hex, nullid, nullrev, short | |
14 | from i18n import _ |
|
14 | from i18n import _ | |
15 | import changegroup, errno, ancestor, mdiff, parsers |
|
15 | import changegroup, errno, ancestor, mdiff, parsers | |
16 | import struct, util, zlib |
|
16 | import struct, util, zlib, error | |
17 |
|
17 | |||
18 | _pack = struct.pack |
|
18 | _pack = struct.pack | |
19 | _unpack = struct.unpack |
|
19 | _unpack = struct.unpack | |
@@ -29,18 +29,8 b' REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDAT' | |||||
29 | REVLOG_DEFAULT_FORMAT = REVLOGNG |
|
29 | REVLOG_DEFAULT_FORMAT = REVLOGNG | |
30 | REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS |
|
30 | REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS | |
31 |
|
31 | |||
32 | class RevlogError(Exception): |
|
32 | RevlogError = error.RevlogError | |
33 | pass |
|
33 | LookupError = error.LookupError | |
34 |
|
||||
35 | class LookupError(RevlogError, KeyError): |
|
|||
36 | def __init__(self, name, index, message): |
|
|||
37 | self.name = name |
|
|||
38 | if isinstance(name, str) and len(name) == 20: |
|
|||
39 | name = short(name) |
|
|||
40 | RevlogError.__init__(self, _('%s@%s: %s') % (index, name, message)) |
|
|||
41 |
|
||||
42 | def __str__(self): |
|
|||
43 | return RevlogError.__str__(self) |
|
|||
44 |
|
34 | |||
45 | def getoffset(q): |
|
35 | def getoffset(q): | |
46 | return int(q >> 16) |
|
36 | return int(q >> 16) |
General Comments 0
You need to be logged in to leave comments.
Login now