lookup: fast-paths for int and 'tip'
authorMatt Mackall <mpm@selenic.com>
Fri, 14 Nov 2008 14:12:43 -0600
changeset 7377 374a6b3ac623
parent 7376 fc06bd17c985
child 7378 8dde275680d8
lookup: fast-paths for int and 'tip'
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Fri Nov 14 14:12:16 2008 -0600
+++ b/mercurial/localrepo.py	Fri Nov 14 14:12:43 2008 -0600
@@ -437,10 +437,14 @@
             partial[b] = c.node()
 
     def lookup(self, key):
-        if key == '.':
+        if isinstance(key, int):
+            return self.changelog.node(key)
+        elif key == '.':
             return self.dirstate.parents()[0]
         elif key == 'null':
             return nullid
+        elif key == 'tip':
+            return self.changelog.tip()
         n = self.changelog._match(key)
         if n:
             return n