mercurial/context.py
changeset 3134 abd9a05fca0b
parent 3126 4bf2e895cf86
parent 3132 81da3c45aabd
child 3135 b1db258e875c
--- a/mercurial/context.py	Tue Sep 19 14:58:54 2006 -0500
+++ b/mercurial/context.py	Tue Sep 19 15:28:13 2006 -0500
@@ -12,10 +12,19 @@
 class changectx(object):
     """A changecontext object makes access to data related to a particular
     changeset convenient."""
-    def __init__(self, repo, changeid):
+    def __init__(self, repo, changeid=None):
         """changeid is a revision number, node, or tag"""
         self._repo = repo
 
+        if not changeid:
+            p1, p2 = self._repo.dirstate.parents()
+            self._rev = self._repo.changelog.rev(p1)
+            if self._rev == -1:
+                changeid = 'tip'
+            else:
+                self._node = p1
+                return
+
         self._node = self._repo.lookup(changeid)
         self._rev = self._repo.changelog.rev(self._node)