mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
archive: prefetch remotefilelog files before executing archive
Summary: Currently archive is almost useless because it fetches each file one-by-one. Let's add prefetching. Differential Revision: D14460880 fbshipit-source-id: 1f06e1ac9d03aae3ab27d3064f9fe6141051be06
This commit is contained in:
parent
161cbd88ad
commit
ee7f2e0275
@ -136,6 +136,7 @@ import traceback
|
||||
from contextlib import contextmanager
|
||||
|
||||
from edenscm.mercurial import (
|
||||
archival,
|
||||
bundle2,
|
||||
changegroup,
|
||||
changelog,
|
||||
@ -580,6 +581,19 @@ def onetimeclientsetup(ui):
|
||||
|
||||
wrapfunction(copies, "_computeforwardmissing", computeforwardmissing)
|
||||
|
||||
# prefetch files before archiving
|
||||
def computefiles(orig, ctx, matchfn):
|
||||
files = orig(ctx, matchfn)
|
||||
|
||||
repo = ctx._repo
|
||||
if shallowrepo.requirement in repo.requirements:
|
||||
mf = ctx.manifest()
|
||||
repo.fileservice.prefetch(list((f, hex(mf.get(f))) for f in files))
|
||||
|
||||
return files
|
||||
|
||||
wrapfunction(archival, "computefiles", computefiles)
|
||||
|
||||
# close cache miss server connection after the command has finished
|
||||
def runcommand(orig, lui, repo, *args, **kwargs):
|
||||
try:
|
||||
|
@ -332,10 +332,7 @@ def archive(repo, dest, node, kind, decode=True, matchfn=None, prefix="", mtime=
|
||||
if not matchfn or matchfn(name):
|
||||
write(name, 0o644, False, lambda: buildmetadata(ctx))
|
||||
|
||||
if matchfn:
|
||||
files = ctx.manifest().matches(matchfn).keys()
|
||||
else:
|
||||
files = ctx.manifest().keys()
|
||||
files = computefiles(ctx, matchfn)
|
||||
total = len(files)
|
||||
if total:
|
||||
files.sort()
|
||||
@ -350,3 +347,11 @@ def archive(repo, dest, node, kind, decode=True, matchfn=None, prefix="", mtime=
|
||||
|
||||
archiver.done()
|
||||
return total
|
||||
|
||||
|
||||
def computefiles(ctx, matchfn):
|
||||
if matchfn:
|
||||
files = ctx.manifest().matches(matchfn).keys()
|
||||
else:
|
||||
files = ctx.manifest().keys()
|
||||
return files
|
||||
|
@ -26,4 +26,4 @@ Test blame
|
||||
|
||||
$ clearcache
|
||||
$ hg archive -r tip -t tar myarchive.tar
|
||||
3 files fetched over 3 fetches - (3 misses, 0.00% hit ratio) over 0.00s
|
||||
3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over 0.00s
|
||||
|
Loading…
Reference in New Issue
Block a user