revlog: raise informative exception if file is missing.
authorBryan O'Sullivan <bos@serpentine.com>
Sun, 04 Sep 2005 14:45:03 -0700
changeset 1201 59bfbdbc38f6
parent 1200 333de1d53846
child 1202 71111d796e40
revlog: raise informative exception if file is missing.
mercurial/revlog.py
--- a/mercurial/revlog.py	Sun Sep 04 14:21:53 2005 -0700
+++ b/mercurial/revlog.py	Sun Sep 04 14:45:03 2005 -0700
@@ -206,11 +206,15 @@
     def tip(self): return self.node(len(self.index) - 1)
     def count(self): return len(self.index)
     def node(self, rev): return (rev < 0) and nullid or self.index[rev][6]
-    def rev(self, node): return self.nodemap[node]
-    def linkrev(self, node): return self.index[self.nodemap[node]][3]
+    def rev(self, node):
+        try:
+            return self.nodemap[node]
+        except KeyError:
+            raise KeyError('%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)
-        return self.index[self.nodemap[node]][4:6]
+        return self.index[self.rev(node)][4:6]
 
     def start(self, rev): return self.index[rev][0]
     def length(self, rev): return self.index[rev][1]