mercurial/revlog.py
changeset 469 e205194ca7ef
parent 451 c9d134165392
child 476 0a338d506268
child 484 934279f3ca53
--- a/mercurial/revlog.py	Fri Jun 24 23:22:46 2005 -0800
+++ b/mercurial/revlog.py	Fri Jun 24 23:50:27 2005 -0800
@@ -98,6 +98,7 @@
         self.p.load()
         return key in self.p.map
     def __iter__(self):
+        yield nullid
         for i in xrange(self.p.l):
             try:
                 yield self.p.index[i][6]
@@ -192,12 +193,14 @@
     def lookup(self, id):
         try:
             rev = int(id)
-            if str(rev) != id: raise "mismatch"
+            if str(rev) != id: raise ValueError
+            if rev < 0: rev = self.count() + rev
+            if rev < 0 or rev >= self.count: raise ValueError
             return self.node(rev)
-        except:
+        except (ValueError, OverflowError):
             c = []
             for n in self.nodemap:
-                if id in hex(n):
+                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")