Mercurial > hg-stable
changeset 1073:7b35a980b982
[PATCH] raise exceptions with Exception subclasses
Fixed the patch. Using Exception subclasses.
(tweaked by mpm)
author | Bart Trojanowski <bart@jukie.net> |
---|---|
date | Fri, 26 Aug 2005 19:08:25 -0700 |
parents | 05dc7aba22eb |
children | 55bf5cfde69e |
files | mercurial/hgweb.py mercurial/revlog.py mercurial/transaction.py |
diffstat | 3 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb.py Fri Aug 26 16:49:23 2005 -0700 +++ b/mercurial/hgweb.py Fri Aug 26 19:08:25 2005 -0700 @@ -86,7 +86,7 @@ if m: self.map[m.group(1)] = os.path.join(self.base, m.group(2)) else: - raise "unknown map entry '%s'" % l + raise LookupError("unknown map entry '%s'" % l) def __call__(self, t, **map): m = self.defaults.copy()
--- a/mercurial/revlog.py Fri Aug 26 16:49:23 2005 -0700 +++ b/mercurial/revlog.py Fri Aug 26 19:08:25 2005 -0700 @@ -32,7 +32,7 @@ if t == '\0': return bin if t == 'x': return zlib.decompress(bin) if t == 'u': return bin[1:] - raise "unknown compression type %s" % t + raise RevlogError("unknown compression type %s" % t) def hash(text, p1, p2): l = [p1, p2] @@ -120,6 +120,8 @@ def __setitem__(self, key, val): self.p.map[key] = val +class RevlogError(Exception): pass + class revlog: def __init__(self, opener, indexfile, datafile): self.indexfile = indexfile @@ -505,7 +507,7 @@ if node in self.nodemap: # this can happen if two branches make the same change if unique: - raise "already have %s" % hex(node[:4]) + raise RevlogError("already have %s" % hex(node[:4])) chain = node continue delta = chunk[80:] @@ -514,7 +516,7 @@ # retrieve the parent revision of the delta chain chain = p1 if not chain in self.nodemap: - raise "unknown base %s" % short(chain[:4]) + raise RevlogError("unknown base %s" % short(chain[:4])) # full versions are inserted when the needed deltas become # comparable to the uncompressed text or when the previous @@ -533,7 +535,7 @@ text = self.patches(text, [delta]) chk = self.addrevision(text, transaction, link, p1, p2) if chk != node: - raise "consistency error adding group" + raise RevlogError("consistency error adding group") measure = len(text) else: e = (end, len(cdelta), self.base(t), link, p1, p2, node)
--- a/mercurial/transaction.py Fri Aug 26 16:49:23 2005 -0700 +++ b/mercurial/transaction.py Fri Aug 26 19:08:25 2005 -0700 @@ -20,7 +20,7 @@ # abort here if the journal already exists if os.path.exists(journal): - raise "journal already exists - run hg recover" + raise AssertionError("journal already exists - run hg recover") self.report = report self.opener = opener