[Request] [+ ] D11250: testing: make sure write_file is "atomic"
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Wed Aug 4 20:42:46 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
marmoute added a comment.
Alphare accepted this revision.
This revision is now accepted and ready to land.
This does not seems to be all of the issue we have with nointerrupt.t ⦠https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/233269
REVISION SUMMARY
This make sure viewer cannot see the new file with partial content.
This was likely the cause of some flakiness in `test-nointerrupt.t`
REPOSITORY
rHG Mercurial
BRANCH
stable
REVISION DETAIL
https://phab.mercurial-scm.org/D11250
AFFECTED FILES
mercurial/testing/__init__.py
CHANGE DETAILS
diff --git a/mercurial/testing/__init__.py b/mercurial/testing/__init__.py
--- a/mercurial/testing/__init__.py
+++ b/mercurial/testing/__init__.py
@@ -33,5 +33,11 @@
def write_file(path, content=b''):
- with open(path, 'wb') as f:
+ if content:
+ write_path = b'%s.tmp' % path
+ else:
+ write_path = path
+ with open(write_path, 'wb') as f:
f.write(content)
+ if path != write_path:
+ os.rename(write_path, path)
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210804/b692db51/attachment.html>
More information about the Mercurial-patches
mailing list