write: add the possibility to pass keyword argument from batchget to vfs
authorBoris Feld <boris.feld@octobus.net>
Wed, 17 Jan 2018 16:52:13 +0100
changeset 35725 2a7e777c9eed
parent 35724 853bf7d90804
child 35726 45b678bf3a78
write: add the possibility to pass keyword argument from batchget to vfs We are going to pass atomictemp keyword argument from merge.baychget to vfs.__call__. Update all the frames to accept **kwargs and pass it to the next function. Differential Revision: https://phab.mercurial-scm.org/D1881
mercurial/context.py
mercurial/localrepo.py
mercurial/vfs.py
--- a/mercurial/context.py	Thu Jan 18 12:55:19 2018 +0100
+++ b/mercurial/context.py	Wed Jan 17 16:52:13 2018 +0100
@@ -1962,10 +1962,11 @@
         """wraps unlink for a repo's working directory"""
         self._repo.wvfs.unlinkpath(self._path, ignoremissing=ignoremissing)
 
-    def write(self, data, flags, backgroundclose=False):
+    def write(self, data, flags, backgroundclose=False, **kwargs):
         """wraps repo.wwrite"""
         self._repo.wwrite(self._path, data, flags,
-                          backgroundclose=backgroundclose)
+                          backgroundclose=backgroundclose,
+                          **kwargs)
 
     def markcopied(self, src):
         """marks this file a copy of `src`"""
@@ -2149,7 +2150,7 @@
                               % (path, path, self.p1(), len(matches),
                                  ', '.join(matches.keys())))
 
-    def write(self, path, data, flags=''):
+    def write(self, path, data, flags='', **kwargs):
         if data is None:
             raise error.ProgrammingError("data must be non-None")
         self._auditconflicts(path)
@@ -2327,8 +2328,8 @@
     def setflags(self, islink, isexec):
         return self._parent.setflags(self._path, islink, isexec)
 
-    def write(self, data, flags, backgroundclose=False):
-        return self._parent.write(self._path, data, flags)
+    def write(self, data, flags, backgroundclose=False, **kwargs):
+        return self._parent.write(self._path, data, flags, **kwargs)
 
     def remove(self, ignoremissing=False):
         return self._parent.remove(self._path)
@@ -2574,7 +2575,7 @@
         # need to figure out what to do here
         del self._changectx[self._path]
 
-    def write(self, data, flags):
+    def write(self, data, flags, **kwargs):
         """wraps repo.wwrite"""
         self._data = data
 
@@ -2783,7 +2784,7 @@
     def remove(self):
         util.unlink(self._path)
 
-    def write(self, data, flags):
+    def write(self, data, flags, **kwargs):
         assert not flags
         with open(self._path, "w") as f:
             f.write(data)
--- a/mercurial/localrepo.py	Thu Jan 18 12:55:19 2018 +0100
+++ b/mercurial/localrepo.py	Wed Jan 17 16:52:13 2018 +0100
@@ -1099,7 +1099,7 @@
             data = self.wvfs.read(filename)
         return self._filter(self._encodefilterpats, filename, data)
 
-    def wwrite(self, filename, data, flags, backgroundclose=False):
+    def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
         """write ``data`` into ``filename`` in the working directory
 
         This returns length of written (maybe decoded) data.
@@ -1108,7 +1108,8 @@
         if 'l' in flags:
             self.wvfs.symlink(data, filename)
         else:
-            self.wvfs.write(filename, data, backgroundclose=backgroundclose)
+            self.wvfs.write(filename, data, backgroundclose=backgroundclose,
+                            **kwargs)
             if 'x' in flags:
                 self.wvfs.setflags(filename, False, True)
         return len(data)
--- a/mercurial/vfs.py	Thu Jan 18 12:55:19 2018 +0100
+++ b/mercurial/vfs.py	Wed Jan 17 16:52:13 2018 +0100
@@ -83,8 +83,8 @@
         with self(path, mode=mode) as fp:
             return fp.readlines()
 
-    def write(self, path, data, backgroundclose=False):
-        with self(path, 'wb', backgroundclose=backgroundclose) as fp:
+    def write(self, path, data, backgroundclose=False, **kwargs):
+        with self(path, 'wb', backgroundclose=backgroundclose, **kwargs) as fp:
             return fp.write(data)
 
     def writelines(self, path, data, mode='wb', notindexed=False):