##// END OF EJS Templates
branchcache-v3: introduce a v3 format...
marmoute -
r52413:fe8347b9 default
parent child Browse files
Show More
@@ -728,13 +728,25 b' class _LocalBranchCache(_BaseBranchCache'
728
728
729
729
730 def branch_cache_from_file(repo) -> Optional[_LocalBranchCache]:
730 def branch_cache_from_file(repo) -> Optional[_LocalBranchCache]:
731 """Build a branch cache from on-disk data if possible"""
731 """Build a branch cache from on-disk data if possible
732 return BranchCacheV2.fromfile(repo)
732
733 Return a branch cache of the right format depending of the repository.
734 """
735 if repo.ui.configbool(b"experimental", b"branch-cache-v3"):
736 return BranchCacheV3.fromfile(repo)
737 else:
738 return BranchCacheV2.fromfile(repo)
733
739
734
740
735 def new_branch_cache(repo, *args, **kwargs):
741 def new_branch_cache(repo, *args, **kwargs):
736 """Build a new branch cache from argument"""
742 """Build a new branch cache from argument
737 return BranchCacheV2(repo, *args, **kwargs)
743
744 Return a branch cache of the right format depending of the repository.
745 """
746 if repo.ui.configbool(b"experimental", b"branch-cache-v3"):
747 return BranchCacheV3(repo, *args, **kwargs)
748 else:
749 return BranchCacheV2(repo, *args, **kwargs)
738
750
739
751
740 class BranchCacheV2(_LocalBranchCache):
752 class BranchCacheV2(_LocalBranchCache):
@@ -759,6 +771,30 b' class BranchCacheV2(_LocalBranchCache):'
759 _base_filename = b"branch2"
771 _base_filename = b"branch2"
760
772
761
773
774 class BranchCacheV3(_LocalBranchCache):
775 """a branch cache using version 3 of the format on disk
776
777 This version is still EXPERIMENTAL and the format is subject to changes.
778
779 The cache is serialized on disk in the following format:
780
781 <tip hex node> <tip rev number> [optional filtered repo hex hash]
782 <branch head hex node> <open/closed state> <branch name>
783 <branch head hex node> <open/closed state> <branch name>
784 ...
785
786 The first line is used to check if the cache is still valid. If the
787 branch cache is for a filtered repo view, an optional third hash is
788 included that hashes the hashes of all filtered and obsolete revisions.
789
790 The open/closed state is represented by a single letter 'o' or 'c'.
791 This field can be used to avoid changelog reads when determining if a
792 branch head closes a branch or not.
793 """
794
795 _base_filename = b"branch3"
796
797
762 class remotebranchcache(_BaseBranchCache):
798 class remotebranchcache(_BaseBranchCache):
763 """Branchmap info for a remote connection, should not write locally"""
799 """Branchmap info for a remote connection, should not write locally"""
764
800
@@ -14,6 +14,8 b' def cachetocopy(srcrepo):'
14 # ones. Therefore copy all branch caches over.
14 # ones. Therefore copy all branch caches over.
15 cachefiles = [b'branch2']
15 cachefiles = [b'branch2']
16 cachefiles += [b'branch2-%s' % f for f in repoview.filtertable]
16 cachefiles += [b'branch2-%s' % f for f in repoview.filtertable]
17 cachefiles += [b'branch3']
18 cachefiles += [b'branch3-%s' % f for f in repoview.filtertable]
17 cachefiles += [b'rbc-names-v1', b'rbc-revs-v1']
19 cachefiles += [b'rbc-names-v1', b'rbc-revs-v1']
18 cachefiles += [b'tags2']
20 cachefiles += [b'tags2']
19 cachefiles += [b'tags2-%s' % f for f in repoview.filtertable]
21 cachefiles += [b'tags2-%s' % f for f in repoview.filtertable]
@@ -719,6 +719,12 b' section = "experimental"'
719 name = "auto-publish"
719 name = "auto-publish"
720 default = "publish"
720 default = "publish"
721
721
722
723 [[items]]
724 section = "experimental"
725 name = "branch-cache-v3"
726 default = false
727
722 [[items]]
728 [[items]]
723 section = "experimental"
729 section = "experimental"
724 name = "bundle-phases"
730 name = "bundle-phases"
@@ -1,4 +1,4 b''
1 #testcases mmap nommap
1 #testcases mmap nommap v3
2
2
3 #if mmap
3 #if mmap
4 $ cat <<EOF >> $HGRCPATH
4 $ cat <<EOF >> $HGRCPATH
@@ -7,6 +7,18 b''
7 > EOF
7 > EOF
8 #endif
8 #endif
9
9
10 #if v3
11 $ cat <<EOF >> $HGRCPATH
12 > [experimental]
13 > branch-cache-v3=yes
14 > EOF
15 #else
16 $ cat <<EOF >> $HGRCPATH
17 > [experimental]
18 > branch-cache-v3=no
19 > EOF
20 #endif
21
10 $ hg init a
22 $ hg init a
11 $ cd a
23 $ cd a
12
24
@@ -1322,9 +1334,15 b' Unbundling revision should warm the serv'
1322 new changesets 2ab8003a1750:99ba08759bc7
1334 new changesets 2ab8003a1750:99ba08759bc7
1323 updating to branch A
1335 updating to branch A
1324 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1336 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1337 #if v3
1338 $ cat branchmap-update-01/.hg/cache/branch3-base
1339 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1340 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1341 #else
1325 $ cat branchmap-update-01/.hg/cache/branch2-base
1342 $ cat branchmap-update-01/.hg/cache/branch2-base
1326 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1343 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1327 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1344 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1345 #endif
1328 $ hg -R branchmap-update-01 unbundle bundle.hg
1346 $ hg -R branchmap-update-01 unbundle bundle.hg
1329 adding changesets
1347 adding changesets
1330 adding manifests
1348 adding manifests
@@ -1332,9 +1350,15 b' Unbundling revision should warm the serv'
1332 added 2 changesets with 0 changes to 0 files
1350 added 2 changesets with 0 changes to 0 files
1333 new changesets a3b807b3ff0b:71ca9a6d524e (2 drafts)
1351 new changesets a3b807b3ff0b:71ca9a6d524e (2 drafts)
1334 (run 'hg update' to get a working copy)
1352 (run 'hg update' to get a working copy)
1353 #if v3
1354 $ cat branchmap-update-01/.hg/cache/branch3-served
1355 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3
1356 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 o A
1357 #else
1335 $ cat branchmap-update-01/.hg/cache/branch2-served
1358 $ cat branchmap-update-01/.hg/cache/branch2-served
1336 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3
1359 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3
1337 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 o A
1360 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 o A
1361 #endif
1338
1362
1339 aborted Unbundle should not update the on disk cache
1363 aborted Unbundle should not update the on disk cache
1340
1364
@@ -1356,9 +1380,15 b' aborted Unbundle should not update the o'
1356 updating to branch A
1380 updating to branch A
1357 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1381 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1358
1382
1383 #if v3
1384 $ cat branchmap-update-02/.hg/cache/branch3-base
1385 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1386 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1387 #else
1359 $ cat branchmap-update-02/.hg/cache/branch2-base
1388 $ cat branchmap-update-02/.hg/cache/branch2-base
1360 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1389 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1361 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1390 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1391 #endif
1362 $ hg -R branchmap-update-02 unbundle bundle.hg --config "hooks.pretxnclose=python:$TESTTMP/simplehook.py:hook"
1392 $ hg -R branchmap-update-02 unbundle bundle.hg --config "hooks.pretxnclose=python:$TESTTMP/simplehook.py:hook"
1363 adding changesets
1393 adding changesets
1364 adding manifests
1394 adding manifests
@@ -1367,6 +1397,12 b' aborted Unbundle should not update the o'
1367 rollback completed
1397 rollback completed
1368 abort: pretxnclose hook failed
1398 abort: pretxnclose hook failed
1369 [40]
1399 [40]
1400 #if v3
1401 $ cat branchmap-update-02/.hg/cache/branch3-base
1402 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1403 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1404 #else
1370 $ cat branchmap-update-02/.hg/cache/branch2-base
1405 $ cat branchmap-update-02/.hg/cache/branch2-base
1371 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1406 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1372 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1407 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1408 #endif
General Comments 0
You need to be logged in to leave comments. Login now