##// END OF EJS Templates
sparse: lock the store when updating requirements config...
Arseniy Alekseyev -
r49326:b74ee41a stable
parent child Browse files
Show More
@@ -12,6 +12,7 b' import errno'
12 12 import os
13 13 import shutil
14 14 import stat
15 import weakref
15 16
16 17 from .i18n import _
17 18 from .node import (
@@ -677,7 +678,7 b' def clone('
677 678 srcpeer = source.peer() # in case we were called with a localrepo
678 679 branches = (None, branch or [])
679 680 origsource = source = srcpeer.url()
680 srclock = destlock = cleandir = None
681 srclock = destlock = destwlock = cleandir = None
681 682 destpeer = None
682 683 try:
683 684 revs, checkout = addbranchrevs(srcpeer, srcpeer, branches, revs)
@@ -865,6 +866,8 b' def clone('
865 866 requirements=dest_reqs,
866 867 )
867 868 destrepo = localrepo.makelocalrepository(ui, destrootpath)
869
870 destwlock = destrepo.wlock()
868 871 destlock = destrepo.lock()
869 872 from . import streamclone # avoid cycle
870 873
@@ -873,6 +876,18 b' def clone('
873 876 # we need to re-init the repo after manually copying the data
874 877 # into it
875 878 destpeer = peer(srcrepo, peeropts, dest)
879
880 # make the peer aware that is it already locked
881 #
882 # important:
883 #
884 # We still need to release that lock at the end of the function
885 destpeer.local()._lockref = weakref.ref(destlock)
886 destpeer.local()._wlockref = weakref.ref(destwlock)
887 # dirstate also needs to be copied because `_wlockref` has a reference
888 # to it: this dirstate is saved to disk when the wlock is released
889 destpeer.local().dirstate = destrepo.dirstate
890
876 891 srcrepo.hook(
877 892 b'outgoing', source=b'clone', node=srcrepo.nodeconstants.nullhex
878 893 )
@@ -1040,6 +1055,8 b' def clone('
1040 1055 bookmarks.activate(destrepo, update)
1041 1056 if destlock is not None:
1042 1057 release(destlock)
1058 if destwlock is not None:
1059 release(destlock)
1043 1060 # here is a tiny windows were someone could end up writing the
1044 1061 # repository before the cache are sure to be warm. This is "fine"
1045 1062 # as the only "bad" outcome would be some slowness. That potential
@@ -1047,7 +1064,7 b' def clone('
1047 1064 with destrepo.lock():
1048 1065 destrepo.updatecaches(caches=repositorymod.CACHES_POST_CLONE)
1049 1066 finally:
1050 release(srclock, destlock)
1067 release(srclock, destlock, destwlock)
1051 1068 if cleandir is not None:
1052 1069 shutil.rmtree(cleandir, True)
1053 1070 if srcpeer is not None:
@@ -718,7 +718,7 b' def updateconfig('
718 718
719 719 The new config is written out and a working directory refresh is performed.
720 720 """
721 with repo.wlock(), repo.dirstate.parentchange():
721 with repo.wlock(), repo.lock(), repo.dirstate.parentchange():
722 722 raw = repo.vfs.tryread(b'sparse')
723 723 oldinclude, oldexclude, oldprofiles = parseconfig(
724 724 repo.ui, raw, b'sparse'
@@ -16,10 +16,8 b' Same with share-safe'
16 16 $ echo x > hide
17 17 $ hg ci -Aqm 'initial'
18 18
19 Verify basic --include
19 Regression test: checks that this command correctly locks the store
20 before updating the store [requirements] config.
20 21
21 22 $ hg up -q 0
22 23 $ hg debugsparse --include 'hide'
23 devel-warn: write with no lock: "requires" at: *mercurial/scmutil.py:1558 (writerequires) (glob)
24
25 TODO: bug in sparse when used together with safe-share^
General Comments 0
You need to be logged in to leave comments. Login now