remotefilelog: add debug command to fetch multiple files over HTTP

Summary: Previously, `hg debuggetfile` would allow fetching a single file from the API server. This diff updates the command to `hg debuggetfiles`, which accepts a list of filenode/path pairs on stdin, and fetches all the files concurrently, writing the contents to a single datapack.

Reviewed By: DurhamG

Differential Revision: D13893894

fbshipit-source-id: 36fc54f1870273ab4b447de5d615b3fb6aaa3378
This commit is contained in:
Arun Kulshreshtha 2019-02-01 01:38:10 -08:00 committed by Facebook Github Bot
parent 50c293b94e
commit 78ba8186f3
3 changed files with 17 additions and 8 deletions

View File

@ -1178,9 +1178,9 @@ def debughttphealthcheck(ui, repo, **opts):
return debugcommands.debughttphealthcheck(ui, repo, **opts)
@command("debuggetfile", [], _("hg debuggetfile <filenode> <path>"))
def debuggetfile(ui, repo, node, path, **opts):
return debugcommands.debuggetfile(ui, repo, node, path, **opts)
@command("debuggetfiles", [], _("hg debuggetfiles"))
def debuggetfiles(ui, repo, **opts):
return debugcommands.debuggetfiles(ui, repo, **opts)
def resolveprefetchopts(ui, opts):

View File

@ -8,6 +8,7 @@ from __future__ import absolute_import
import hashlib
import os
import sys
from edenscm.hgext import extutil
from edenscm.mercurial import error, filelog, revlog
@ -484,6 +485,13 @@ def debughttphealthcheck(ui, repo, **opts):
mononokeapi.healthcheck(ui, repo)
def debuggetfile(ui, repo, node, path, **ops):
outpath = mononokeapi.getfile(ui, repo, node, path)
ui.write(_("wrote file to datapack: %s\n") % outpath)
def debuggetfiles(ui, repo, **opts):
keys = []
for line in sys.stdin.readlines():
key = line.split()
if len(key) != 2:
raise error.Abort(_("invalid input"))
keys.append(tuple(key))
outpath = mononokeapi.getfiles(ui, repo, keys)
ui.write(_("wrote datapack: %s\n") % outpath)

View File

@ -65,8 +65,9 @@ def healthcheck(ui, repo):
raise error.Abort(e)
def getfile(ui, repo, node, path):
def getfiles(ui, repo, keys):
req = GetFilesRequest()
req.push(node, path)
for (node, path) in keys:
req.push(node, path)
client = setupclient(ui, repo)
return client.get_files(req)