doctor: repair indexedlog data store when running doctor without a repo

Reviewed By: xavierd

Differential Revision: D23873218

fbshipit-source-id: e0999a4fd5bd6d53e9b28a8c9e175a995f92efa2
This commit is contained in:
Zeyi (Rice) Fan 2020-09-23 17:50:17 -07:00 committed by Facebook GitHub Bot
parent 0a53aa1db3
commit 9041ed077a
2 changed files with 44 additions and 0 deletions

View File

@ -106,6 +106,26 @@ def getindexedloghistorystorepath(repo):
return os.path.join(path, "indexedloghistorystore")
def getallindexedlogdatastorepath(ui):
cachepath = getcachepath(ui)
paths = []
for name in os.listdir(cachepath):
fullpath = os.path.join(cachepath, name, "indexedlogdatastore")
if os.path.isdir(fullpath):
paths.append(fullpath)
return paths
def getallindexedloghistorystorepath(ui):
cachepath = getcachepath(ui)
paths = []
for name in os.listdir(cachepath):
fullpath = os.path.join(cachepath, name, "indexedloghistorystore")
if os.path.isdir(fullpath):
paths.append(fullpath)
return paths
def createrevlogtext(text, copyfrom=None, copyrev=None):
"""returns a string that matches the revlog contents in a
traditional revlog

View File

@ -55,8 +55,10 @@ def doctor(ui, **opts):
# a real repo object.
repopath, ui = dispatch._getlocal(origui, "")
if not repopath:
runglobalindexedlogdoctor(ui)
runedenfsdoctor(ui)
return
repohgpath = os.path.join(repopath, ".hg")
vfs = vfsmod.vfs(repohgpath)
sharedhgpath = vfs.tryreadutf8("sharedpath").rstrip("\n") or repohgpath
@ -492,3 +494,25 @@ def indent(message):
def runedenfsdoctor(ui):
ui.write(_("running 'edenfsctl doctor'\n"))
os.system("edenfsctl doctor")
def runglobalindexedlogdoctor(ui):
"""Global indexed log doctor"""
if not ui.config("remotefilelog", "cachepath"):
# remotefilelog is not enabled, skipping
return
from ...hgext.remotefilelog import shallowutil
for path in shallowutil.getallindexedlogdatastorepath(ui):
repair(
ui, "indexedlogdatastore", path, revisionstore.indexedlogdatastore.repair
)
for path in shallowutil.getallindexedloghistorystorepath(ui):
repair(
ui,
"indexedloghistorystore",
path,
revisionstore.indexedloghistorystore.repair,
)