Friendlier exceptions for unknown node errors
authormpm@selenic.com
Tue, 17 May 2005 12:20:29 -0800
changeset 86 1b945e8ba67b
parent 85 58a1a0425c9b
child 87 b2b3fdbd79f4
Friendlier exceptions for unknown node errors
mercurial/revlog.py
--- 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