Patchwork [2,of,5] shared: take wlock for writting the 'shared' file

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 8, 2016, 10:12 p.m.
Message ID <8eefbe50ec3f68844a02.1470694357@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/16215/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 8, 2016, 10:12 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1470582647 -7200
#      Sun Aug 07 17:10:47 2016 +0200
# Node ID 8eefbe50ec3f68844a02dce82c6461a9241c1138
# Parent  ef6aa171bb9b23b5ab192561073e476cba23b20e
# EXP-Topic vfs.ward
shared: take wlock for writting the 'shared' file

I do not see a reason why this should not be covered by the wlock.

Patch

diff -r ef6aa171bb9b -r 8eefbe50ec3f mercurial/hg.py
--- a/mercurial/hg.py	Sun Aug 07 17:00:45 2016 +0200
+++ b/mercurial/hg.py	Sun Aug 07 17:10:47 2016 +0200
@@ -259,10 +259,11 @@  def postshare(sourcerepo, destrepo, book
         fp.write("default = %s\n" % default)
         fp.close()
 
-    if bookmarks:
-        fp = destrepo.vfs('shared', 'w')
-        fp.write(sharedbookmarks + '\n')
-        fp.close()
+    with destrepo.wlock():
+        if bookmarks:
+            fp = destrepo.vfs('shared', 'w')
+            fp.write(sharedbookmarks + '\n')
+            fp.close()
 
 def _postshareupdate(repo, update, checkout=None):
     """Maybe perform a working directory update after a shared repo is created.