Show More
@@ -12,6 +12,7 b' import errno' | |||||
12 | import os |
|
12 | import os | |
13 | import shutil |
|
13 | import shutil | |
14 | import stat |
|
14 | import stat | |
|
15 | import weakref | |||
15 |
|
16 | |||
16 | from .i18n import _ |
|
17 | from .i18n import _ | |
17 | from .node import ( |
|
18 | from .node import ( | |
@@ -677,7 +678,7 b' def clone(' | |||||
677 | srcpeer = source.peer() # in case we were called with a localrepo |
|
678 | srcpeer = source.peer() # in case we were called with a localrepo | |
678 | branches = (None, branch or []) |
|
679 | branches = (None, branch or []) | |
679 | origsource = source = srcpeer.url() |
|
680 | origsource = source = srcpeer.url() | |
680 | srclock = destlock = cleandir = None |
|
681 | srclock = destlock = destwlock = cleandir = None | |
681 | destpeer = None |
|
682 | destpeer = None | |
682 | try: |
|
683 | try: | |
683 | revs, checkout = addbranchrevs(srcpeer, srcpeer, branches, revs) |
|
684 | revs, checkout = addbranchrevs(srcpeer, srcpeer, branches, revs) | |
@@ -865,6 +866,8 b' def clone(' | |||||
865 | requirements=dest_reqs, |
|
866 | requirements=dest_reqs, | |
866 | ) |
|
867 | ) | |
867 | destrepo = localrepo.makelocalrepository(ui, destrootpath) |
|
868 | destrepo = localrepo.makelocalrepository(ui, destrootpath) | |
|
869 | ||||
|
870 | destwlock = destrepo.wlock() | |||
868 | destlock = destrepo.lock() |
|
871 | destlock = destrepo.lock() | |
869 | from . import streamclone # avoid cycle |
|
872 | from . import streamclone # avoid cycle | |
870 |
|
873 | |||
@@ -873,6 +876,18 b' def clone(' | |||||
873 | # we need to re-init the repo after manually copying the data |
|
876 | # we need to re-init the repo after manually copying the data | |
874 | # into it |
|
877 | # into it | |
875 | destpeer = peer(srcrepo, peeropts, dest) |
|
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 | srcrepo.hook( |
|
891 | srcrepo.hook( | |
877 | b'outgoing', source=b'clone', node=srcrepo.nodeconstants.nullhex |
|
892 | b'outgoing', source=b'clone', node=srcrepo.nodeconstants.nullhex | |
878 | ) |
|
893 | ) | |
@@ -1040,6 +1055,8 b' def clone(' | |||||
1040 | bookmarks.activate(destrepo, update) |
|
1055 | bookmarks.activate(destrepo, update) | |
1041 | if destlock is not None: |
|
1056 | if destlock is not None: | |
1042 | release(destlock) |
|
1057 | release(destlock) | |
|
1058 | if destwlock is not None: | |||
|
1059 | release(destlock) | |||
1043 | # here is a tiny windows were someone could end up writing the |
|
1060 | # here is a tiny windows were someone could end up writing the | |
1044 | # repository before the cache are sure to be warm. This is "fine" |
|
1061 | # repository before the cache are sure to be warm. This is "fine" | |
1045 | # as the only "bad" outcome would be some slowness. That potential |
|
1062 | # as the only "bad" outcome would be some slowness. That potential | |
@@ -1047,7 +1064,7 b' def clone(' | |||||
1047 | with destrepo.lock(): |
|
1064 | with destrepo.lock(): | |
1048 | destrepo.updatecaches(caches=repositorymod.CACHES_POST_CLONE) |
|
1065 | destrepo.updatecaches(caches=repositorymod.CACHES_POST_CLONE) | |
1049 | finally: |
|
1066 | finally: | |
1050 | release(srclock, destlock) |
|
1067 | release(srclock, destlock, destwlock) | |
1051 | if cleandir is not None: |
|
1068 | if cleandir is not None: | |
1052 | shutil.rmtree(cleandir, True) |
|
1069 | shutil.rmtree(cleandir, True) | |
1053 | if srcpeer is not None: |
|
1070 | if srcpeer is not None: |
@@ -718,7 +718,7 b' def updateconfig(' | |||||
718 |
|
718 | |||
719 | The new config is written out and a working directory refresh is performed. |
|
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 | raw = repo.vfs.tryread(b'sparse') |
|
722 | raw = repo.vfs.tryread(b'sparse') | |
723 | oldinclude, oldexclude, oldprofiles = parseconfig( |
|
723 | oldinclude, oldexclude, oldprofiles = parseconfig( | |
724 | repo.ui, raw, b'sparse' |
|
724 | repo.ui, raw, b'sparse' |
@@ -16,10 +16,8 b' Same with share-safe' | |||||
16 | $ echo x > hide |
|
16 | $ echo x > hide | |
17 | $ hg ci -Aqm 'initial' |
|
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 | $ hg up -q 0 |
|
22 | $ hg up -q 0 | |
22 | $ hg debugsparse --include 'hide' |
|
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