changeset 3214:696c656202a0

context: make filectx remember changectx in changectx.filectx
author Matt Mackall <mpm@selenic.com>
date Mon, 02 Oct 2006 15:02:28 -0500
parents e8199702cf4e
children 931288cf58a7
files mercurial/context.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Mon Oct 02 14:23:38 2006 -0500
+++ b/mercurial/context.py	Mon Oct 02 15:02:28 2006 -0500
@@ -83,7 +83,7 @@
         """get a file context from this changeset"""
         if fileid is None:
             fileid = self.filenode(path)
-        return filectx(self._repo, path, fileid=fileid)
+        return filectx(self._repo, path, fileid=fileid, changectx=self)
 
     def filectxs(self):
         """generate a file context for each file in this changeset's
@@ -104,7 +104,8 @@
 class filectx(object):
     """A filecontext object makes access to data related to a particular
        filerevision convenient."""
-    def __init__(self, repo, path, changeid=None, fileid=None, filelog=None):
+    def __init__(self, repo, path, changeid=None, fileid=None,
+                 filelog=None, changectx=None):
         """changeid can be a changeset revision, node, or tag.
            fileid can be a file revision or node."""
         self._repo = repo
@@ -114,6 +115,9 @@
 
         if filelog:
             self._filelog = filelog
+        if changectx:
+            self._changectx = changectx
+            self._changeid = changectx.node()
 
         if fileid is None:
             self._changeid = changeid