Patchwork [47,of,48,RFC] commitablefilectx: move parents from workingfilectx

login
register
mail settings
Submitter Sean Farley
Date Sept. 5, 2013, 8:07 p.m.
Message ID <2605b1bde276bfc54a27.1378411661@laptop.local>
Download mbox | patch
Permalink /patch/2386/
State Accepted
Commit bad0bd99ac9673dd9960cf5675c3b7c318eff5a9
Headers show

Comments

Sean Farley - Sept. 5, 2013, 8:07 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1376592153 18000
#      Thu Aug 15 13:42:33 2013 -0500
# Node ID 2605b1bde276bfc54a27158b288a2deccd14c53c
# Parent  2d2d9d92a1d104410d6ba7d29517d7d6f311eecd
commitablefilectx: move parents from workingfilectx

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1203,28 +1203,10 @@ 
             self._changectx = ctx
 
     def __nonzero__(self):
         return True
 
-class workingfilectx(commitablefilectx):
-    """A workingfilectx object makes access to data related to a particular
-       file in the working directory convenient."""
-    def __init__(self, repo, path, filelog=None, workingctx=None):
-        super(workingfilectx, self).__init__(repo, path, filelog, workingctx)
-
-    @propertycache
-    def _changectx(self):
-        return workingctx(self._repo)
-
-    def data(self):
-        return self._repo.wread(self._path)
-    def renamed(self):
-        rp = self._repo.dirstate.copied(self._path)
-        if not rp:
-            return None
-        return rp, self._changectx._parents[0]._manifest.get(rp, nullid)
-
     def parents(self):
         '''return parent filectxs, following copies if necessary'''
         def filenode(ctx, path):
             return ctx._manifest.get(path, nullid)
 
@@ -1242,10 +1224,28 @@ 
             pl.append((path, filenode(pc, path), fl))
 
         return [filectx(self._repo, p, fileid=n, filelog=l)
                 for p, n, l in pl if n != nullid]
 
+class workingfilectx(commitablefilectx):
+    """A workingfilectx object makes access to data related to a particular
+       file in the working directory convenient."""
+    def __init__(self, repo, path, filelog=None, workingctx=None):
+        super(workingfilectx, self).__init__(repo, path, filelog, workingctx)
+
+    @propertycache
+    def _changectx(self):
+        return workingctx(self._repo)
+
+    def data(self):
+        return self._repo.wread(self._path)
+    def renamed(self):
+        rp = self._repo.dirstate.copied(self._path)
+        if not rp:
+            return None
+        return rp, self._changectx._parents[0]._manifest.get(rp, nullid)
+
     def children(self):
         return []
 
     def size(self):
         return os.lstat(self._repo.wjoin(self._path)).st_size