# HG changeset patch # User mpm@selenic.com # Date 1126161508 25200 # Node ID 34706a835d4ad77c75fec3a2b733d01ed22b1ac0 # Parent db9639b8594c213769ce654625ca5e99a9b1c07d Smarter handling of revlog key errors Use RevlogError for reporting exceptions Catch and report RevlogError exceptions at the command parser diff -r db9639b8594c -r 34706a835d4a mercurial/commands.py --- a/mercurial/commands.py Wed Sep 07 23:13:12 2005 -0700 +++ b/mercurial/commands.py Wed Sep 07 23:38:28 2005 -0700 @@ -1961,6 +1961,8 @@ raise except hg.RepoError, inst: u.warn("abort: ", inst, "!\n") + except revlog.RevlogError, inst: + u.warn("abort: ", inst, "!\n") except SignalInterrupt: u.warn("killed!\n") except KeyboardInterrupt: diff -r db9639b8594c -r 34706a835d4a mercurial/revlog.py --- a/mercurial/revlog.py Wed Sep 07 23:13:12 2005 -0700 +++ b/mercurial/revlog.py Wed Sep 07 23:38:28 2005 -0700 @@ -111,7 +111,8 @@ def load(self, key): if self.p.all: return n = self.p.data.find(key) - if n < 0: raise KeyError("node " + hex(key)) + if n < 0: + raise KeyError(key) pos = n / self.p.s self.p.load(pos) def __contains__(self, key): @@ -210,7 +211,7 @@ try: return self.nodemap[node] except KeyError: - raise KeyError('%s: no node %s' % (self.indexfile, hex(node))) + raise RevlogError('%s: no node %s' % (self.indexfile, hex(node))) def linkrev(self, node): return self.index[self.rev(node)][3] def parents(self, node): if node == nullid: return (nullid, nullid) @@ -290,8 +291,8 @@ for n in self.nodemap: if hex(n).startswith(id): c.append(n) - if len(c) > 1: raise KeyError("Ambiguous identifier") - if len(c) < 1: raise KeyError("No match found") + if len(c) > 1: raise RevlogError("Ambiguous identifier") + if len(c) < 1: raise RevlogError("No match found") return c[0] return None @@ -353,7 +354,7 @@ text = mdiff.patches(text, bins) if node != hash(text, p1, p2): - raise IOError("integrity check failed on %s:%d" + raise RevlogError("integrity check failed on %s:%d" % (self.datafile, rev)) self.cache = (node, rev, text)