diff mercurial/context.py @ 7367:ad0eb8762458

context: special-case changectx setup for integer changeid
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Thu, 13 Nov 2008 21:09:51 +0100
parents 9fe97eea5510
children 595ba2537d4f
line wrap: on
line diff
--- a/mercurial/context.py	Thu Nov 13 12:52:03 2008 -0600
+++ b/mercurial/context.py	Thu Nov 13 21:09:51 2008 +0100
@@ -17,8 +17,12 @@
         if changeid == '':
             changeid = '.'
         self._repo = repo
-        self._node = self._repo.lookup(changeid)
-        self._rev = self._repo.changelog.rev(self._node)
+        if isinstance(changeid, (long, int)):
+            self._rev = changeid
+            self._node = self._repo.changelog.node(changeid)
+        else:
+            self._node = self._repo.lookup(changeid)
+            self._rev = self._repo.changelog.rev(self._node)
 
     def __str__(self):
         return short(self.node())
@@ -59,8 +63,8 @@
             self._manifestdelta = md
             return self._manifestdelta
         elif name == '_parents':
-            p = self._repo.changelog.parents(self._node)
-            if p[1] == nullid:
+            p = self._repo.changelog.parentrevs(self._rev)
+            if p[1] == nullrev:
                 p = p[:-1]
             self._parents = [changectx(self._repo, x) for x in p]
             return self._parents