context: let workingctx parents be overriden
authorPatrick Mezard <pmezard@gmail.com>
Wed, 18 Jun 2008 22:52:25 +0200
changeset 6705 fec6bc978843
parent 6704 8251ffb35725
child 6706 716a1296e182
context: let workingctx parents be overriden
mercurial/context.py
mercurial/localrepo.py
--- a/mercurial/context.py	Wed Jun 18 19:04:10 2008 +0200
+++ b/mercurial/context.py	Wed Jun 18 22:52:25 2008 +0200
@@ -444,11 +444,16 @@
 
 class workingctx(changectx):
     """A workingctx object makes access to data related to
-    the current working directory convenient."""
-    def __init__(self, repo):
+    the current working directory convenient.
+    parents - a pair of parent nodeids, or None to use the dirstate.
+    """
+    def __init__(self, repo, parents=None):
         self._repo = repo
         self._rev = None
         self._node = None
+        if parents:
+            p1, p2 = parents
+            self._parents = [self._repo.changectx(p) for p in (p1, p2)]
 
     def __str__(self):
         return str(self._parents[0]) + "+"
--- a/mercurial/localrepo.py	Wed Jun 18 19:04:10 2008 +0200
+++ b/mercurial/localrepo.py	Wed Jun 18 22:52:25 2008 +0200
@@ -491,8 +491,8 @@
     def changectx(self, changeid=None):
         return context.changectx(self, changeid)
 
-    def workingctx(self):
-        return context.workingctx(self)
+    def workingctx(self, parents=None):
+        return context.workingctx(self, parents)
 
     def parents(self, changeid=None):
         '''