doctor: skip unknown visibleheads format

Summary:
When I run `hg doctor` in my www checkout it fails the assertion check of the
first line of visibleheads is "v1". Make it graceful so doctor can check and
fix other components.

Reviewed By: DurhamG

Differential Revision: D20147969

fbshipit-source-id: 6aee2cab962fcd0ef06a0611d288021e86621249
This commit is contained in:
Jun Wu 2020-03-03 13:35:17 -08:00 committed by Facebook Github Bot
parent 7e0c6397c4
commit 5ba323af16
2 changed files with 31 additions and 1 deletions

View File

@ -239,7 +239,10 @@ def repairvisibleheads(ui, metalog, cl):
"""Attempt to fix visibleheads by removing invalid commit hashes"""
oldtext = decodeutf8(metalog.get("visibleheads") or b"")
oldlines = oldtext.splitlines()
assert oldlines[0] == "v1"
# Only support v1 right now.
if oldlines[0:1] != ["v1"]:
ui.write_err(_("visibleheads: skipped\n"))
return
nodemap = cl.nodemap
newlines = [oldlines[0]] + [
hexnode

View File

@ -119,6 +119,23 @@ Check changelog repiar:
$ hg status
Check unknown visibleheads format:
$ newrepo
$ hg dbsh << 'EOS'
> ml = repo.svfs.metalog
> ml.set("visibleheads", "v-1")
> ml.commit("break visibleheads")
> EOS
$ hg doctor
checking internal storage
mutation: looks okay
changelog: looks okay
metalog: looks okay
visibleheads: skipped
treestate: looks okay
allheads: looks okay
Check dirstate pointing to a stripped commit:
$ newrepo
@ -203,4 +220,14 @@ Try other kinds of dirstate corruptions:
visibleheads: looks okay
treestate: repaired
allheads: looks okay
$ hg status
M A2
A A0
A X
R A
R A1
? B
? C
? Y
? Z
#endif