Patchwork [2,of,8,RFC] workingfilectx: add remove and write methods

login
register
mail settings
Submitter Sean Farley
Date Aug. 7, 2014, 7:52 p.m.
Message ID <50a462c913c3796a9fd4.1407441129@laptop.att.net>
Download mbox | patch
Permalink /patch/5318/
State Accepted
Headers show

Comments

Sean Farley - Aug. 7, 2014, 7:52 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1404327661 18000
#      Wed Jul 02 14:01:01 2014 -0500
# Node ID 50a462c913c3796a9fd44678b258dc09f7de54f5
# Parent  c19945ae6a620e9965bc6f3b32562ef93f7d14d8
workingfilectx: add remove and write methods

This patch will allow abstracting localrepo.remove / write method to refactor
working directory code.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1554,10 +1554,18 @@  class workingfilectx(committablefilectx)
         """
         # fctx should be a filectx (not a workingfilectx)
         # invert comparison to reuse the same code path
         return fctx.cmp(self)
 
+    def remove(self, ignoremissing=False):
+        """wraps unlink for a repo's working directory"""
+        util.unlinkpath(self._repo.wjoin(self._path), ignoremissing)
+
+    def write(self, data, flags):
+        """wraps repo.wwrite"""
+        self._repo.wwrite(self._path, data, flags)
+
 class memctx(committablectx):
     """Use memctx to perform in-memory commits via localrepo.commitctx().
 
     Revision information is supplied at initialization time while
     related files data and is made available through a callback