[PATCH 2 of 8 RFC] workingfilectx: add remove and write methods
Sean Farley
sean.michael.farley at gmail.com
Thu Aug 7 14:52:09 CDT 2014
# HG changeset patch
# User Sean Farley <sean.michael.farley at 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.
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
More information about the Mercurial-devel
mailing list