##// END OF EJS Templates
tagcache: distinguish between invalid and missing entries...
Matt Harbison -
r47223:7fbca460 default draft
parent child Browse files
Show More
@@ -1769,7 +1769,7 b' def addparttagsfnodescache(repo, bundler'
1769 1769 for node in outgoing.ancestorsof:
1770 1770 # Don't compute missing, as this may slow down serving.
1771 1771 fnode = cache.getfnode(node, computemissing=False)
1772 if fnode is not None:
1772 if fnode:
1773 1773 chunks.extend([node, fnode])
1774 1774
1775 1775 if chunks:
@@ -3868,7 +3868,13 b' def debugtagscache(ui, repo):'
3868 3868 for r in repo:
3869 3869 node = repo[r].node()
3870 3870 tagsnode = cache.getfnode(node, computemissing=False)
3871 tagsnodedisplay = hex(tagsnode) if tagsnode else b'missing/invalid'
3871 if tagsnode:
3872 tagsnodedisplay = hex(tagsnode)
3873 elif tagsnode is False:
3874 tagsnodedisplay = b'invalid'
3875 else:
3876 tagsnodedisplay = b'missing'
3877
3872 3878 ui.write(b'%d %s %s\n' % (r, hex(node), tagsnodedisplay))
3873 3879
3874 3880
@@ -733,6 +733,7 b' class hgtagsfnodescache(object):'
733 733 if rawlen < wantedlen:
734 734 if self._dirtyoffset is None:
735 735 self._dirtyoffset = rawlen
736 # TODO: zero fill entire record, because it's invalid not missing?
736 737 self._raw.extend(b'\xff' * (wantedlen - rawlen))
737 738
738 739 def getfnode(self, node, computemissing=True):
@@ -740,7 +741,8 b' class hgtagsfnodescache(object):'
740 741
741 742 If the value is in the cache, the entry will be validated and returned.
742 743 Otherwise, the filenode will be computed and returned unless
743 "computemissing" is False, in which case None will be returned without
744 "computemissing" is False. In that case, None will be returned if
745 the entry is missing or False if the entry is invalid without
744 746 any potentially expensive computation being performed.
745 747
746 748 If an .hgtags does not exist at the specified revision, nullid is
@@ -771,6 +773,8 b' class hgtagsfnodescache(object):'
771 773 # If we get here, the entry is either missing or invalid.
772 774
773 775 if not computemissing:
776 if record != _fnodesmissingrec:
777 return False
774 778 return None
775 779
776 780 fnode = None
@@ -788,7 +792,7 b' class hgtagsfnodescache(object):'
788 792 # we cannot rely on readfast because we don't know against what
789 793 # parent the readfast delta is computed
790 794 p1fnode = None
791 if p1fnode is not None:
795 if p1fnode:
792 796 mctx = ctx.manifestctx()
793 797 fnode = mctx.readfast().get(b'.hgtags')
794 798 if fnode is None:
@@ -104,7 +104,7 b' The cache should have an empty entry for'
104 104 0010: ff ff ff ff ff ff ff ff b9 15 46 36 26 b7 b4 a7 |..........F6&...|
105 105 0020: 73 e0 9e e3 c5 2f 51 0e 19 e0 5e 1f f9 66 d8 59 |s..../Q...^..f.Y|
106 106 $ hg debugtagscache
107 0 acb14030fe0a21b60322c440ad2d20cf7685a376 missing/invalid
107 0 acb14030fe0a21b60322c440ad2d20cf7685a376 missing
108 108 1 b9154636be938d3d431e75a7c906504a079bfe07 26b7b4a773e09ee3c52f510e19e05e1ff966d859
109 109
110 110 Repeat with cold tag cache:
@@ -381,7 +381,7 b' On junk data + missing cache entries, hg'
381 381
382 382 $ hg debugtagscache | tail -2
383 383 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
384 5 8dbfe60eff306a54259cfe007db9e330e7ecf866 missing/invalid
384 5 8dbfe60eff306a54259cfe007db9e330e7ecf866 missing
385 385 $ hg tags
386 386 tip 5:8dbfe60eff30
387 387 bar 1:78391a272241
@@ -389,6 +389,34 b' On junk data + missing cache entries, hg'
389 389 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
390 390 5 8dbfe60eff306a54259cfe007db9e330e7ecf866 0c04f2a8af31de17fab7422878ee5a2dadbc943d
391 391
392 If the 4 bytes of node hash for a record don't match an existing node, the entry
393 is flagged as invalid.
394
395 >>> import os
396 >>> with open(".hg/cache/hgtagsfnodes1", "rb+") as fp:
397 ... fp.seek(-24, os.SEEK_END) and None
398 ... fp.write(b'\xde\xad') and None
399
400 $ f --size --hexdump .hg/cache/hgtagsfnodes1
401 .hg/cache/hgtagsfnodes1: size=144
402 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
403 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
404 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
405 0030: 7a 94 12 77 0c 04 f2 a8 af 31 de 17 fa b7 42 28 |z..w.....1....B(|
406 0040: 78 ee 5a 2d ad bc 94 3d 6f a4 50 21 7d 3b 71 8c |x.Z-...=o.P!};q.|
407 0050: 96 4e f3 7b 89 e5 50 eb da fd 57 89 e7 6c e1 b0 |.N.{..P...W..l..|
408 0060: 0c 19 2d 7d 0c 04 f2 a8 af 31 de 17 fa b7 42 28 |..-}.....1....B(|
409 0070: 78 ee 5a 2d ad bc 94 3d de ad e6 0e 0c 04 f2 a8 |x.Z-...=........|
410 0080: af 31 de 17 fa b7 42 28 78 ee 5a 2d ad bc 94 3d |.1....B(x.Z-...=|
411
412 $ hg debugtagscache | tail -2
413 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
414 5 8dbfe60eff306a54259cfe007db9e330e7ecf866 invalid
415
416 $ hg tags
417 tip 5:8dbfe60eff30
418 bar 1:78391a272241
419
392 420 #if unix-permissions no-root
393 421 Errors writing to .hgtags fnodes cache are silently ignored
394 422
@@ -405,7 +433,7 b' Errors writing to .hgtags fnodes cache a'
405 433 $ hg blackbox -l 6
406 434 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags
407 435 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> couldn't write cache/hgtagsfnodes1: [Errno *] * (glob)
408 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> 3/4 cache hits/lookups in * seconds (glob)
436 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> 2/4 cache hits/lookups in * seconds (glob)
409 437 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing .hg/cache/tags2-visible with 1 tags
410 438 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags exited 0 after * seconds (glob)
411 439 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> blackbox -l 6
@@ -420,7 +448,7 b' Errors writing to .hgtags fnodes cache a'
420 448 $ hg blackbox -l 6
421 449 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags
422 450 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing 24 bytes to cache/hgtagsfnodes1
423 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> 3/4 cache hits/lookups in * seconds (glob)
451 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> 2/4 cache hits/lookups in * seconds (glob)
424 452 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing .hg/cache/tags2-visible with 1 tags
425 453 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags exited 0 after * seconds (glob)
426 454 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> blackbox -l 6
General Comments 0
You need to be logged in to leave comments. Login now