changeset 1201:59bfbdbc38f6

revlog: raise informative exception if file is missing.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun, 04 Sep 2005 14:45:03 -0700
parents 333de1d53846
children 71111d796e40
files mercurial/revlog.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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]