revlog: handle integer arguments to lookup
authorMatt Mackall <mpm@selenic.com>
Wed, 28 Jun 2006 15:49:33 -0500
changeset 2560 c35694df7b13
parent 2501 b73552a00b20
child 2561 494f7787d8ee
revlog: handle integer arguments to lookup
mercurial/revlog.py
--- a/mercurial/revlog.py	Mon Jun 26 16:47:24 2006 +0200
+++ b/mercurial/revlog.py	Wed Jun 28 15:49:33 2006 -0500
@@ -743,6 +743,11 @@
 
     def lookup(self, id):
         """locate a node based on revision number or subset of hex nodeid"""
+        if type(id) == type(0):
+            rev = id
+            if rev < 0: rev = self.count() + rev
+            if rev < 0 or rev >= self.count(): return None
+            return self.node(rev)
         try:
             rev = int(id)
             if str(rev) != id: raise ValueError