[PATCH 1 of 6] context: let workingctx parents be overriden

Patrick Mezard pmezard at gmail.com
Sun Jun 15 12:21:37 CDT 2008


# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1213549476 -7200
# Node ID 801e6c072d4e787a0929926f9d8e922d58d72867
# Parent  76021ec849c876bde6fc85485e81cc4d835036fd
context: let workingctx parents be overriden

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -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]) + "+"
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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):
         '''


More information about the Mercurial-devel mailing list