##// END OF EJS Templates
branchcache: explicitly track inheritence "state"...
marmoute -
r52386:82c1a388 default
parent child Browse files
Show More
@@ -4303,8 +4303,16 b' def perfbranchmapupdate(ui, repo, base=('
4303 4303 baserepo = repo.filtered(b'__perf_branchmap_update_base')
4304 4304 targetrepo = repo.filtered(b'__perf_branchmap_update_target')
4305 4305
4306 bcache = repo.branchmap()
4307 copy_method = 'copy'
4308
4306 4309 copy_base_kwargs = copy_base_kwargs = {}
4307 if 'repo' in getargspec(repo.branchmap().copy).args:
4310 if hasattr(bcache, 'copy'):
4311 if 'repo' in getargspec(bcache.copy).args:
4312 copy_base_kwargs = {"repo": baserepo}
4313 copy_target_kwargs = {"repo": targetrepo}
4314 else:
4315 copy_method = 'inherit_for'
4308 4316 copy_base_kwargs = {"repo": baserepo}
4309 4317 copy_target_kwargs = {"repo": targetrepo}
4310 4318
@@ -4316,7 +4324,7 b' def perfbranchmapupdate(ui, repo, base=('
4316 4324 if candidatebm.validfor(baserepo):
4317 4325 filtered = repoview.filterrevs(repo, candidatefilter)
4318 4326 missing = [r for r in allbaserevs if r in filtered]
4319 base = candidatebm.copy(**copy_base_kwargs)
4327 base = getattr(candidatebm, copy_method)(**copy_base_kwargs)
4320 4328 base.update(baserepo, missing)
4321 4329 break
4322 4330 candidatefilter = subsettable.get(candidatefilter)
@@ -4326,7 +4334,7 b' def perfbranchmapupdate(ui, repo, base=('
4326 4334 base.update(baserepo, allbaserevs)
4327 4335
4328 4336 def setup():
4329 x[0] = base.copy(**copy_target_kwargs)
4337 x[0] = getattr(base, copy_method)(**copy_target_kwargs)
4330 4338 if clearcaches:
4331 4339 unfi._revbranchcache = None
4332 4340 clearchangelog(repo)
@@ -85,8 +85,7 b' class BranchMapCache:'
85 85 bcache._filtername,
86 86 repo.filtername,
87 87 )
88 if bcache._dirty:
89 bcache.write(repo)
88 bcache.sync_disk(repo)
90 89
91 90 def updatecache(self, repo):
92 91 """Update the cache for the given filtered view on a repository"""
@@ -109,7 +108,7 b' class BranchMapCache:'
109 108 subsetname = subsettable.get(filtername)
110 109 if subsetname is not None:
111 110 subset = repo.filtered(subsetname)
112 bcache = self[subset].copy(repo)
111 bcache = self[subset].inherit_for(repo)
113 112 extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
114 113 revs.extend(r for r in extrarevs if r <= bcache.tiprev)
115 114 else:
@@ -160,7 +159,7 b' class BranchMapCache:'
160 159 if cache.validfor(rview):
161 160 cache._filtername = candidate
162 161 self._per_filter[candidate] = cache
163 cache._dirty = True
162 cache._state = STATE_DIRTY
164 163 cache.write(rview)
165 164 return
166 165
@@ -173,12 +172,11 b' class BranchMapCache:'
173 172 cache = self._per_filter.get(filtername)
174 173 if cache is None:
175 174 continue
176 if cache._dirty:
177 if filtername is None:
178 repo = unfi
179 else:
180 repo = unfi.filtered(filtername)
181 cache.write(repo)
175 if filtername is None:
176 repo = unfi
177 else:
178 repo = unfi.filtered(filtername)
179 cache.sync_disk(repo)
182 180
183 181
184 182 def _unknownnode(node):
@@ -414,6 +412,11 b' class _BaseBranchCache:'
414 412 return max_rev
415 413
416 414
415 STATE_CLEAN = 1
416 STATE_INHERITED = 2
417 STATE_DIRTY = 3
418
419
417 420 class branchcache(_BaseBranchCache):
418 421 """Branchmap info for a local repo or repoview"""
419 422
@@ -431,6 +434,7 b' class branchcache(_BaseBranchCache):'
431 434 closednodes: Optional[Set[bytes]] = None,
432 435 hasnode: Optional[Callable[[bytes], bool]] = None,
433 436 verify_node: bool = False,
437 inherited: bool = False,
434 438 ) -> None:
435 439 """hasnode is a function which can be used to verify whether changelog
436 440 has a given node or not. If it's not provided, we assume that every node
@@ -442,7 +446,9 b' class branchcache(_BaseBranchCache):'
442 446 self.tipnode = tipnode
443 447 self.tiprev = tiprev
444 448 self.filteredhash = filteredhash
445 self._dirty = False
449 self._state = STATE_CLEAN
450 if inherited:
451 self._state = STATE_INHERITED
446 452
447 453 super().__init__(repo=repo, entries=entries, closed_nodes=closednodes)
448 454 # closednodes is a set of nodes that close their branch. If the branch
@@ -555,7 +561,7 b' class branchcache(_BaseBranchCache):'
555 561 filename = b'%s-%s' % (filename, repo.filtername)
556 562 return filename
557 563
558 def copy(self, repo):
564 def inherit_for(self, repo):
559 565 """return a deep copy of the branchcache object"""
560 566 assert repo.filtername != self._filtername
561 567 other = type(self)(
@@ -569,16 +575,33 b' class branchcache(_BaseBranchCache):'
569 575 filteredhash=self.filteredhash,
570 576 closednodes=set(self._closednodes),
571 577 verify_node=self._verify_node,
578 inherited=True,
572 579 )
573 580 # also copy information about the current verification state
574 581 other._verifiedbranches = set(self._verifiedbranches)
575 582 return other
576 583
584 def sync_disk(self, repo):
585 """synchronise the on disk file with the cache state
586
587 If new value specific to this filter level need to be written, the file
588 will be updated, if the state of the branchcache is inherited from a
589 subset, any stalled on disk file will be deleted.
590
591 That method does nothing if there is nothing to do.
592 """
593 if self._state == STATE_DIRTY:
594 self.write(repo)
595 elif self._state == STATE_INHERITED:
596 filename = self._filename(repo)
597 repo.cachevfs.tryunlink(filename)
598
577 599 def write(self, repo):
578 600 assert self._filtername == repo.filtername, (
579 601 self._filtername,
580 602 repo.filtername,
581 603 )
604 assert self._state == STATE_DIRTY, self._state
582 605 tr = repo.currenttransaction()
583 606 if not getattr(tr, 'finalized', True):
584 607 # Avoid premature writing.
@@ -597,7 +620,7 b' class branchcache(_BaseBranchCache):'
597 620 len(self._entries),
598 621 nodecount,
599 622 )
600 self._dirty = False
623 self._state = STATE_CLEAN
601 624 except (IOError, OSError, error.Abort) as inst:
602 625 # Abort may be raised by read only opener, so log and continue
603 626 repo.ui.debug(
@@ -707,7 +730,7 b' class branchcache(_BaseBranchCache):'
707 730 self.filteredhash = scmutil.filteredhash(
708 731 repo, self.tiprev, needobsolete=True
709 732 )
710 self._dirty = True
733 self._state = STATE_DIRTY
711 734 self.write(repo)
712 735
713 736
@@ -167,7 +167,6 b' Extension disabled for lack of acl.sourc'
167 167 listing keys for "phases"
168 168 checking for updated bookmarks
169 169 listing keys for "bookmarks"
170 invalid branch cache (served): tip differs
171 170 listing keys for "bookmarks"
172 171 3 changesets found
173 172 list of changesets:
@@ -187,7 +186,6 b' Extension disabled for lack of acl.sourc'
187 186 bundle2-input-part: total payload size * (glob)
188 187 bundle2-input-part: "check:updated-heads" supported
189 188 bundle2-input-part: total payload size * (glob)
190 invalid branch cache (served): tip differs
191 189 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
192 190 adding changesets
193 191 add changeset ef1ea85a6374
@@ -237,7 +235,6 b' No [acl.allow]/[acl.deny]'
237 235 listing keys for "phases"
238 236 checking for updated bookmarks
239 237 listing keys for "bookmarks"
240 invalid branch cache (served): tip differs
241 238 listing keys for "bookmarks"
242 239 3 changesets found
243 240 list of changesets:
@@ -257,7 +254,6 b' No [acl.allow]/[acl.deny]'
257 254 bundle2-input-part: total payload size * (glob)
258 255 bundle2-input-part: "check:updated-heads" supported
259 256 bundle2-input-part: total payload size * (glob)
260 invalid branch cache (served): tip differs
261 257 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
262 258 adding changesets
263 259 add changeset ef1ea85a6374
@@ -317,7 +313,6 b' Empty [acl.allow]'
317 313 listing keys for "phases"
318 314 checking for updated bookmarks
319 315 listing keys for "bookmarks"
320 invalid branch cache (served): tip differs
321 316 listing keys for "bookmarks"
322 317 3 changesets found
323 318 list of changesets:
@@ -337,7 +332,6 b' Empty [acl.allow]'
337 332 bundle2-input-part: total payload size * (glob)
338 333 bundle2-input-part: "check:updated-heads" supported
339 334 bundle2-input-part: total payload size * (glob)
340 invalid branch cache (served): tip differs
341 335 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
342 336 adding changesets
343 337 add changeset ef1ea85a6374
@@ -388,7 +382,6 b' fred is allowed inside foo/'
388 382 listing keys for "phases"
389 383 checking for updated bookmarks
390 384 listing keys for "bookmarks"
391 invalid branch cache (served): tip differs
392 385 listing keys for "bookmarks"
393 386 3 changesets found
394 387 list of changesets:
@@ -408,7 +401,6 b' fred is allowed inside foo/'
408 401 bundle2-input-part: total payload size * (glob)
409 402 bundle2-input-part: "check:updated-heads" supported
410 403 bundle2-input-part: total payload size * (glob)
411 invalid branch cache (served): tip differs
412 404 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
413 405 adding changesets
414 406 add changeset ef1ea85a6374
@@ -463,7 +455,6 b' Empty [acl.deny]'
463 455 listing keys for "phases"
464 456 checking for updated bookmarks
465 457 listing keys for "bookmarks"
466 invalid branch cache (served): tip differs
467 458 listing keys for "bookmarks"
468 459 3 changesets found
469 460 list of changesets:
@@ -483,7 +474,6 b' Empty [acl.deny]'
483 474 bundle2-input-part: total payload size * (glob)
484 475 bundle2-input-part: "check:updated-heads" supported
485 476 bundle2-input-part: total payload size * (glob)
486 invalid branch cache (served): tip differs
487 477 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
488 478 adding changesets
489 479 add changeset ef1ea85a6374
@@ -535,7 +525,6 b' fred is allowed inside foo/, but not foo'
535 525 listing keys for "phases"
536 526 checking for updated bookmarks
537 527 listing keys for "bookmarks"
538 invalid branch cache (served): tip differs
539 528 listing keys for "bookmarks"
540 529 3 changesets found
541 530 list of changesets:
@@ -555,7 +544,6 b' fred is allowed inside foo/, but not foo'
555 544 bundle2-input-part: total payload size * (glob)
556 545 bundle2-input-part: "check:updated-heads" supported
557 546 bundle2-input-part: total payload size * (glob)
558 invalid branch cache (served): tip differs
559 547 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
560 548 adding changesets
561 549 add changeset ef1ea85a6374
@@ -612,7 +600,6 b' fred is allowed inside foo/, but not foo'
612 600 listing keys for "phases"
613 601 checking for updated bookmarks
614 602 listing keys for "bookmarks"
615 invalid branch cache (served): tip differs
616 603 listing keys for "bookmarks"
617 604 3 changesets found
618 605 list of changesets:
@@ -632,7 +619,6 b' fred is allowed inside foo/, but not foo'
632 619 bundle2-input-part: total payload size * (glob)
633 620 bundle2-input-part: "check:updated-heads" supported
634 621 bundle2-input-part: total payload size * (glob)
635 invalid branch cache (served): tip differs
636 622 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
637 623 adding changesets
638 624 add changeset ef1ea85a6374
@@ -686,7 +672,6 b' fred is allowed inside foo/, but not foo'
686 672 listing keys for "phases"
687 673 checking for updated bookmarks
688 674 listing keys for "bookmarks"
689 invalid branch cache (served): tip differs
690 675 listing keys for "bookmarks"
691 676 3 changesets found
692 677 list of changesets:
@@ -706,7 +691,6 b' fred is allowed inside foo/, but not foo'
706 691 bundle2-input-part: total payload size * (glob)
707 692 bundle2-input-part: "check:updated-heads" supported
708 693 bundle2-input-part: total payload size * (glob)
709 invalid branch cache (served): tip differs
710 694 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
711 695 adding changesets
712 696 add changeset ef1ea85a6374
@@ -761,7 +745,6 b' fred is not blocked from moving bookmark'
761 745 listing keys for "phases"
762 746 checking for updated bookmarks
763 747 listing keys for "bookmarks"
764 invalid branch cache (served): tip differs
765 748 listing keys for "bookmarks"
766 749 1 changesets found
767 750 list of changesets:
@@ -783,7 +766,6 b' fred is not blocked from moving bookmark'
783 766 bundle2-input-part: total payload size * (glob)
784 767 bundle2-input-part: "check:updated-heads" supported
785 768 bundle2-input-part: total payload size * (glob)
786 invalid branch cache (served): tip differs
787 769 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
788 770 adding changesets
789 771 add changeset ef1ea85a6374
@@ -849,7 +831,6 b' fred is not allowed to move bookmarks'
849 831 listing keys for "phases"
850 832 checking for updated bookmarks
851 833 listing keys for "bookmarks"
852 invalid branch cache (served): tip differs
853 834 listing keys for "bookmarks"
854 835 1 changesets found
855 836 list of changesets:
@@ -871,7 +852,6 b' fred is not allowed to move bookmarks'
871 852 bundle2-input-part: total payload size * (glob)
872 853 bundle2-input-part: "check:updated-heads" supported
873 854 bundle2-input-part: total payload size * (glob)
874 invalid branch cache (served): tip differs
875 855 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
876 856 adding changesets
877 857 add changeset ef1ea85a6374
@@ -938,7 +918,6 b' barney is allowed everywhere'
938 918 listing keys for "phases"
939 919 checking for updated bookmarks
940 920 listing keys for "bookmarks"
941 invalid branch cache (served): tip differs
942 921 listing keys for "bookmarks"
943 922 3 changesets found
944 923 list of changesets:
@@ -958,7 +937,6 b' barney is allowed everywhere'
958 937 bundle2-input-part: total payload size * (glob)
959 938 bundle2-input-part: "check:updated-heads" supported
960 939 bundle2-input-part: total payload size * (glob)
961 invalid branch cache (served): tip differs
962 940 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
963 941 adding changesets
964 942 add changeset ef1ea85a6374
@@ -1024,7 +1002,6 b' wilma can change files with a .txt exten'
1024 1002 listing keys for "phases"
1025 1003 checking for updated bookmarks
1026 1004 listing keys for "bookmarks"
1027 invalid branch cache (served): tip differs
1028 1005 listing keys for "bookmarks"
1029 1006 3 changesets found
1030 1007 list of changesets:
@@ -1044,7 +1021,6 b' wilma can change files with a .txt exten'
1044 1021 bundle2-input-part: total payload size * (glob)
1045 1022 bundle2-input-part: "check:updated-heads" supported
1046 1023 bundle2-input-part: total payload size * (glob)
1047 invalid branch cache (served): tip differs
1048 1024 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
1049 1025 adding changesets
1050 1026 add changeset ef1ea85a6374
@@ -1108,7 +1084,6 b' file specified by acl.config does not ex'
1108 1084 listing keys for "phases"
1109 1085 checking for updated bookmarks
1110 1086 listing keys for "bookmarks"
1111 invalid branch cache (served): tip differs
1112 1087 listing keys for "bookmarks"
1113 1088 3 changesets found
1114 1089 list of changesets:
@@ -1128,7 +1103,6 b' file specified by acl.config does not ex'
1128 1103 bundle2-input-part: total payload size * (glob)
1129 1104 bundle2-input-part: "check:updated-heads" supported
1130 1105 bundle2-input-part: total payload size * (glob)
1131 invalid branch cache (served): tip differs
1132 1106 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
1133 1107 adding changesets
1134 1108 add changeset ef1ea85a6374
@@ -1186,7 +1160,6 b' betty is allowed inside foo/ by a acl.co'
1186 1160 listing keys for "phases"
1187 1161 checking for updated bookmarks
1188 1162 listing keys for "bookmarks"
1189 invalid branch cache (served): tip differs
1190 1163 listing keys for "bookmarks"
1191 1164 3 changesets found
1192 1165 list of changesets:
@@ -1206,7 +1179,6 b' betty is allowed inside foo/ by a acl.co'
1206 1179 bundle2-input-part: total payload size * (glob)
1207 1180 bundle2-input-part: "check:updated-heads" supported
1208 1181 bundle2-input-part: total payload size * (glob)
1209 invalid branch cache (served): tip differs
1210 1182 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
1211 1183 adding changesets
1212 1184 add changeset ef1ea85a6374
@@ -1275,7 +1247,6 b' acl.config can set only [acl.allow]/[acl'
1275 1247 listing keys for "phases"
1276 1248 checking for updated bookmarks
1277 1249 listing keys for "bookmarks"
1278 invalid branch cache (served): tip differs
1279 1250 listing keys for "bookmarks"
1280 1251 3 changesets found
1281 1252 list of changesets:
@@ -1295,7 +1266,6 b' acl.config can set only [acl.allow]/[acl'
1295 1266 bundle2-input-part: total payload size * (glob)
1296 1267 bundle2-input-part: "check:updated-heads" supported
1297 1268 bundle2-input-part: total payload size * (glob)
1298 invalid branch cache (served): tip differs
1299 1269 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
1300 1270 adding changesets
1301 1271 add changeset ef1ea85a6374
@@ -1365,7 +1335,6 b' fred is always allowed'
1365 1335 listing keys for "phases"
1366 1336 checking for updated bookmarks
1367 1337 listing keys for "bookmarks"
1368 invalid branch cache (served): tip differs
1369 1338 listing keys for "bookmarks"
1370 1339 3 changesets found
1371 1340 list of changesets:
@@ -1385,7 +1354,6 b' fred is always allowed'
1385 1354 bundle2-input-part: total payload size * (glob)
1386 1355 bundle2-input-part: "check:updated-heads" supported
1387 1356 bundle2-input-part: total payload size * (glob)
1388 invalid branch cache (served): tip differs
1389 1357 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
1390 1358 adding changesets
1391 1359 add changeset ef1ea85a6374
@@ -1452,7 +1420,6 b' no one is allowed inside foo/Bar/'
1452 1420 listing keys for "phases"
1453 1421 checking for updated bookmarks
1454 1422 listing keys for "bookmarks"
1455 invalid branch cache (served): tip differs
1456 1423 listing keys for "bookmarks"
1457 1424 3 changesets found
1458 1425 list of changesets:
@@ -1472,7 +1439,6 b' no one is allowed inside foo/Bar/'
1472 1439 bundle2-input-part: total payload size * (glob)
1473 1440 bundle2-input-part: "check:updated-heads" supported
1474 1441 bundle2-input-part: total payload size * (glob)
1475 invalid branch cache (served): tip differs
1476 1442 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
1477 1443 adding changesets
1478 1444 add changeset ef1ea85a6374
@@ -1535,7 +1501,6 b' OS-level groups'
1535 1501 listing keys for "phases"
1536 1502 checking for updated bookmarks
1537 1503 listing keys for "bookmarks"
1538 invalid branch cache (served): tip differs
1539 1504 listing keys for "bookmarks"
1540 1505 3 changesets found
1541 1506 list of changesets:
@@ -1555,7 +1520,6 b' OS-level groups'
1555 1520 bundle2-input-part: total payload size * (glob)
1556 1521 bundle2-input-part: "check:updated-heads" supported
1557 1522 bundle2-input-part: total payload size * (glob)
1558 invalid branch cache (served): tip differs
1559 1523 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
1560 1524 adding changesets
1561 1525 add changeset ef1ea85a6374
@@ -1622,7 +1586,6 b' OS-level groups'
1622 1586 listing keys for "phases"
1623 1587 checking for updated bookmarks
1624 1588 listing keys for "bookmarks"
1625 invalid branch cache (served): tip differs
1626 1589 listing keys for "bookmarks"
1627 1590 3 changesets found
1628 1591 list of changesets:
@@ -1642,7 +1605,6 b' OS-level groups'
1642 1605 bundle2-input-part: total payload size * (glob)
1643 1606 bundle2-input-part: "check:updated-heads" supported
1644 1607 bundle2-input-part: total payload size * (glob)
1645 invalid branch cache (served): tip differs
1646 1608 bundle2-input-part: "changegroup" (params: 1 mandatory) supported
1647 1609 adding changesets
1648 1610 add changeset ef1ea85a6374
@@ -188,13 +188,11 b' backup bundles get logged'
188 188 $ hg strip tip
189 189 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
190 190 saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
191 $ hg blackbox -l 6
191 $ hg blackbox -l 4
192 192 1970-01-01 00:00:00.000 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip
193 193 1970-01-01 00:00:00.000 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg
194 1970-01-01 00:00:00.000 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (base) in * seconds (glob)
195 1970-01-01 00:00:00.000 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (base) with 1 labels and 2 nodes
196 194 1970-01-01 00:00:00.000 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob)
197 1970-01-01 00:00:00.000 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
195 1970-01-01 00:00:00.000 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 4
198 196
199 197 extension and python hooks - use the eol extension for a pythonhook
200 198
@@ -43,11 +43,9 b' older one have been actively deleted.'
43 43
44 44 $ ls -1 .hg/cache/branch?*
45 45 .hg/cache/branch2-base
46 .hg/cache/branch2-served
47 $ cat .hg/cache/branch?-served
48 222ae9789a75703f9836e44de7db179cbfd420ee 2
49 a3498d6e39376d2456425dd8c692367bdbf00fa2 o default
50 222ae9789a75703f9836e44de7db179cbfd420ee o default
46 $ cat .hg/cache/branch?-base
47 7ab0a3bd758a58b9f79557ce708533e627776cce 0
48 7ab0a3bd758a58b9f79557ce708533e627776cce o default
51 49
52 50 We do a new commit and we get a new valid branchmap for the served version
53 51
General Comments 0
You need to be logged in to leave comments. Login now