changeset 35726:45b678bf3a78

atomicupdate: add an experimental option to use atomictemp when updating In some cases Mercurial truncating files when updating causes problems. It can happens when processes are currently reading the file or with big file or on NFS mounts. We add an experimental option to use the atomictemp option of vfs.__call__ in order to avoid the problem. The localrepository.wwrite seems to assume the files are created without the `x` flag; with atomictempfile, the new file might inherit the `x` flag from the destination. We force remove it afterward. This code could be refactored and the flag processing could be moved inside vfs. This patch should be tested with `--extra-config-opt experimental.update.atomic-file=True` as we disabled the option by default. Differential Revision: https://phab.mercurial-scm.org/D1882
author Boris Feld <boris.feld@octobus.net>
date Wed, 17 Jan 2018 17:07:55 +0100
parents 2a7e777c9eed
children 05c70675e5b9
files mercurial/configitems.py mercurial/localrepo.py mercurial/merge.py
diffstat 3 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.py	Wed Jan 17 16:52:13 2018 +0100
+++ b/mercurial/configitems.py	Wed Jan 17 17:07:55 2018 +0100
@@ -568,6 +568,9 @@
 coreconfigitem('experimental', 'treemanifest',
     default=False,
 )
+coreconfigitem('experimental', 'update.atomic-file',
+    default=False,
+)
 coreconfigitem('extensions', '.*',
     default=None,
     generic=True,
--- a/mercurial/localrepo.py	Wed Jan 17 16:52:13 2018 +0100
+++ b/mercurial/localrepo.py	Wed Jan 17 17:07:55 2018 +0100
@@ -1112,6 +1112,8 @@
                             **kwargs)
             if 'x' in flags:
                 self.wvfs.setflags(filename, False, True)
+            else:
+                self.wvfs.setflags(filename, False, False)
         return len(data)
 
     def wwritedata(self, filename, data):
--- a/mercurial/merge.py	Wed Jan 17 16:52:13 2018 +0100
+++ b/mercurial/merge.py	Wed Jan 17 17:07:55 2018 +0100
@@ -1376,7 +1376,9 @@
                 if repo.wvfs.lexists(absf):
                     util.rename(absf, orig)
             wctx[f].clearunknown()
-            wctx[f].write(fctx(f).data(), flags, backgroundclose=True)
+            atomictemp = ui.configbool("experimental", "update.atomic-file")
+            wctx[f].write(fctx(f).data(), flags, backgroundclose=True,
+                          atomictemp=atomictemp)
             if i == 100:
                 yield i, f
                 i = 0