mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
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:
parent
50c293b94e
commit
78ba8186f3
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user