debugtagscache: verify that filenode is correct
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 15 Feb 2021 17:08:18 +0530
changeset 46694 e4e971abb6a3
parent 46693 9ea6b75b4a95
child 46695 9a31f65381ae
debugtagscache: verify that filenode is correct Previous patch from Matt demonstrates that `debugtagscache` does not warn about filenode being unknown which can be caused by a corrupted cache. We start by showing that it's an unknown node. Differential Revision: https://phab.mercurial-scm.org/D10015
mercurial/debugcommands.py
tests/test-tags.t
--- a/mercurial/debugcommands.py	Thu Dec 24 12:23:46 2020 -0500
+++ b/mercurial/debugcommands.py	Mon Feb 15 17:08:18 2021 +0530
@@ -3865,11 +3865,14 @@
 def debugtagscache(ui, repo):
     """display the contents of .hg/cache/hgtagsfnodes1"""
     cache = tagsmod.hgtagsfnodescache(repo.unfiltered())
+    flog = repo.file(b'.hgtags')
     for r in repo:
         node = repo[r].node()
         tagsnode = cache.getfnode(node, computemissing=False)
         if tagsnode:
             tagsnodedisplay = hex(tagsnode)
+            if not flog.hasnode(tagsnode):
+                tagsnodedisplay += b' (unknown node)'
         elif tagsnode is None:
             tagsnodedisplay = b'missing'
         else:
--- a/tests/test-tags.t	Thu Dec 24 12:23:46 2020 -0500
+++ b/tests/test-tags.t	Mon Feb 15 17:08:18 2021 +0530
@@ -444,12 +444,12 @@
 
   $ hg debugtagscache | tail -2
   4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
-  5 8dbfe60eff306a54259cfe007db9e330e7ecf866 0c04f2a8deadde17fab7422878ee5a2dadbc943d
+  5 8dbfe60eff306a54259cfe007db9e330e7ecf866 0c04f2a8deadde17fab7422878ee5a2dadbc943d (unknown node)
 
   $ rm -f .hg/cache/tags2-visible
   $ hg debugtagscache | tail -2
   4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
-  5 8dbfe60eff306a54259cfe007db9e330e7ecf866 0c04f2a8deadde17fab7422878ee5a2dadbc943d
+  5 8dbfe60eff306a54259cfe007db9e330e7ecf866 0c04f2a8deadde17fab7422878ee5a2dadbc943d (unknown node)
 
   $ hg tags
   abort: data/.hgtags.i@0c04f2a8deadde17fab7422878ee5a2dadbc943d: no match found