##// END OF EJS Templates
share: introduce config option to store requires in .hg/store...
Pulkit Goyal -
r46055:d252f51a default
parent child Browse files
Show More
@@ -0,0 +1,69 b''
1 setup
2
3 $ cat >> $HGRCPATH <<EOF
4 > [extensions]
5 > share =
6 > [format]
7 > exp-share-safe = True
8 > EOF
9
10 prepare source repo
11
12 $ hg init source
13 $ cd source
14 $ cat .hg/requires
15 exp-sharesafe
16 $ cat .hg/store/requires
17 dotencode
18 fncache
19 generaldelta
20 revlogv1
21 sparserevlog
22 store
23 $ hg debugrequirements
24 dotencode
25 exp-sharesafe
26 fncache
27 generaldelta
28 revlogv1
29 sparserevlog
30 store
31
32 $ echo a > a
33 $ hg ci -Aqm "added a"
34 $ echo b > b
35 $ hg ci -Aqm "added b"
36 $ cd ..
37
38 Create a shared repo and check the requirements are shared and read correctly
39 $ hg share source shared1
40 updating working directory
41 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
42 $ cd shared1
43 $ cat .hg/requires
44 exp-sharesafe
45 shared
46
47 $ hg debugrequirements -R ../source
48 dotencode
49 exp-sharesafe
50 fncache
51 generaldelta
52 revlogv1
53 sparserevlog
54 store
55
56 $ hg debugrequirements
57 dotencode
58 exp-sharesafe
59 fncache
60 generaldelta
61 revlogv1
62 shared
63 sparserevlog
64 store
65
66 $ echo c > c
67 $ hg ci -Aqm "added c"
68
69 $ hg unshare
@@ -784,6 +784,9 b' coreconfigitem('
784 b'format', b'exp-use-side-data', default=False, experimental=True,
784 b'format', b'exp-use-side-data', default=False, experimental=True,
785 )
785 )
786 coreconfigitem(
786 coreconfigitem(
787 b'format', b'exp-share-safe', default=False, experimental=True,
788 )
789 coreconfigitem(
787 b'format', b'internal-phase', default=False, experimental=True,
790 b'format', b'internal-phase', default=False, experimental=True,
788 )
791 )
789 coreconfigitem(
792 coreconfigitem(
@@ -545,6 +545,26 b' def makelocalrepository(baseui, path, in'
545 raise error.RepoError(_(b'repository %s not found') % path)
545 raise error.RepoError(_(b'repository %s not found') % path)
546
546
547 requirements = _readrequires(hgvfs, True)
547 requirements = _readrequires(hgvfs, True)
548 shared = (
549 requirementsmod.SHARED_REQUIREMENT in requirements
550 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
551 )
552 if shared:
553 sharedvfs = _getsharedvfs(hgvfs, requirements)
554
555 # if .hg/requires contains the sharesafe requirement, it means
556 # there exists a `.hg/store/requires` too and we should read it
557 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
558 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
559 # is not present, refer checkrequirementscompat() for that
560 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
561 if shared:
562 # This is a shared repo
563 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
564 else:
565 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
566
567 requirements |= _readrequires(storevfs, False)
548
568
549 # The .hg/hgrc file may load extensions or contain config options
569 # The .hg/hgrc file may load extensions or contain config options
550 # that influence repository construction. Attempt to load it and
570 # that influence repository construction. Attempt to load it and
@@ -587,12 +607,7 b' def makelocalrepository(baseui, path, in'
587 # accessed is determined by various requirements. If `shared` or
607 # accessed is determined by various requirements. If `shared` or
588 # `relshared` requirements are present, this indicates current repository
608 # `relshared` requirements are present, this indicates current repository
589 # is a share and store exists in path mentioned in `.hg/sharedpath`
609 # is a share and store exists in path mentioned in `.hg/sharedpath`
590 shared = (
591 requirementsmod.SHARED_REQUIREMENT in requirements
592 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
593 )
594 if shared:
610 if shared:
595 sharedvfs = _getsharedvfs(hgvfs, requirements)
596 storebasepath = sharedvfs.base
611 storebasepath = sharedvfs.base
597 cachepath = sharedvfs.join(b'cache')
612 cachepath = sharedvfs.join(b'cache')
598 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
613 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
@@ -1048,6 +1063,7 b' class localrepository(object):'
1048 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1063 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1049 requirementsmod.NODEMAP_REQUIREMENT,
1064 requirementsmod.NODEMAP_REQUIREMENT,
1050 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1065 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1066 requirementsmod.SHARESAFE_REQUIREMENT,
1051 }
1067 }
1052 _basesupported = supportedformats | {
1068 _basesupported = supportedformats | {
1053 b'store',
1069 b'store',
@@ -3329,6 +3345,11 b' def newreporequirements(ui, createopts):'
3329 if ui.configbool(b'format', b'use-persistent-nodemap'):
3345 if ui.configbool(b'format', b'use-persistent-nodemap'):
3330 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3346 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3331
3347
3348 # if share-safe is enabled, let's create the new repository with the new
3349 # requirement
3350 if ui.configbool(b'format', b'exp-share-safe'):
3351 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3352
3332 return requirements
3353 return requirements
3333
3354
3334
3355
@@ -3362,6 +3383,16 b' def checkrequirementscompat(ui, requirem'
3362 )
3383 )
3363 )
3384 )
3364
3385
3386 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3387 ui.warn(
3388 _(
3389 b"ignoring enabled 'format.exp-share-safe' config because "
3390 b"it is incompatible with disabled 'format.usestore'"
3391 b" config\n"
3392 )
3393 )
3394 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3395
3365 return dropped
3396 return dropped
3366
3397
3367
3398
@@ -3486,7 +3517,18 b' def createrepository(ui, path, createopt'
3486 b'layout',
3517 b'layout',
3487 )
3518 )
3488
3519
3489 scmutil.writerequires(hgvfs, requirements)
3520 # Filter the requirements into working copy and store ones
3521 wcreq, storereq = scmutil.filterrequirements(requirements)
3522 # write working copy ones
3523 scmutil.writerequires(hgvfs, wcreq)
3524 # If there are store requirements and the current repository
3525 # is not a shared one, write stored requirements
3526 # For new shared repository, we don't need to write the store
3527 # requirements as they are already present in store requires
3528 if storereq and b'sharedrepo' not in createopts:
3529 scmutil.writerequires(hgvfs, wcreq)
3530 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3531 scmutil.writerequires(storevfs, storereq)
3490
3532
3491 # Write out file telling readers where to find the shared store.
3533 # Write out file telling readers where to find the shared store.
3492 if b'sharedrepo' in createopts:
3534 if b'sharedrepo' in createopts:
@@ -52,6 +52,11 b" SHARED_REQUIREMENT = b'shared'"
52 # relative to the current repository root path
52 # relative to the current repository root path
53 RELATIVE_SHARED_REQUIREMENT = b'relshared'
53 RELATIVE_SHARED_REQUIREMENT = b'relshared'
54
54
55 # A repository with share implemented safely. The repository has different
56 # store and working copy requirements i.e. both `.hg/requires` and
57 # `.hg/store/requires` are present.
58 SHARESAFE_REQUIREMENT = b'exp-sharesafe'
59
55 # List of requirements which are working directory specific
60 # List of requirements which are working directory specific
56 # These requirements cannot be shared between repositories if they
61 # These requirements cannot be shared between repositories if they
57 # share the same store
62 # share the same store
@@ -60,8 +65,11 b" RELATIVE_SHARED_REQUIREMENT = b'relshare"
60 # * SHARED_REQUIREMENT and RELATIVE_SHARED_REQUIREMENT are requirements which
65 # * SHARED_REQUIREMENT and RELATIVE_SHARED_REQUIREMENT are requirements which
61 # represents that the current working copy/repository shares store of another
66 # represents that the current working copy/repository shares store of another
62 # repo. Hence both of them should be stored in working copy
67 # repo. Hence both of them should be stored in working copy
68 # * SHARESAFE_REQUIREMENT needs to be stored in working dir to mark that rest of
69 # the requirements are stored in store's requires
63 WORKING_DIR_REQUIREMENTS = {
70 WORKING_DIR_REQUIREMENTS = {
64 SPARSE_REQUIREMENT,
71 SPARSE_REQUIREMENT,
65 SHARED_REQUIREMENT,
72 SHARED_REQUIREMENT,
66 RELATIVE_SHARED_REQUIREMENT,
73 RELATIVE_SHARED_REQUIREMENT,
74 SHARESAFE_REQUIREMENT,
67 }
75 }
@@ -1479,7 +1479,7 b' def filterrequirements(requirements):'
1479
1479
1480 Returns (wcreq, storereq)
1480 Returns (wcreq, storereq)
1481 """
1481 """
1482 if False:
1482 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
1483 wc, store = set(), set()
1483 wc, store = set(), set()
1484 for r in requirements:
1484 for r in requirements:
1485 if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
1485 if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
@@ -384,6 +384,7 b' def _calcmode(vfs):'
384 b'00changelog.i',
384 b'00changelog.i',
385 b'phaseroots',
385 b'phaseroots',
386 b'obsstore',
386 b'obsstore',
387 b'requires',
387 ]
388 ]
388
389
389
390
@@ -455,7 +456,7 b' class basicstore(object):'
455 yield x
456 yield x
456
457
457 def copylist(self):
458 def copylist(self):
458 return [b'requires'] + _data
459 return _data
459
460
460 def write(self, tr):
461 def write(self, tr):
461 pass
462 pass
@@ -704,6 +705,7 b' class fncachestore(basicstore):'
704 b'00manifest.i',
705 b'00manifest.i',
705 b'00changelog.d',
706 b'00changelog.d',
706 b'00changelog.i',
707 b'00changelog.i',
708 b'requires',
707 )
709 )
708 return [b'requires', b'00changelog.i'] + [b'store/' + f for f in d]
710 return [b'requires', b'00changelog.i'] + [b'store/' + f for f in d]
709
711
@@ -1,3 +1,10 b''
1 #testcases safe normal
2
3 #if safe
4 $ echo "[format]" >> $HGRCPATH
5 $ echo "exp-share-safe = True" >> $HGRCPATH
6 #endif
7
1 Journal extension test: tests the share extension support
8 Journal extension test: tests the share extension support
2
9
3 $ cat >> testmocks.py << EOF
10 $ cat >> testmocks.py << EOF
@@ -1,4 +1,10 b''
1 #testcases flat tree
1 #testcases flat tree
2 #testcases safe normal
3
4 #if safe
5 $ echo "[format]" >> $HGRCPATH
6 $ echo "exp-share-safe = True" >> $HGRCPATH
7 #endif
2
8
3 $ . "$TESTDIR/narrow-library.sh"
9 $ . "$TESTDIR/narrow-library.sh"
4
10
@@ -1,5 +1,12 b''
1 #require no-windows
1 #require no-windows
2
2
3 #testcases safe normal
4
5 #if safe
6 $ echo "[format]" >> $HGRCPATH
7 $ echo "exp-share-safe = True" >> $HGRCPATH
8 #endif
9
3 $ . "$TESTDIR/remotefilelog-library.sh"
10 $ . "$TESTDIR/remotefilelog-library.sh"
4
11
5 $ cat >> $HGRCPATH <<EOF
12 $ cat >> $HGRCPATH <<EOF
@@ -1,4 +1,10 b''
1 #testcases vfs svfs
1 #testcases vfs svfs
2 #testcases safe normal
3
4 #if safe
5 $ echo "[format]" >> $HGRCPATH
6 $ echo "exp-share-safe = True" >> $HGRCPATH
7 #endif
2
8
3 $ echo "[extensions]" >> $HGRCPATH
9 $ echo "[extensions]" >> $HGRCPATH
4 $ echo "share = " >> $HGRCPATH
10 $ echo "share = " >> $HGRCPATH
@@ -284,3 +290,4 b' Test that if store is disabled, we drop '
284
290
285 $ hg init brokenrepo --config format.bookmarks-in-store=True --config format.usestore=false
291 $ hg init brokenrepo --config format.bookmarks-in-store=True --config format.usestore=false
286 ignoring enabled 'format.bookmarks-in-store' config beacuse it is incompatible with disabled 'format.usestore' config
292 ignoring enabled 'format.bookmarks-in-store' config beacuse it is incompatible with disabled 'format.usestore' config
293 ignoring enabled 'format.exp-share-safe' config because it is incompatible with disabled 'format.usestore' config (safe !)
@@ -1,3 +1,10 b''
1 #testcases safe normal
2
3 #if safe
4 $ echo "[format]" >> $HGRCPATH
5 $ echo "exp-share-safe = True" >> $HGRCPATH
6 #endif
7
1 $ echo "[extensions]" >> $HGRCPATH
8 $ echo "[extensions]" >> $HGRCPATH
2 $ echo "share = " >> $HGRCPATH
9 $ echo "share = " >> $HGRCPATH
3
10
@@ -255,6 +262,7 b' Explicitly kill daemons to let the test '
255 Test sharing a repository which was created with store requirement disable
262 Test sharing a repository which was created with store requirement disable
256
263
257 $ hg init nostore --config format.usestore=false
264 $ hg init nostore --config format.usestore=false
265 ignoring enabled 'format.exp-share-safe' config because it is incompatible with disabled 'format.usestore' config (safe !)
258 $ hg share nostore sharednostore
266 $ hg share nostore sharednostore
259 abort: cannot create shared repository as source was created with 'format.usestore' config disabled
267 abort: cannot create shared repository as source was created with 'format.usestore' config disabled
260 [255]
268 [255]
General Comments 0
You need to be logged in to leave comments. Login now