changeset 3122:da85145d4571

filectx: add rename traversal for parents()
author Matt Mackall <mpm@selenic.com>
date Sun, 17 Sep 2006 22:20:44 -0500
parents 2ef0b3aae186
children 4ea58eb3f0c9
files mercurial/context.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Sun Sep 17 21:27:30 2006 -0500
+++ b/mercurial/context.py	Sun Sep 17 22:20:44 2006 -0500
@@ -5,6 +5,8 @@
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
+from node import *
+
 class changectx(object):
     """A changecontext object makes access to data related to a particular
     changeset convenient."""
@@ -33,7 +35,7 @@
     def node(self): return self._node
     def user(self): return self.changeset()[1]
     def date(self): return self.changeset()[2]
-    def changedfiles(self): return self.changeset()[3]
+    def files(self): return self.changeset()[3]
     def description(self): return self.changeset()[4]
 
     def parents(self):
@@ -111,11 +113,14 @@
     def data(self): return self._filelog.read(self._filenode)
     def metadata(self): return self._filelog.readmeta(self._filenode)
     def renamed(self): return self._filelog.renamed(self._filenode)
+    def path(self): return self._path
 
     def parents(self):
-        # need to fix for renames
-        p = self._filelog.parents(self._filenode)
-        return [ filectx(self._repo, self._path, fileid=x) for x in p ]
+        p = [ (self._path, n) for n in self._filelog.parents(self._filenode) ]
+        r = self.renamed()
+        if r:
+            p[0] = r
+        return [ filectx(self._repo, p, fileid=n) for p,n in p if n != nullid ]
 
     def children(self):
         # hard for renames