changeset 86:1b945e8ba67b

Friendlier exceptions for unknown node errors
author mpm@selenic.com
date Tue, 17 May 2005 12:20:29 -0800
parents 58a1a0425c9b
children b2b3fdbd79f4
files mercurial/revlog.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Tue May 17 11:40:45 2005 -0800
+++ b/mercurial/revlog.py	Tue May 17 12:20:29 2005 -0800
@@ -78,7 +78,7 @@
         self.p = parser
     def load(self, key):
         n = self.p.data.find(key)
-        if n < 0: raise KeyError(key)
+        if n < 0: raise KeyError("node " + hex(key))
         pos = n / self.p.s
         self.p.load(pos)
     def __contains__(self, key):
@@ -91,8 +91,11 @@
         try:
             return self.p.map[key]
         except KeyError:
-            self.load(key)
-            return self.p.map[key]
+            try:
+                self.load(key)
+                return self.p.map[key]
+            except KeyError:
+                raise KeyError("node " + hex(key))
     def __setitem__(self, key, val):
         self.p.map[key] = val