[PATCH 3 of 8 RFC] memfilectx: add remove and write methods

Sean Farley sean.michael.farley at gmail.com
Thu Aug 7 14:52:10 CDT 2014


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1406337626 18000
#      Fri Jul 25 20:20:26 2014 -0500
# Node ID 124225c16d40a0c2707e346c67e2a7a332ca0509
# Parent  50a462c913c3796a9fd44678b258dc09f7de54f5
memfilectx: add remove and write methods

Similar to the previous patch for workingfilectx, this patch will allow
abstracting localrepo.remove / write method to refactor working directory code
but instead operate on files in memory.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1682,5 +1682,14 @@ class memfilectx(committablefilectx):
         return len(self.data())
     def flags(self):
         return self._flags
     def renamed(self):
         return self._copied
+
+    def remove(self, ignoremissing=False):
+        """wraps unlink for a repo's working directory"""
+        # need to figure out what to do here
+        del self._changectx[self._path]
+
+    def write(self, data, flags):
+        """wraps repo.wwrite"""
+        self._data = data


More information about the Mercurial-devel mailing list