##// END OF EJS Templates
phases: avoid N² behavior in `advanceboundary`...
phases: avoid N² behavior in `advanceboundary` We allowed duplicated entries in the deque, which each entry could potentially insert all its ancestors. So advancing boundary for the full repository would mean each revision would walk all its ancestors, resulting in O(N²) iteration. For repository of any decent size, N² is quickly insane. We introduce a simple set to avoid this and get back to reasonable performance.

File last commit:

r52263:0d414fb8 default
r52398:c9ceb4f6 6.7 stable
Show More
__init__.py
1259 lines | 41.0 KiB | text/x-python | PythonLexer
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 # __init__.py - remotefilelog extension
#
# Copyright 2013 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
"""remotefilelog causes Mercurial to lazilly fetch file contents (EXPERIMENTAL)
Augie Fackler
remotefilelog: add some docstring...
r40547 This extension is HIGHLY EXPERIMENTAL. There are NO BACKWARDS COMPATIBILITY
GUARANTEES. This means that repositories created with this extension may
only be usable with the exact version of this extension/Mercurial that was
used. The extension attempts to enforce this in order to prevent repository
corruption.
remotefilelog works by fetching file contents lazily and storing them
in a cache on the client rather than in revlogs. This allows enormous
histories to be transferred only partially, making them easier to
operate on.
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 Configs:
``packs.maxchainlen`` specifies the maximum delta chain length in pack files
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``packs.maxpacksize`` specifies the maximum pack file size
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``packs.maxpackfilecount`` specifies the maximum number of packs in the
shared cache (trees only for now)
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.backgroundprefetch`` runs prefetch in background when True
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.bgprefetchrevs`` specifies revisions to fetch on commit and
update, and on other commands that use them. Different from pullprefetch.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.gcrepack`` does garbage collection during repack when True
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.nodettl`` specifies maximum TTL of a node in seconds before
it is garbage collected
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.repackonhggc`` runs repack on hg gc when True
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.prefetchdays`` specifies the maximum age of a commit in
days after which it is no longer prefetched.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.prefetchdelay`` specifies delay between background
prefetches in seconds after operations that change the working copy parent
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.data.gencountlimit`` constraints the minimum number of data
pack files required to be considered part of a generation. In particular,
minimum number of packs files > gencountlimit.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.data.generations`` list for specifying the lower bound of
each generation of the data pack files. For example, list ['100MB','1MB']
or ['1MB', '100MB'] will lead to three generations: [0, 1MB), [
1MB, 100MB) and [100MB, infinity).
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.data.maxrepackpacks`` the maximum number of pack files to
include in an incremental data repack.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.data.repackmaxpacksize`` the maximum size of a pack file for
it to be considered for an incremental data repack.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.data.repacksizelimit`` the maximum total size of pack files
to include in an incremental data repack.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.history.gencountlimit`` constraints the minimum number of
history pack files required to be considered part of a generation. In
particular, minimum number of packs files > gencountlimit.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.history.generations`` list for specifying the lower bound of
Augie Fackler
remotefilelog: fix typo in docstring...
r40768 each generation of the history pack files. For example, list [
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 '100MB', '1MB'] or ['1MB', '100MB'] will lead to three generations: [
0, 1MB), [1MB, 100MB) and [100MB, infinity).
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.history.maxrepackpacks`` the maximum number of pack files to
include in an incremental history repack.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.history.repackmaxpacksize`` the maximum size of a pack file
for it to be considered for an incremental history repack.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.history.repacksizelimit`` the maximum total size of pack
files to include in an incremental history repack.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.backgroundrepack`` automatically consolidate packs in the
background
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.cachepath`` path to cache
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.cachegroup`` if set, make cache directory sgid to this
group
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.cacheprocess`` binary to invoke for fetching file data
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.debug`` turn on remotefilelog-specific debug output
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.excludepattern`` pattern of files to exclude from pulls
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
``remotefilelog.includepattern`` pattern of files to include in pulls
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.fetchwarning``: message to print when too many
single-file fetches occur
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.getfilesstep`` number of files to request in a single RPC
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.getfilestype`` if set to 'threaded' use threads to fetch
files, otherwise use optimistic fetching
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.pullprefetch`` revset for selecting files that should be
eagerly downloaded rather than lazily
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.reponame`` name of the repo. If set, used to partition
data from other repos in a shared store.
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.server`` if true, enable server-side functionality
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.servercachepath`` path for caching blobs on the server
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.serverexpiration`` number of days to keep cached server
blobs
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.validatecache`` if set, check cache entries for corruption
before returning blobs
Augie Fackler
remotefilelog: fix various whitespace issues in docstring...
r40581
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 ``remotefilelog.validatecachelog`` if set, check cache entries for
corruption before returning metadata
"""
import os
import time
import traceback
Joerg Sonnenberger
node: import symbols explicitly...
r46729 from mercurial.node import (
hex,
wdirrev,
)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 from mercurial.i18n import _
Gregory Szorc
py3: manually import pycompat.open into files that need it...
r43355 from mercurial.pycompat import open
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 from mercurial import (
changegroup,
changelog,
commands,
configitems,
context,
copies,
debugcommands as hgdebugcommands,
dispatch,
error,
exchange,
extensions,
hg,
localrepo,
Rodrigo Damazio Bovendorp
scmutil: allowing different files to be prefetched per revision...
r45632 match as matchmod,
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 merge,
Pulkit Goyal
mergeactions: use action constants instead of string values...
r45851 mergestate as mergestatemod,
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 patch,
Pulkit Goyal
py3: fix keyword arguments handling in hgext/remotefilelog/...
r40646 pycompat,
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 registrar,
repair,
repoview,
revset,
scmutil,
smartset,
Pulkit Goyal
remotefilelog: remove some BC code related to streamclone...
r40548 streamclone,
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 util,
)
from . import (
Augie Fackler
remotefilelog: rename capability for legacy ssh file fetching method...
r40543 constants,
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 debugcommands,
fileserverclient,
remotefilectx,
remotefilelog,
remotefilelogserver,
repack as repackmod,
shallowbundle,
shallowrepo,
shallowstore,
shallowutil,
shallowverifier,
)
# ensures debug commands are registered
hgdebugcommands.command
cmdtable = {}
command = registrar.command(cmdtable)
configtable = {}
configitem = registrar.configitem(configtable)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 configitem(b'remotefilelog', b'debug', default=False)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 configitem(b'remotefilelog', b'reponame', default=b'')
configitem(b'remotefilelog', b'cachepath', default=None)
configitem(b'remotefilelog', b'cachegroup', default=None)
configitem(b'remotefilelog', b'cacheprocess', default=None)
configitem(b'remotefilelog', b'cacheprocess.includepath', default=None)
configitem(b"remotefilelog", b"cachelimit", default=b"1000 GB")
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: blacken the codebase...
r43346 configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'remotefilelog',
b'fallbackpath',
Augie Fackler
formatting: blacken the codebase...
r43346 default=configitems.dynamicdefault,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 alias=[(b'remotefilelog', b'fallbackrepo')],
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 configitem(b'remotefilelog', b'validatecachelog', default=None)
configitem(b'remotefilelog', b'validatecache', default=b'on')
configitem(b'remotefilelog', b'server', default=None)
configitem(b'remotefilelog', b'servercachepath', default=None)
configitem(b"remotefilelog", b"serverexpiration", default=30)
configitem(b'remotefilelog', b'backgroundrepack', default=False)
configitem(b'remotefilelog', b'bgprefetchrevs', default=None)
configitem(b'remotefilelog', b'pullprefetch', default=None)
configitem(b'remotefilelog', b'backgroundprefetch', default=False)
configitem(b'remotefilelog', b'prefetchdelay', default=120)
configitem(b'remotefilelog', b'prefetchdays', default=14)
Kyle Lippincott
remotefilelog: include file contents in bundles produced during strip...
r47606 # Other values include 'local' or 'none'. Any unrecognized value is 'all'.
configitem(b'remotefilelog', b'strip.includefiles', default='all')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 configitem(b'remotefilelog', b'getfilesstep', default=10000)
configitem(b'remotefilelog', b'getfilestype', default=b'optimistic')
configitem(b'remotefilelog', b'batchsize', configitems.dynamicdefault)
configitem(b'remotefilelog', b'fetchwarning', default=b'')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 configitem(b'remotefilelog', b'includepattern', default=None)
configitem(b'remotefilelog', b'excludepattern', default=None)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 configitem(b'remotefilelog', b'gcrepack', default=False)
configitem(b'remotefilelog', b'repackonhggc', default=False)
configitem(b'repack', b'chainorphansbysize', default=True, experimental=True)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 configitem(b'packs', b'maxpacksize', default=0)
configitem(b'packs', b'maxchainlen', default=1000)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
remotefilelog: add a developer option to wait for background processes...
r44298 configitem(b'devel', b'remotefilelog.bg-wait', default=False)
Boris Feld
remotefilelog: reduce probability of race-condition in remotefilelog tests...
r43110
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 # default TTL limit is 30 days
_defaultlimit = 60 * 60 * 24 * 30
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 configitem(b'remotefilelog', b'nodettl', default=_defaultlimit)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 configitem(b'remotefilelog', b'data.gencountlimit', default=2),
configitem(
b'remotefilelog', b'data.generations', default=[b'1GB', b'100MB', b'1MB']
)
configitem(b'remotefilelog', b'data.maxrepackpacks', default=50)
configitem(b'remotefilelog', b'data.repackmaxpacksize', default=b'4GB')
configitem(b'remotefilelog', b'data.repacksizelimit', default=b'100MB')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 configitem(b'remotefilelog', b'history.gencountlimit', default=2),
configitem(b'remotefilelog', b'history.generations', default=[b'100MB'])
configitem(b'remotefilelog', b'history.maxrepackpacks', default=50)
configitem(b'remotefilelog', b'history.repackmaxpacksize', default=b'400MB')
configitem(b'remotefilelog', b'history.repacksizelimit', default=b'100MB')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 testedwith = b'ships-with-hg-core'
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
repoclass = localrepo.localrepository
Augie Fackler
remotefilelog: consolidate and rename on-disk store requirement...
r40545 repoclass._basesupported.add(constants.SHALLOWREPO_REQUIREMENT)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Pulkit Goyal
shallowutil: introduce a helper function isenabled()...
r40549 isenabled = shallowutil.isenabled
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def uisetup(ui):
"""Wraps user facing Mercurial commands to swap them out with shallow
versions.
"""
hg.wirepeersetupfuncs.append(fileserverclient.peersetup)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 entry = extensions.wrapcommand(commands.table, b'clone', cloneshallow)
Augie Fackler
formatting: blacken the codebase...
r43346 entry[1].append(
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'',
b'shallow',
Augie Fackler
formatting: blacken the codebase...
r43346 None,
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b"create a shallow clone which uses remote file history"),
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: blacken the codebase...
r43346 extensions.wrapcommand(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 commands.table, b'debugindex', debugcommands.debugindex
Augie Fackler
formatting: blacken the codebase...
r43346 )
extensions.wrapcommand(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 commands.table, b'debugindexdot', debugcommands.debugindexdot
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 extensions.wrapcommand(commands.table, b'log', log)
extensions.wrapcommand(commands.table, b'pull', pull)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
# Prevent 'hg manifest --all'
def _manifest(orig, ui, repo, *args, **opts):
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 if isenabled(repo) and opts.get('all'):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"--all is not supported in a shallow repo"))
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
return orig(ui, repo, *args, **opts)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 extensions.wrapcommand(commands.table, b"manifest", _manifest)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
# Wrap remotefilelog with lfs code
def _lfsloaded(loaded=False):
lfsmod = None
try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 lfsmod = extensions.find(b'lfs')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 except KeyError:
pass
if lfsmod:
lfsmod.wrapfilelog(remotefilelog.remotefilelog)
fileserverclient._lfsmod = lfsmod
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 extensions.afterloaded(b'lfs', _lfsloaded)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
# debugdata needs remotefilelog.len to work
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 extensions.wrapcommand(commands.table, b'debugdata', debugdatashallow)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Martin von Zweigbergk
remotefilelog: move most setup from onetimesetup() to uisetup()...
r42460 changegroup.cgpacker = shallowbundle.shallowcg1packer
extensions.wrapfunction(
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 changegroup, '_addchangegroupfiles', shallowbundle.addchangegroupfiles
Augie Fackler
formatting: blacken the codebase...
r43346 )
extensions.wrapfunction(
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 changegroup, 'makechangegroup', shallowbundle.makechangegroup
Augie Fackler
formatting: blacken the codebase...
r43346 )
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 extensions.wrapfunction(localrepo, 'makestore', storewrapper)
extensions.wrapfunction(exchange, 'pull', exchangepull)
extensions.wrapfunction(merge, 'applyupdates', applyupdates)
extensions.wrapfunction(merge, '_checkunknownfiles', checkunknownfiles)
extensions.wrapfunction(context.workingctx, '_checklookup', checklookup)
extensions.wrapfunction(scmutil, '_findrenames', findrenames)
Augie Fackler
formatting: blacken the codebase...
r43346 extensions.wrapfunction(
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 copies, '_computeforwardmissing', computeforwardmissing
Augie Fackler
formatting: blacken the codebase...
r43346 )
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 extensions.wrapfunction(dispatch, 'runcommand', runcommand)
extensions.wrapfunction(repair, '_collectbrokencsets', _collectbrokencsets)
extensions.wrapfunction(context.changectx, 'filectx', filectx)
extensions.wrapfunction(context.workingctx, 'filectx', workingfilectx)
extensions.wrapfunction(patch, 'trydiff', trydiff)
extensions.wrapfunction(hg, 'verify', _verify)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 scmutil.fileprefetchhooks.add(b'remotefilelog', _fileprefetchhook)
Martin von Zweigbergk
remotefilelog: move most setup from onetimesetup() to uisetup()...
r42460
# disappointing hacks below
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 extensions.wrapfunction(scmutil, 'getrenamedfn', getrenamedfn)
extensions.wrapfunction(revset, 'filelog', filelogrevset)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 revset.symbols[b'filelog'] = revset.filelog
Martin von Zweigbergk
remotefilelog: move most setup from onetimesetup() to uisetup()...
r42460
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def cloneshallow(orig, ui, repo, *args, **opts):
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 if opts.get('shallow'):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 repos = []
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def pull_shallow(orig, self, *args, **kwargs):
Pulkit Goyal
shallowutil: introduce a helper function isenabled()...
r40549 if not isenabled(self):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 repos.append(self.unfiltered())
# set up the client hooks so the post-clone update works
setupclient(self.ui, self.unfiltered())
# setupclient fixed the class on the repo itself
# but we also need to fix it on the repoview
if isinstance(self, repoview.repoview):
Augie Fackler
formatting: blacken the codebase...
r43346 self.__class__.__bases__ = (
self.__class__.__bases__[0],
self.unfiltered().__class__,
)
Augie Fackler
remotefilelog: consolidate and rename on-disk store requirement...
r40545 self.requirements.add(constants.SHALLOWREPO_REQUIREMENT)
Pulkit Goyal
remotefilelog: acquire lock before writing requirements on clone...
r46053 with self.lock():
# acquire store lock before writing requirements as some
# requirements might be written to .hg/store/requires
scmutil.writereporequirements(self)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
# Since setupclient hadn't been called, exchange.pull was not
# wrapped. So we need to manually invoke our version of it.
return exchangepull(orig, self, *args, **kwargs)
else:
return orig(self, *args, **kwargs)
Augie Fackler
formatting: blacken the codebase...
r43346
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 extensions.wrapfunction(exchange, 'pull', pull_shallow)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
# Wrap the stream logic to add requirements and to pass include/exclude
# patterns around.
def setup_streamout(repo, remote):
# Replace remote.stream_out with a version that sends file
# patterns.
def stream_out_shallow(orig):
caps = remote.capabilities()
Augie Fackler
remotefilelog: rename capability for legacy ssh file fetching method...
r40543 if constants.NETWORK_CAP_LEGACY_SSH_GETFILES in caps:
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 opts = {}
if repo.includepattern:
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 opts['includepattern'] = b'\0'.join(repo.includepattern)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if repo.excludepattern:
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 opts['excludepattern'] = b'\0'.join(repo.excludepattern)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return remote._callstream(b'stream_out_shallow', **opts)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 else:
return orig()
Augie Fackler
formatting: blacken the codebase...
r43346
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 extensions.wrapfunction(remote, 'stream_out', stream_out_shallow)
Augie Fackler
formatting: blacken the codebase...
r43346
Pulkit Goyal
remotefilelog: remove some BC code related to streamclone...
r40548 def stream_wrap(orig, op):
setup_streamout(op.repo, op.remote)
return orig(op)
Augie Fackler
formatting: blacken the codebase...
r43346
Pulkit Goyal
remotefilelog: remove some BC code related to streamclone...
r40548 extensions.wrapfunction(
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 streamclone, 'maybeperformlegacystreamclone', stream_wrap
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Pulkit Goyal
remotefilelog: remove some BC code related to streamclone...
r40548 def canperformstreamclone(orig, pullop, bundle2=False):
# remotefilelog is currently incompatible with the
# bundle2 flavor of streamclones, so force us to use
# v1 instead.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b'v2' in pullop.remotebundle2caps.get(b'stream', []):
stream-clone: introduce the notion of an experimental "v3" version...
r51417 pullop.remotebundle2caps[b'stream'] = []
Pulkit Goyal
remotefilelog: remove some BC code related to streamclone...
r40548 if bundle2:
return False, None
supported, requirements = orig(pullop, bundle2=bundle2)
if requirements is not None:
Augie Fackler
remotefilelog: consolidate and rename on-disk store requirement...
r40545 requirements.add(constants.SHALLOWREPO_REQUIREMENT)
Pulkit Goyal
remotefilelog: remove some BC code related to streamclone...
r40548 return supported, requirements
Augie Fackler
formatting: blacken the codebase...
r43346
Pulkit Goyal
remotefilelog: remove some BC code related to streamclone...
r40548 extensions.wrapfunction(
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 streamclone, 'canperformstreamclone', canperformstreamclone
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
try:
orig(ui, repo, *args, **opts)
finally:
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 if opts.get('shallow'):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 for r in repos:
safehasattr: drop usage in favor of hasattr...
r51821 if hasattr(r, 'fileservice'):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 r.fileservice.close()
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def debugdatashallow(orig, *args, **kwds):
oldlen = remotefilelog.remotefilelog.__len__
try:
remotefilelog.remotefilelog.__len__ = lambda x: 1
return orig(*args, **kwds)
finally:
remotefilelog.remotefilelog.__len__ = oldlen
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def reposetup(ui, repo):
Matt Harbison
remotefilelog: use repo.local() instead of isinstance()
r41088 if not repo.local():
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 return
# put here intentionally bc doesnt work in uisetup
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.setconfig(b'hooks', b'update.prefetch', wcpprefetch)
ui.setconfig(b'hooks', b'commit.prefetch', wcpprefetch)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 isserverenabled = ui.configbool(b'remotefilelog', b'server')
Pulkit Goyal
shallowutil: introduce a helper function isenabled()...
r40549 isshallowclient = isenabled(repo)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
if isserverenabled and isshallowclient:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise RuntimeError(b"Cannot be both a server and shallow client.")
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
if isshallowclient:
setupclient(ui, repo)
if isserverenabled:
remotefilelogserver.setupserver(ui, repo)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def setupclient(ui, repo):
if not isinstance(repo, localrepo.localrepository):
return
# Even clients get the server setup since they need to have the
# wireprotocol endpoints registered.
remotefilelogserver.onetimesetup(ui)
onetimeclientsetup(ui)
shallowrepo.wraprepo(repo)
repo.store = shallowstore.wrapstore(repo.store)
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 def storewrapper(orig, requirements, path, vfstype):
s = orig(requirements, path, vfstype)
if constants.SHALLOWREPO_REQUIREMENT in requirements:
s = shallowstore.wrapstore(s)
return s
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 # prefetch files before update
Augie Fackler
formatting: blacken the codebase...
r43346 def applyupdates(
Pulkit Goyal
merge: pass mergeresult obj instead of actions in applyupdates() (API)...
r45894 orig, repo, mresult, wctx, mctx, overwrite, wantfiledata, **opts
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 if isenabled(repo):
manifest = mctx.manifest()
files = []
Pulkit Goyal
merge: pass mergeresult obj instead of actions in applyupdates() (API)...
r45894 for f, args, msg in mresult.getactions([mergestatemod.ACTION_GET]):
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 files.append((f, hex(manifest[f])))
# batch fetch the needed files from the server
repo.fileservice.prefetch(files)
Pulkit Goyal
merge: pass mergeresult obj instead of actions in applyupdates() (API)...
r45894 return orig(repo, mresult, wctx, mctx, overwrite, wantfiledata, **opts)
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459
# Prefetch merge checkunknownfiles
Pulkit Goyal
merge: pass mergeresult instead of actions in _checkunknownfiles() (API)...
r45844 def checkunknownfiles(orig, repo, wctx, mctx, force, mresult, *args, **kwargs):
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 if isenabled(repo):
files = []
sparsematch = repo.maybesparsematch(mctx.rev())
Pulkit Goyal
mergeresult: introduce filemap() which yields filename based mapping...
r45906 for f, (m, actionargs, msg) in mresult.filemap():
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 if sparsematch and not sparsematch(f):
continue
Pulkit Goyal
mergeactions: use action constants instead of string values...
r45851 if m in (
mergestatemod.ACTION_CREATED,
mergestatemod.ACTION_DELETED_CHANGED,
mergestatemod.ACTION_CREATED_MERGE,
):
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 files.append((f, hex(mctx.filenode(f))))
Pulkit Goyal
mergeactions: use action constants instead of string values...
r45851 elif m == mergestatemod.ACTION_LOCAL_DIR_RENAME_GET:
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 f2 = actionargs[0]
files.append((f2, hex(mctx.filenode(f2))))
# batch fetch the needed files from the server
repo.fileservice.prefetch(files)
Pulkit Goyal
merge: pass mergeresult instead of actions in _checkunknownfiles() (API)...
r45844 return orig(repo, wctx, mctx, force, mresult, *args, **kwargs)
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 # Prefetch files before status attempts to look at their size and contents
status: use filesystem time boundary to invalidate racy mtime...
r49213 def checklookup(orig, self, files, mtime_boundary):
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 repo = self._repo
if isenabled(repo):
prefetchfiles = []
for parent in self._parents:
for f in files:
if f in parent:
prefetchfiles.append((f, hex(parent.filenode(f))))
# batch fetch the needed files from the server
repo.fileservice.prefetch(prefetchfiles)
status: use filesystem time boundary to invalidate racy mtime...
r49213 return orig(self, files, mtime_boundary)
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 # Prefetch the logic that compares added and removed files for renames
def findrenames(orig, repo, matcher, added, removed, *args, **kwargs):
if isenabled(repo):
files = []
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pmf = repo[b'.'].manifest()
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 for f in removed:
if f in pmf:
files.append((f, hex(pmf[f])))
# batch fetch the needed files from the server
repo.fileservice.prefetch(files)
return orig(repo, matcher, added, removed, *args, **kwargs)
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 # prefetch files before pathcopies check
def computeforwardmissing(orig, a, b, match=None):
missing = orig(a, b, match=match)
repo = a._repo
if isenabled(repo):
mb = b.manifest()
files = []
sparsematch = repo.maybesparsematch(b.rev())
if sparsematch:
sparsemissing = set()
for f in missing:
if sparsematch(f):
files.append((f, hex(mb[f])))
sparsemissing.add(f)
missing = sparsemissing
# batch fetch the needed files from the server
repo.fileservice.prefetch(files)
return missing
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 # close cache miss server connection after the command has finished
def runcommand(orig, lui, repo, *args, **kwargs):
fileservice = None
# repo can be None when running in chg:
# - at startup, reposetup was called because serve is not norepo
# - a norepo command like "help" is called
if repo and isenabled(repo):
fileservice = repo.fileservice
try:
return orig(lui, repo, *args, **kwargs)
finally:
if fileservice:
fileservice.close()
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 # prevent strip from stripping remotefilelogs
def _collectbrokencsets(orig, repo, files, striprev):
if isenabled(repo):
Manuel Jacob
cleanup: remove unnecessary list constructor calls around list comprehensions
r52263 files = [f for f in files if not repo.shallowmatch(f)]
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 return orig(repo, files, striprev)
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 # changectx wrappers
def filectx(orig, self, path, fileid=None, filelog=None):
if fileid is None:
fileid = self.filenode(path)
Augie Fackler
formatting: blacken the codebase...
r43346 if isenabled(self._repo) and self._repo.shallowmatch(path):
return remotefilectx.remotefilectx(
self._repo, path, fileid=fileid, changectx=self, filelog=filelog
)
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 return orig(self, path, fileid=fileid, filelog=filelog)
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 def workingfilectx(orig, self, path, filelog=None):
Augie Fackler
formatting: blacken the codebase...
r43346 if isenabled(self._repo) and self._repo.shallowmatch(path):
return remotefilectx.remoteworkingfilectx(
self._repo, path, workingctx=self, filelog=filelog
)
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 return orig(self, path, filelog=filelog)
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 # prefetch required revisions before a diff
Augie Fackler
formatting: blacken the codebase...
r43346 def trydiff(
orig,
repo,
revs,
ctx1,
ctx2,
modified,
added,
removed,
copy,
getfilectx,
*args,
**kwargs
):
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459 if isenabled(repo):
prefetch = []
mf1 = ctx1.manifest()
for fname in modified + added + removed:
if fname in mf1:
fnode = getfilectx(fname, ctx1).filenode()
# fnode can be None if it's a edited working ctx file
if fnode:
prefetch.append((fname, hex(fnode)))
if fname not in removed:
fnode = getfilectx(fname, ctx2).filenode()
if fnode:
prefetch.append((fname, hex(fnode)))
repo.fileservice.prefetch(prefetch)
Augie Fackler
formatting: blacken the codebase...
r43346 return orig(
repo,
revs,
ctx1,
ctx2,
modified,
added,
removed,
copy,
getfilectx,
*args,
**kwargs
)
Martin von Zweigbergk
remotefilelog: move most functions in onetimeclientsetup() to top level...
r42459
# Prevent verify from processing files
# a stub for mercurial.hg.verify()
def _verify(orig, repo, level=None):
lock = repo.lock()
try:
return shallowverifier.shallowverifier(repo).verify()
finally:
lock.release()
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 clientonetime = False
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def onetimeclientsetup(ui):
global clientonetime
if clientonetime:
return
clientonetime = True
# Don't commit filelogs until we know the commit hash, since the hash
# is present in the filelog blob.
# This violates Mercurial's filelog->manifest->changelog write order,
# but is generally fine for client repos.
pendingfilecommits = []
Augie Fackler
formatting: blacken the codebase...
r43346
def addrawrevision(
orig,
self,
rawtext,
transaction,
link,
p1,
p2,
node,
flags,
cachedelta=None,
_metatuple=None,
):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if isinstance(link, int):
pendingfilecommits.append(
Augie Fackler
formatting: blacken the codebase...
r43346 (
self,
rawtext,
transaction,
link,
p1,
p2,
node,
flags,
cachedelta,
_metatuple,
)
)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 return node
else:
Augie Fackler
formatting: blacken the codebase...
r43346 return orig(
self,
rawtext,
transaction,
link,
p1,
p2,
node,
flags,
cachedelta,
_metatuple=_metatuple,
)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 extensions.wrapfunction(
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 remotefilelog.remotefilelog, 'addrawrevision', addrawrevision
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Daniel Ploch
remotefilelog: handle **kwargs correctly when overriding changelog.add()...
r44017 def changelogadd(orig, self, *args, **kwargs):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 oldlen = len(self)
Daniel Ploch
remotefilelog: handle **kwargs correctly when overriding changelog.add()...
r44017 node = orig(self, *args, **kwargs)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 newlen = len(self)
if oldlen != newlen:
for oldargs in pendingfilecommits:
log, rt, tr, link, p1, p2, n, fl, c, m = oldargs
linknode = self.node(link)
if linknode == node:
log.addrawrevision(rt, tr, linknode, p1, p2, n, fl, c, m)
else:
raise error.ProgrammingError(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'pending multiple integer revisions are not supported'
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 else:
# "link" is actually wrong here (it is set to len(changelog))
# if changelog remains unchanged, skip writing file revisions
# but still do a sanity check about pending multiple revisions
Augie Fackler
cleanup: run pyupgrade on our source tree to clean up varying things...
r44937 if len({x[3] for x in pendingfilecommits}) > 1:
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 raise error.ProgrammingError(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'pending multiple integer revisions are not supported'
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 del pendingfilecommits[:]
return node
Augie Fackler
formatting: blacken the codebase...
r43346
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 extensions.wrapfunction(changelog.changelog, 'add', changelogadd)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
remotefilelog: check if RFL is enabled in getrenamedfn() override...
r42699 def getrenamedfn(orig, repo, endrev=None):
Martin von Zweigbergk
remotefilelog: handle copies in changesets in getrenamedfn() override...
r42700 if not isenabled(repo) or copies.usechangesetcentricalgo(repo):
Martin von Zweigbergk
remotefilelog: check if RFL is enabled in getrenamedfn() override...
r42699 return orig(repo, endrev)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 rcache = {}
def getrenamed(fn, rev):
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """looks up all renames for a file (up to endrev) the first
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 time the file is given. It indexes on the changerev and only
parses the manifest if linkrev != changerev.
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 Returns rename info for fn at changerev rev."""
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if rev in rcache.setdefault(fn, {}):
return rcache[fn][rev]
try:
fctx = repo[rev].filectx(fn)
for ancestor in fctx.ancestors():
if ancestor.path() == fn:
renamed = ancestor.renamed()
Martin von Zweigbergk
remotefilelog: fix {file_copies} template keyword...
r41228 rcache[fn][ancestor.rev()] = renamed and renamed[0]
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Martin von Zweigbergk
remotefilelog: fix {file_copies} template keyword...
r41228 renamed = fctx.renamed()
return renamed and renamed[0]
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 except error.LookupError:
return None
return getrenamed
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def filelogrevset(orig, repo, subset, x):
"""``filelog(pattern)``
Changesets connected to the specified filelog.
For performance reasons, ``filelog()`` does not show every changeset
that affects the requested file(s). See :hg:`help log` for details. For
a slower, more accurate result, use ``file()``.
"""
Pulkit Goyal
shallowutil: introduce a helper function isenabled()...
r40549 if not isenabled(repo):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 return orig(repo, subset, x)
# i18n: "filelog" is a keyword
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pat = revset.getstring(x, _(b"filelog requires a pattern"))
Rodrigo Damazio Bovendorp
scmutil: allowing different files to be prefetched per revision...
r45632 m = matchmod.match(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo.root, repo.getcwd(), [pat], default=b'relpath', ctx=repo[None]
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 s = set()
Rodrigo Damazio Bovendorp
scmutil: allowing different files to be prefetched per revision...
r45632 if not matchmod.patkind(pat):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 # slow
for r in subset:
ctx = repo[r]
cfiles = ctx.files()
for f in m.files():
if f in cfiles:
s.add(ctx.rev())
break
else:
# partial
files = (f for f in repo[None] if m(f))
for f in files:
fctx = repo[None].filectx(f)
s.add(fctx.linkrev())
for actx in fctx.ancestors():
s.add(actx.linkrev())
return smartset.baseset([r for r in subset if r in s])
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @command(b'gc', [], _(b'hg gc [REPO...]'), norepo=True)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def gc(ui, *args, **opts):
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """garbage collect the client and server filelog caches"""
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 cachepaths = set()
# get the system client cache
systemcache = shallowutil.getcachepath(ui, allowempty=True)
if systemcache:
cachepaths.add(systemcache)
# get repo client and server cache
repopaths = []
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pwd = ui.environ.get(b'PWD')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if pwd:
repopaths.append(pwd)
repopaths.extend(args)
repos = []
for repopath in repopaths:
try:
repo = hg.peer(ui, {}, repopath)
repos.append(repo)
repocache = shallowutil.getcachepath(repo.ui, allowempty=True)
if repocache:
cachepaths.add(repocache)
except error.RepoError:
pass
# gc client cache
for cachepath in cachepaths:
gcclient(ui, cachepath)
# gc server cache
for repo in repos:
remotefilelogserver.gcserver(ui, repo._repo)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def gcclient(ui, cachepath):
# get list of repos that use this cache
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repospath = os.path.join(cachepath, b'repos')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if not os.path.exists(repospath):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.warn(_(b"no known cache at %s\n") % cachepath)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 return
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 reposfile = open(repospath, b'rb')
Martin von Zweigbergk
cleanup: use set literals where possible...
r42224 repos = {r[:-1] for r in reposfile.readlines()}
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 reposfile.close()
# build list of useful files
validrepos = []
keepkeys = set()
sharedcache = None
filesrepacked = False
count = 0
Augie Fackler
formatting: blacken the codebase...
r43346 progress = ui.makeprogress(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"analyzing repositories"), unit=b"repos", total=len(repos)
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 for path in repos:
Martin von Zweigbergk
remotefilelog: use progress helper when analyzing repos...
r40875 progress.update(count)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 count += 1
try:
remotefilelog: use the right expandpath in to expand `~`...
r47707 path = util.expandpath(os.path.normpath(path))
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 except TypeError as e:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.warn(_(b"warning: malformed path: %r:%s\n") % (path, e))
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 traceback.print_exc()
continue
try:
peer = hg.peer(ui, {}, path)
repo = peer._repo
except error.RepoError:
continue
validrepos.append(path)
# Protect against any repo or config changes that have happened since
# this repo was added to the repos file. We'd rather this loop succeed
# and too much be deleted, than the loop fail and nothing gets deleted.
Pulkit Goyal
shallowutil: introduce a helper function isenabled()...
r40549 if not isenabled(repo):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 continue
safehasattr: drop usage in favor of hasattr...
r51821 if not hasattr(repo, 'name'):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.warn(
_(b"repo %s is a misconfigured remotefilelog repo\n") % path
)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 continue
# If garbage collection on repack and repack on hg gc are enabled
# then loose files are repacked and garbage collected.
# Otherwise regular garbage collection is performed.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repackonhggc = repo.ui.configbool(b'remotefilelog', b'repackonhggc')
gcrepack = repo.ui.configbool(b'remotefilelog', b'gcrepack')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if repackonhggc and gcrepack:
try:
repackmod.incrementalrepack(repo)
filesrepacked = True
continue
except (IOError, repackmod.RepackAlreadyRunning):
# If repack cannot be performed due to not enough disk space
# continue doing garbage collection of loose files w/o repack
pass
reponame = repo.name
if not sharedcache:
sharedcache = repo.sharedstore
# Compute a keepset which is not garbage collected
def keyfn(fname, fnode):
return fileserverclient.getcachekey(reponame, fname, hex(fnode))
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 keepkeys = repackmod.keepset(repo, keyfn=keyfn, lastkeepkeys=keepkeys)
Martin von Zweigbergk
remotefilelog: use progress helper when analyzing repos...
r40875 progress.complete()
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
# write list of valid repos back
oldumask = os.umask(0o002)
try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 reposfile = open(repospath, b'wb')
reposfile.writelines([(b"%s\n" % r) for r in validrepos])
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 reposfile.close()
finally:
os.umask(oldumask)
# prune cache
if sharedcache is not None:
sharedcache.gc(keepkeys)
elif not filesrepacked:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.warn(_(b"warning: no valid repos in repofile\n"))
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def log(orig, ui, repo, *pats, **opts):
Pulkit Goyal
shallowutil: introduce a helper function isenabled()...
r40549 if not isenabled(repo):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 return orig(ui, repo, *pats, **opts)
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 follow = opts.get('follow')
revs = opts.get('rev')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if pats:
# Force slowpath for non-follow patterns and follows that start from
# non-working-copy-parent revs.
if not follow or revs:
# This forces the slowpath
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 opts['removed'] = True
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
# If this is a non-follow log without any revs specified, recommend that
# the user add -f to speed it up.
if not follow and not revs:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 match = scmutil.match(repo[b'.'], pats, pycompat.byteskwargs(opts))
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 isfile = not match.anypats()
if isfile:
for file in match.files():
if not os.path.isfile(repo.wjoin(file)):
isfile = False
break
if isfile:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.warn(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"warning: file log can be slow on large repos - "
+ b"use -f to speed it up\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
return orig(ui, repo, *pats, **opts)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def revdatelimit(ui, revset):
"""Update revset so that only changesets no older than 'prefetchdays' days
are included. The default value is set to 14 days. If 'prefetchdays' is set
to zero or negative value then date restriction is not applied.
"""
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 days = ui.configint(b'remotefilelog', b'prefetchdays')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if days > 0:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 revset = b'(%s) & date(-%s)' % (revset, days)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 return revset
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def readytofetch(repo):
"""Check that enough time has passed since the last background prefetch.
This only relates to prefetches after operations that change the working
copy parent. Default delay between background prefetches is 2 minutes.
"""
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 timeout = repo.ui.configint(b'remotefilelog', b'prefetchdelay')
fname = repo.vfs.join(b'lastprefetch')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
ready = False
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 with open(fname, b'a'):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 # the with construct above is used to avoid race conditions
modtime = os.path.getmtime(fname)
if (time.time() - modtime) > timeout:
os.utime(fname, None)
ready = True
return ready
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def wcpprefetch(ui, repo, **kwargs):
"""Prefetches in background revisions specified by bgprefetchrevs revset.
Does background repack if backgroundrepack flag is set in config.
"""
Pulkit Goyal
shallowutil: introduce a helper function isenabled()...
r40549 shallow = isenabled(repo)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 bgprefetchrevs = ui.config(b'remotefilelog', b'bgprefetchrevs')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 isready = readytofetch(repo)
if not (shallow and bgprefetchrevs and isready):
return
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 bgrepack = repo.ui.configbool(b'remotefilelog', b'backgroundrepack')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 # update a revset with a date limit
bgprefetchrevs = revdatelimit(ui, bgprefetchrevs)
Kyle Lippincott
lock: pass "success" boolean to _afterlock callbacks...
r44217 def anon(unused_success):
safehasattr: drop usage in favor of hasattr...
r51821 if hasattr(repo, 'ranprefetch') and repo.ranprefetch:
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 return
repo.ranprefetch = True
repo.backgroundprefetch(bgprefetchrevs, repack=bgrepack)
repo._afterlock(anon)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def pull(orig, ui, repo, *pats, **opts):
result = orig(ui, repo, *pats, **opts)
Pulkit Goyal
shallowutil: introduce a helper function isenabled()...
r40549 if isenabled(repo):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 # prefetch if it's configured
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 prefetchrevset = ui.config(b'remotefilelog', b'pullprefetch')
bgrepack = repo.ui.configbool(b'remotefilelog', b'backgroundrepack')
bgprefetch = repo.ui.configbool(b'remotefilelog', b'backgroundprefetch')
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
if prefetchrevset:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status(_(b"prefetching file contents\n"))
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 revs = scmutil.revrange(repo, [prefetchrevset])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 base = repo[b'.'].rev()
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if bgprefetch:
remotefilelog: remove the `ensurestart` usage...
r44303 repo.backgroundprefetch(prefetchrevset, repack=bgrepack)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 else:
repo.prefetch(revs, base=base)
if bgrepack:
remotefilelog: remove the `ensurestart` usage...
r44303 repackmod.backgroundrepack(repo, incremental=True)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 elif bgrepack:
remotefilelog: remove the `ensurestart` usage...
r44303 repackmod.backgroundrepack(repo, incremental=True)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
return result
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def exchangepull(orig, repo, remote, *args, **kwargs):
# Hook into the callstream/getbundle to insert bundle capabilities
# during a pull.
Augie Fackler
formatting: blacken the codebase...
r43346 def localgetbundle(
orig, source, heads=None, common=None, bundlecaps=None, **kwargs
):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if not bundlecaps:
bundlecaps = set()
Augie Fackler
remotefilelog: consolidate and rename bundle2 capability...
r40544 bundlecaps.add(constants.BUNDLE2_CAPABLITY)
Augie Fackler
formatting: blacken the codebase...
r43346 return orig(
source, heads=heads, common=common, bundlecaps=bundlecaps, **kwargs
)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
safehasattr: drop usage in favor of hasattr...
r51821 if hasattr(remote, '_callstream'):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 remote._localrepo = repo
safehasattr: drop usage in favor of hasattr...
r51821 elif hasattr(remote, 'getbundle'):
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"...
r51682 extensions.wrapfunction(remote, 'getbundle', localgetbundle)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
return orig(repo, remote, *args, **kwargs)
Augie Fackler
formatting: blacken the codebase...
r43346
Rodrigo Damazio Bovendorp
scmutil: allowing different files to be prefetched per revision...
r45632 def _fileprefetchhook(repo, revmatches):
Pulkit Goyal
shallowutil: introduce a helper function isenabled()...
r40549 if isenabled(repo):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 allfiles = []
Rodrigo Damazio Bovendorp
scmutil: allowing different files to be prefetched per revision...
r45632 for rev, match in revmatches:
Joerg Sonnenberger
node: import symbols explicitly...
r46729 if rev == wdirrev or rev is None:
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 continue
ctx = repo[rev]
mf = ctx.manifest()
sparsematch = repo.maybesparsematch(ctx.rev())
for path in ctx.walk(match):
if (not sparsematch or sparsematch(path)) and path in mf:
allfiles.append((path, hex(mf[path])))
repo.fileservice.prefetch(allfiles)
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'debugremotefilelog',
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 [
(b'd', b'decompress', None, _(b'decompress the filelog first')),
],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg debugremotefilelog <path>'),
Augie Fackler
formatting: blacken the codebase...
r43346 norepo=True,
)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def debugremotefilelog(ui, path, **opts):
return debugcommands.debugremotefilelog(ui, path, **opts)
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'verifyremotefilelog',
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 [
(b'd', b'decompress', None, _(b'decompress the filelogs first')),
],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg verifyremotefilelogs <directory>'),
Augie Fackler
formatting: blacken the codebase...
r43346 norepo=True,
)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def verifyremotefilelog(ui, path, **opts):
return debugcommands.verifyremotefilelog(ui, path, **opts)
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'debugdatapack',
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'long', None, _(b'print the long hashes')),
(b'', b'node', b'', _(b'dump the contents of node'), b'NODE'),
Augie Fackler
formatting: blacken the codebase...
r43346 ],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg debugdatapack <paths>'),
Augie Fackler
formatting: blacken the codebase...
r43346 norepo=True,
)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def debugdatapack(ui, *paths, **opts):
return debugcommands.debugdatapack(ui, *paths, **opts)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @command(b'debughistorypack', [], _(b'hg debughistorypack <path>'), norepo=True)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def debughistorypack(ui, path, **opts):
return debugcommands.debughistorypack(ui, path)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @command(b'debugkeepset', [], _(b'hg debugkeepset'))
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def debugkeepset(ui, repo, **opts):
# The command is used to measure keepset computation time
def keyfn(fname, fnode):
return fileserverclient.getcachekey(repo.name, fname, hex(fnode))
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 repackmod.keepset(repo, keyfn)
return
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @command(b'debugwaitonrepack', [], _(b'hg debugwaitonrepack'))
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def debugwaitonrepack(ui, repo, **opts):
return debugcommands.debugwaitonrepack(repo)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @command(b'debugwaitonprefetch', [], _(b'hg debugwaitonprefetch'))
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def debugwaitonprefetch(ui, repo, **opts):
return debugcommands.debugwaitonprefetch(repo)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def resolveprefetchopts(ui, opts):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not opts.get(b'rev'):
revset = [b'.', b'draft()']
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 prefetchrevset = ui.config(b'remotefilelog', b'pullprefetch', None)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if prefetchrevset:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 revset.append(b'(%s)' % prefetchrevset)
bgprefetchrevs = ui.config(b'remotefilelog', b'bgprefetchrevs', None)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 if bgprefetchrevs:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 revset.append(b'(%s)' % bgprefetchrevs)
revset = b'+'.join(revset)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
# update a revset with a date limit
revset = revdatelimit(ui, revset)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 opts[b'rev'] = [revset]
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not opts.get(b'base'):
opts[b'base'] = None
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
return opts
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'prefetch',
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'r', b'rev', [], _(b'prefetch the specified revisions'), _(b'REV')),
(b'', b'repack', False, _(b'run repack after prefetch')),
(b'b', b'base', b'', _(b"rev that is assumed to already be local")),
Augie Fackler
formatting: blacken the codebase...
r43346 ]
+ commands.walkopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg prefetch [OPTIONS] [FILE...]'),
Rodrigo Damazio
help: adding a help category to narrow and remotefilelog commands...
r43451 helpcategory=command.CATEGORY_MAINTENANCE,
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def prefetch(ui, repo, *pats, **opts):
"""prefetch file revisions from the server
Prefetchs file revisions for the specified revs and stores them in the
local remotefilelog cache. If no rev is specified, the default rev is
used which is the union of dot, draft, pullprefetch and bgprefetchrev.
File names or patterns can be used to limit which files are downloaded.
Return 0 on success.
"""
Pulkit Goyal
py3: fix keyword arguments handling in hgext/remotefilelog/...
r40646 opts = pycompat.byteskwargs(opts)
Pulkit Goyal
shallowutil: introduce a helper function isenabled()...
r40549 if not isenabled(repo):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"repo is not shallow"))
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
opts = resolveprefetchopts(ui, opts)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 revs = scmutil.revrange(repo, opts.get(b'rev'))
repo.prefetch(revs, opts.get(b'base'), pats, opts)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
# Run repack in background
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'repack'):
remotefilelog: remove the `ensurestart` usage...
r44303 repackmod.backgroundrepack(repo, incremental=True)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
Augie Fackler
formatting: blacken the codebase...
r43346 @command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'repack',
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'background', None, _(b'run in a background process'), None),
(b'', b'incremental', None, _(b'do an incremental repack'), None),
Augie Fackler
formatting: blacken the codebase...
r43346 (
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'',
b'packsonly',
Augie Fackler
formatting: blacken the codebase...
r43346 None,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'only repack packs (skip loose objects)'),
Augie Fackler
formatting: blacken the codebase...
r43346 None,
),
],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg repack [OPTIONS]'),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def repack_(ui, repo, *pats, **opts):
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 if opts.get('background'):
Augie Fackler
formatting: blacken the codebase...
r43346 repackmod.backgroundrepack(
repo,
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 incremental=opts.get('incremental'),
packsonly=opts.get('packsonly', False),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 return
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 options = {b'packsonly': opts.get('packsonly')}
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
try:
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 if opts.get('incremental'):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 repackmod.incrementalrepack(repo, options=options)
else:
repackmod.fullrepack(repo, options=options)
except repackmod.RepackAlreadyRunning as ex:
# Don't propogate the exception if the repack is already in
# progress, since we want the command to exit 0.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo.ui.warn(b'%s\n' % ex)