HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/hgext/remotefilelog/__pycache__/__init__.cpython-310.pyc
o

�]LbĤ�	@sLdZddlmZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddl
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*dd	l+m,Z,mZm-Z-m.Z.m/Z/m0Z0m1Z2m3Z3m4Z4m5Z5m6Z6m7Z7ej8iZ9e#�8e9�Z8iZ:e#�;e:�Z;e;d
ddd
�e;d
ddd
�e;d
ddd
�e;d
ddd
�e;d
ddd
�e;d
ddd
�e;d
ddd
�e;d
dej<dgd�e;d
ddd
�e;d
ddd
�e;d
ddd
�e;d
ddd
�e;d
ddd
�e;d
d dd
�e;d
d!dd
�e;d
d"dd
�e;d
d#dd
�e;d
d$d%d
�e;d
d&d'd
�e;d
d(d)d
�e;d
d*d+d
�e;d
d,d-d
�e;d
d.ej<�e;d
d/dd
�e;d
d0dd
�e;d
d1dd
�e;d
d2dd
�e;d
d3dd
�e;d4d5d6d6d7�e;d8d9dd
�e;d8d:d;d
�e;d<d=dd
�d>Z=e;d
d?e=d
�e;d
d@dAd
�fe;d
dBgdC�d
�e;d
dDdEd
�e;d
dFdGd
�e;d
dHdId
�e;d
dJdAd
�fe;d
dKdIgd
�e;d
dLdEd
�e;d
dMdNd
�e;d
dOdId
�dPZ>ej?Z@e@jA�Be,jC�e6jDZDdQdR�ZEdSdT�ZFdUdV�ZGdWdX�ZHdYdZ�ZId[d\�ZJd]d^�ZKd_d`�ZLdadb�ZMdcdd�ZNd�dedf�ZOdgdh�ZPdidj�ZQd�dkdl�ZRd�dmdn�ZSdodp�ZTd�dqdr�ZUdaVdsdt�ZWd�dudv�ZXdwdx�ZYe8dyge
dz�d6d{�d|d}��ZZd~d�Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbe8d�d�d�de
d��fge
d��d6d{�d�d���Zce8d�d�d�de
d��fge
d��d6d{�d�d���Zde8d�dd�de
d��fdd�de
d��d�fge
d��d6d{�d�d���Zee8d�ge
d��d6d{�d�d���Zfe8d�ge
d���d�d���Zge8d�ge
d���d�d���Zhe8d�ge
d���d�d���Zid�d��Zje8d�d�d�ge
d��e
d��fdd4de
d��fd�d�de
d��fgejke
d��e8jld��d�d���Zme8d4dd�de
dÃdfdd�de
dŃdfdd�de
dǃdfge
dȃ�d�dʄ�ZndS)�aremotefilelog causes Mercurial to lazilly fetch file contents (EXPERIMENTAL)

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.

Configs:

    ``packs.maxchainlen`` specifies the maximum delta chain length in pack files

    ``packs.maxpacksize`` specifies the maximum pack file size

    ``packs.maxpackfilecount`` specifies the maximum number of packs in the
      shared cache (trees only for now)

    ``remotefilelog.backgroundprefetch`` runs prefetch in background when True

    ``remotefilelog.bgprefetchrevs`` specifies revisions to fetch on commit and
      update, and on other commands that use them. Different from pullprefetch.

    ``remotefilelog.gcrepack`` does garbage collection during repack when True

    ``remotefilelog.nodettl`` specifies maximum TTL of a node in seconds before
      it is garbage collected

    ``remotefilelog.repackonhggc`` runs repack on hg gc when True

    ``remotefilelog.prefetchdays`` specifies the maximum age of a commit in
      days after which it is no longer prefetched.

    ``remotefilelog.prefetchdelay`` specifies delay between background
      prefetches in seconds after operations that change the working copy parent

    ``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.

    ``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).

    ``remotefilelog.data.maxrepackpacks`` the maximum number of pack files to
      include in an incremental data repack.

    ``remotefilelog.data.repackmaxpacksize`` the maximum size of a pack file for
      it to be considered for an incremental data repack.

    ``remotefilelog.data.repacksizelimit`` the maximum total size of pack files
      to include in an incremental data repack.

    ``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.

    ``remotefilelog.history.generations`` list for specifying the lower bound of
      each generation of the history pack files. For example, list [
      '100MB', '1MB'] or ['1MB', '100MB'] will lead to three generations: [
      0, 1MB), [1MB, 100MB) and [100MB, infinity).

    ``remotefilelog.history.maxrepackpacks`` the maximum number of pack files to
      include in an incremental history repack.

    ``remotefilelog.history.repackmaxpacksize`` the maximum size of a pack file
      for it to be considered for an incremental history repack.

    ``remotefilelog.history.repacksizelimit`` the maximum total size of pack
      files to include in an incremental history repack.

    ``remotefilelog.backgroundrepack`` automatically consolidate packs in the
      background

    ``remotefilelog.cachepath`` path to cache

    ``remotefilelog.cachegroup`` if set, make cache directory sgid to this
      group

    ``remotefilelog.cacheprocess`` binary to invoke for fetching file data

    ``remotefilelog.debug`` turn on remotefilelog-specific debug output

    ``remotefilelog.excludepattern`` pattern of files to exclude from pulls

    ``remotefilelog.includepattern`` pattern of files to include in pulls

    ``remotefilelog.fetchwarning``: message to print when too many
      single-file fetches occur

    ``remotefilelog.getfilesstep`` number of files to request in a single RPC

    ``remotefilelog.getfilestype`` if set to 'threaded' use threads to fetch
      files, otherwise use optimistic fetching

    ``remotefilelog.pullprefetch`` revset for selecting files that should be
      eagerly downloaded rather than lazily

    ``remotefilelog.reponame`` name of the repo. If set, used to partition
      data from other repos in a shared store.

    ``remotefilelog.server`` if true, enable server-side functionality

    ``remotefilelog.servercachepath`` path for caching blobs on the server

    ``remotefilelog.serverexpiration`` number of days to keep cached server
      blobs

    ``remotefilelog.validatecache`` if set, check cache entries for corruption
      before returning blobs

    ``remotefilelog.validatecachelog`` if set, check cache entries for
      corruption before returning metadata

�)�absolute_importN)�hex�wdirrev)�_)�open)�changegroup�	changelog�commands�configitems�context�copies�
debugcommands�dispatch�error�exchange�
extensions�hg�	localrepo�match�merge�
mergestate�patch�pycompat�	registrar�repair�repoview�revset�scmutil�smartset�streamclone�util�)�	constantsr
�fileserverclient�
remotefilectx�
remotefilelog�remotefilelogserver�repack�
shallowbundle�shallowrepo�shallowstore�shallowutil�shallowverifier�
remotefilelogsdebugF)�defaultsreponame�s	cachepaths
cachegroupscacheprocessscacheprocess.includepaths
cachelimits1000 GBsfallbackpath)r-sfallbackrepo)r.�aliassvalidatecachelogs
validatecacheson�serversservercachepathsserverexpiration��backgroundrepack�bgprefetchrevs�pullprefetch�backgroundprefetch�
prefetchdelay�x�prefetchdays�sstrip.includefiles�allsgetfilesstepi'sgetfilestypes
optimistics	batchsizesfetchwarningsincludepatternsexcludepattern�gcrepack�repackonhggc�repackschainorphansbysizeT)r.�experimentalspackssmaxpacksizesmaxchainleni�sdevelsremotefilelog.bg-waiti�'snodettlsdata.gencountlimit�sdata.generations)s1GB�100MBs1MBsdata.maxrepackpacks�2sdata.repackmaxpacksizes4GBsdata.repacksizelimitrAshistory.gencountlimitshistory.generationsshistory.maxrepackpacksshistory.repackmaxpacksizes400MBshistory.repacksizelimitsships-with-hg-corecCs�tj�tj�t�tjdt	�}|d�dddt
d�f�t�tjdtj�t�tjdtj
�t�tjd	t�t�tjd
t�dd�}t�tjd
|�d#dd�}t�d|�t�tjdt�tjt_t�tdtj�t�tdtj�t�tdt�t�td
t�t�tdt�t�tdt�t�t j!dt"�t�t#dt$�t�t%dt&�t�t'dt(�t�t)dt*�t�t j+dt,�t�t j!dt-�t�t.dt/�t�tdt0�t#j1�2d t3�t�t#d!t4�t�t5d"t6�t5j7t5j8d"<dS)$zUWraps user facing Mercurial commands to swap them out with shallow
    versions.
    scloner!r/sshallowNs5create a shallow clone which uses remote file historys
debugindexs
debugindexdotslog�pullc_s8t|�r|�d�rt�td���|||g|�Ri|��S)Nr;s(--all is not supported in a shallow repo)�	isenabled�getr�Abortr)�orig�ui�repo�args�opts�rL�>/usr/lib/python3/dist-packages/hgext/remotefilelog/__init__.py�	_manifest&szuisetup.<locals>._manifestsmanifestFcSsDd}zt�d�}Wn	tyYnw|r |�tj�|t_dSdS)N�lfs)r�find�KeyError�wrapfilelogr%r#�_lfsmod)�loaded�lfsmodrLrLrM�
_lfsloaded/s�
�zuisetup.<locals>._lfsloadedrOs	debugdatas_addchangegroupfilessmakechangegroups	makestoresapplyupdatess_checkunknownfiless_checklookups_findrenamess_computeforwardmissings
runcommands_collectbrokencsetssfilectxstrydiffsverifyr-sgetrenamedfnsfilelog�F)9r�wirepeersetupfuncs�appendr#�	peersetupr�wrapcommandr	�table�cloneshallowrr
�
debugindex�
debugindexdot�log�pull�afterloaded�debugdatashallowr(�shallowcg1packerr�cgpacker�wrapfunction�addchangegroupfiles�makechangegroupr�storewrapperr�exchangepullr�applyupdates�checkunknownfilesr�
workingctx�checklookupr�findrenamesr�computeforwardmissingr�
runcommandr�_collectbrokencsets�	changectx�filectx�workingfilectxr�trydiff�_verify�fileprefetchhooks�add�_fileprefetchhook�getrenamedfnr�
filelogrevset�filelog�symbols)rH�entryrNrVrLrLrM�uisetups`��	
�
�

���r�c	s�|�d�r1g��fdd�}t�td|�dd���fdd�}t�td	|�ddd�}t�td
|�z&|||g|�Ri|��W|�d�rT�D]}t�|d�rS|j��qFdSdS|�d�rm�D]}t�|d�rl|j��q_ww)N�shallowcs�t|�sR��|���t|j|���t|tj�r&|jjd|��jf|j_|j	�
tj�|�
��
t�|�Wd�n1sAwYt||g|�Ri|��S||g|�Ri|��S�Nr)rDrY�
unfiltered�setupclientrH�
isinstancer�	__class__�	__bases__�requirementsryr"�SHALLOWREPO_REQUIREMENT�lockr�writereporequirementsrj)rG�selfrJ�kwargs)�reposrLrM�pull_shallowas
�
�z"cloneshallow.<locals>.pull_shallowrCcs ��fdd�}t��d|�dS)NcsX���}tj|vr)i}�jrd��j�|d<�jr!d��j�|d<�jdi|��S|�S)N��includepattern�excludepattern�stream_out_shallow)r�)�capabilitiesr"�NETWORK_CAP_LEGACY_SSH_GETFILESr��joinr��_callstream)rG�capsrK��remoterIrLrM�stream_out_shallow�s
zAcloneshallow.<locals>.setup_streamout.<locals>.stream_out_shallows
stream_out)rrf)rIr�r�rLr�rM�setup_streamout~sz%cloneshallow.<locals>.setup_streamoutcs�|j|j�||�S�N)rIr�)rG�op)r�rLrM�stream_wrap�sz!cloneshallow.<locals>.stream_wrapsmaybeperformlegacystreamcloneFcSs`d|j�dg�vrdd�|jdD�|jd<|rdS|||d�\}}|dur,|�tj�||fS)N�v2sstreamcSsg|]}|dkr|�qS)r�rL)�.0�crLrLrM�
<listcomp>�sz?cloneshallow.<locals>.canperformstreamclone.<locals>.<listcomp>)FN)�bundle2)�remotebundle2capsrEryr"r�)rG�pullopr��	supportedr�rLrLrM�canperformstreamclone�s�z+cloneshallow.<locals>.canperformstreamclonescanperformstreamclonesfileservicerW)	rErrfrrr �safehasattr�fileservice�close)	rGrHrIrJrKr�r�r��rrL)r�r�rMr]]s:
�
�

��
�
��r]cOs8tjj}zdd�tj_||i|��W|tj_S|tj_w)NcSsdS)Nr!rL)�xrLrLrM�<lambda>�sz"debugdatashallow.<locals>.<lambda>)r%�__len__)rGrJ�kwds�oldlenrLrLrMrc�s
rccCsr|��sdS|�ddt�|�ddt�|�dd�}t|�}|r&|r&td��|r-t||�|r7t�||�dSdS)Nshookssupdate.prefetchscommit.prefetchr-r1s+Cannot be both a server and shallow client.)	�local�	setconfig�wcpprefetch�
configboolrD�RuntimeErrorr�r&�setupserver)rHrI�isserverenabled�isshallowclientrLrLrM�	reposetup�s
�r�cCs>t|tj�sdSt�|�t|�t�|�t�	|j
�|_
dSr�)r�r�localrepositoryr&�onetimesetup�onetimeclientsetupr)�wraprepor*�	wrapstore�store)rHrIrLrLrMr��s

r�cCs$||||�}tj|vrt�|�}|Sr�)r"r�r*r�)rGr��path�vfstype�srLrLrMri�s

ric
Ksjt|�r(|��}g}	|�tjg�D]\}
}}|	�|
t||
�f�q|j�|	�|||||||fi|��Sr�)	rD�manifest�
getactions�
mergestatemod�
ACTION_GETrYrr��prefetch)
rGrI�mresult�wctx�mctx�	overwrite�wantfiledatarKr��files�frJ�msgrLrLrMrk�srkcOs�t|�rRg}|�|���}	|��D]:\}
\}}}
|	r|	|
�sq|tjtjtjfvr6|�|
t	|�
|
��f�q|tjkrK|d}|�|t	|�
|��f�q|j�
|�||||||g|�Ri|��Sr�)rD�maybesparsematch�rev�filemapr��ACTION_CREATED�ACTION_DELETED_CHANGED�ACTION_CREATED_MERGErYr�filenode�ACTION_LOCAL_DIR_RENAME_GETr�r�)rGrIr�r��forcer�rJr�r��sparsematchr��m�
actionargsr��f2rLrLrMrl�s$�
�rlc	Cs`|j}t|�r*g}|jD]}|D]}||vr"|�|t|�|��f�qq|j�|�||||�Sr�)�_reporD�_parentsrYrr�r�r�)rGr�r��mtime_boundaryrI�
prefetchfiles�parentr�rLrLrMrns
��rnc
Osht|�r&g}|d��}|D]}	|	|vr|�|	t||	�f�q|j�|�|||||g|�Ri|��S)N�.)rDr�rYrr�r�)
rGrI�matcher�added�removedrJr�r��pmfr�rLrLrMros�rocCs�||||d�}|j}t|�rA|��}g}|�|���}|r;t�}	|D]}
||
�r8|�|
t||
�f�|	�|
�q"|	}|j	�
|�|S)N)r)r�rDr�r�r��setrYrryr�r�)rG�a�br�missingrI�mbr�r��
sparsemissingr�rLrLrMrp&s 
�rpcOsPd}|rt|�r|j}z|||g|�Ri|��W|r|��SS|r'|��wwr�)rDr�r�)rG�luirIrJr�r�rLrLrMrq<s
�
�rqcs*t��rt�fdd�|D��}|�||�S)Ncsg|]	}��|�s|�qSrL)�shallowmatch�r�r��rIrLrMr�Msz'_collectbrokencsets.<locals>.<listcomp>)rD�list)rGrIr��striprevrLr�rMrrKsrrcCsN|dur	|�|�}t|j�r|j�|�rtj|j||||d�S|||||d�S)N)�fileidrsr})r�r})r�rDr�r�r$)rGr�r�r�r}rLrLrMrtRs
�rtcCs8t|j�r|j�|�rtj|j|||d�S||||d�S)N)rmr})r})rDr�r�r$�remoteworkingfilectx)rGr�r�r}rLrLrMru\s

�ruc

Os�t|�rEg}|��}
|||D].}||
vr(|	||���}|r(|�|t|�f�||vr>|	||���}|r>|�|t|�f�q|j�|�||||||||||	g	|
�Ri|��Sr�)rDr�r�rYrr�r�)rGrI�revs�ctx1�ctx2�modifiedr�r��copy�
getfilectxrJr�r��mf1�fname�fnoderLrLrMrves:��
��rvcCs,|��}zt�|���W|��S|��wr�)r�r,�verify�release)rGrI�levelr�rLrLrMrw�srwcsRtrdSdag�		d�fdd�	}t�tjd|��fdd�}t�tjd|�dS)	NTcsHt|t�r��|||||||||	|
f
�|S||||||||||	|
d�
S)N)�
_metatuple)r��intrY)rGr��rawtext�transaction�link�p1�p2�node�flags�
cachedeltar��pendingfilecommitsrLrM�addrawrevision�s6

���z*onetimeclientsetup.<locals>.addrawrevisionsaddrawrevisioncs�t|�}||g|�Ri|��}t|�}||krD�D])}|\
}}	}
}}}
}}}}|�|�}||kr>|�|	|
|||
||||�	qt�d��ntdd��D��dkrTt�d���dd�=|S)Ns4pending multiple integer revisions are not supportedcSsh|]}|d�qS)�rL)r�r�rLrLrM�	<setcomp>��z;onetimeclientsetup.<locals>.changelogadd.<locals>.<setcomp>r!)�lenr	rr�ProgrammingError)rGr�rJr�r�r	�newlen�oldargsr`�rt�trrrr�n�flr�r��linknoderrLrM�changelogadd�s&
��
�
z(onetimeclientsetup.<locals>.changelogaddsadd�NN)�
clientonetimerrfr%r)rHrrrLrrMr��s�+�r�cs2t��r	t���r|�|�Si���fdd�}|S)Ncs�|��|i�vr�||Sz/�|�|�}|��D]}|��|kr2|��}|o+|d�||��<q|��}|o<|dWStjyHYdSw)z�looks up all renames for a file (up to endrev) the first
        time the file is given. It indexes on the changerev and only
        parses the manifest if linkrev != changerev.
        Returns rename info for fn at changerev rev.rN)�
setdefaultrt�	ancestorsr��renamedr�r�LookupError)�fnr��fctx�ancestorr ��rcacherIrLrM�
getrenamed�s��z getrenamedfn.<locals>.getrenamed)rDr�usechangesetcentricalgo)rGrI�endrevr'rLr%rMr{�s

r{cst|�s
||||�St�|td��}tj|j|��|gd|dd��t��t�	|�sL|D]}||}|�
�}��
�D]}||vrI��|���nq:q,n,�fdd�|dD�}	|	D]}|d�
|�}
��|
���|
��D]	}��|���qmqYt��fdd�|D��S)	a``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()``.
    sfilelog requires a patternsrelpathN)r.�ctxc3s�|]	}�|�r|VqdSr�rLr�)r�rLrM�	<genexpr>1s�z filelogrevset.<locals>.<genexpr>csg|]}|�vr|�qSrLrL�r�r�)r�rLrMr�8�z!filelogrevset.<locals>.<listcomp>)rDr�	getstringr�matchmodr�root�getcwdr��patkindr�ryr�rt�linkrevrr�baseset)rGrI�subsetr��patr�r*�cfilesr�r�r#�actxrL)r�r�rMr|s4	�
���	�r|sgcshg gc [REPO...])�norepoc	Os�t�}tj|dd�}|r|�|�g}|j�d�}|r |�|�|�|�g}|D])}zt�	|i|�}	|�|	�tj|	j
dd�}
|
rG|�|
�Wq)tjyRYq)w|D]}t
||�qU|D]	}	t�||	j�q_dS)z4garbage collect the client and server filelog cachesT)�
allowemptysPWDN)r�r+�getcachepathry�environrErY�extendr�peerrHr�	RepoError�gcclientr&�gcserverr�)rHrJrK�
cachepaths�systemcache�	repopaths�pwdr��repopathrI�	repocache�	cachepathrLrLrM�gc;s4




���rIcs^tj�|d�}tj�|�s|�td�|�dSt|d�}dd�|��D�}|��g}t	�}d}d}d}	|j
td�dt|�d	�}
|D]�}|
�|	�|	d
7}	zt
�tj�|��}Wn!tyz}z|�td�||f�t��WYd}~qCd}~wwzt�|i|�}
|
j}Wn
tjy�YqCw|�|�t|�s�qCt
�|d�s�|�td
�|�qC|j�dd�}|j�dd�}|r�|r�z	t�|�d}WqCttj fy�Ynw|j!�|s�|j"}�fdd�}tj#|||d�}qC|
�$�t�%d�}zt|d�}|�&dd�|D��|��Wt�%|�nt�%|�w|du�r!|�'|�dS|�s-|�td��dSdS)Nsrepossno known cache at %s
srbcSsh|]}|dd��qS)N���rLr,rLrLrMrir-zgcclient.<locals>.<setcomp>Frsanalyzing repositories)�unit�totalr!swarning: malformed path: %r:%s
snames.repo %s is a misconfigured remotefilelog repo
r-r=r<Tcst��|t|��Sr�)r#�getcachekeyr�r�r���reponamerLrM�keyfn�szgcclient.<locals>.keyfn)rQ�lastkeepkeysr@swbcSsg|]}d|�qS)�%s
rLr,rLrLrMr��rzgcclient.<locals>.<listcomp>s$warning: no valid repos in repofile
)(�osr�r��exists�warnrr�	readlinesr�r��makeprogressr�updater �
expandpath�normpath�	TypeError�	traceback�	print_excrr>r�rr?rYrDr�rHr��	repackmod�incrementalrepack�IOError�RepackAlreadyRunning�name�sharedstore�keepset�complete�umask�
writelinesrI)rHrH�	repospath�	reposfiler��
validrepos�keepkeys�sharedcache�
filesrepacked�count�progressr��er>rI�repackonhggc�gcrepackrQ�oldumaskrLrOrMr@as�
�
��
�

�
�



�r@c
Os�t|�s|||g|�Ri|��S|�d�}|�d�}|rX|r |r$d|d<|sX|sXt�|d|t�|��}|��}|rO|��D]}	tj	�
|�|	��sNd}nq?|rX|�t
d��|||g|�Ri|��S)N�followr�Tr�r�FsEwarning: file log can be slow on large repos - use -f to speed it up
)rDrErrr�byteskwargs�anypatsr�rTr��isfile�wjoinrVr)
rGrHrI�patsrKrur�rrx�filerLrLrMr`�s.


���r`cCs$|�dd�}|dkrd||f}|S)z�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.
    r-r9rs(%s) & date(-%s))�	configint)rHr�daysrLrLrM�revdatelimit�sr~cCs�|j�dd�}|j�d�}d}t|d��'tj�|�}t��||kr3t�	|d�d}Wd�|SWd�|S1s>wY|S)z�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.
    r-r7slastprefetchF�aNT)
rHr|�vfsr�rrTr��getmtime�time�utime)rI�timeoutr��ready�modtimerLrLrM�readytofetch�s
��
��r�csbt��}|�dd��t��}|r�r|sdS�j�dd��t|������fdd�}��|�dS)z�Prefetches in background revisions specified by bgprefetchrevs revset.
    Does background repack if backgroundrepack flag is set in config.
    r-r4Nr3cs.t��d�r�jrdSd�_�j��d�dS)NsranprefetchT�r')r r��ranprefetch�backgroundprefetch)�unused_success��bgprefetchrevs�bgrepackrIrLrM�anonszwcpprefetch.<locals>.anon)rD�configr�rHr�r~�
_afterlock)rHrIr�r��isreadyr�rLr�rMr�s
r�cOs�|||g|�Ri|��}t|�r`|�dd�}|j�dd�}|j�dd�}|rW|�td��t�||g�}	|d��}
|rE|j	||d�|S|j
|	|
d�|rUtj|d	d
�|S|r`tj|d	d
�|S)Nr-r5r3r6sprefetching file contents
r�r�)�baseT��incremental)
rDr�rHr��statusrr�revranger�r�r�r_�backgroundrepack)rGrHrIrzrK�result�prefetchrevsetr��
bgprefetchr�r�rLrLrMras&��racOsR	ddd�}t�|d�r||_n
t�|d�rt�|d|�|||g|�Ri|��S)Nc[s.|st�}|�tj�||f|||d�|��S)N)�heads�common�
bundlecaps)r�ryr"�BUNDLE2_CAPABLITY)rG�sourcer�r�r�r�rLrLrM�localgetbundle4s���z$exchangepull.<locals>.localgetbundles_callstreams	getbundle)NNN)r r��
_localreporrf)rGrIr�rJr�r�rLrLrMrj1s
�
rjc	Cs�t|�rJg}|D]9\}}|tks|durq||}|��}|�|���}|�|�D]}|r1||�r@||vr@|�|t||�f�q)q|j�	|�dSdSr�)
rDrr�r�r��walkrYrr�r�)	rI�
revmatches�allfilesr�rr*�mfr�r�rLrLrMrzFs���rzsdebugremotefilelog�ds
decompresssdecompress the filelog firstshg debugremotefilelog <path>cK�tj||fi|��Sr�)r
�debugremotefilelog�rHr�rKrLrLrMr�U�	r�sverifyremotefilelogsdecompress the filelogs firsts#hg verifyremotefilelogs <directory>cKr�r�)r
�verifyremotefilelogr�rLrLrMr�ar�r�s
debugdatapackslongsprint the long hashessnodesdump the contents of nodesNODEshg debugdatapack <paths>cOstj|g|�Ri|��Sr�)r
�
debugdatapack)rH�pathsrKrLrLrMr�ms
r�sdebughistorypackshg debughistorypack <path>cKst�||�Sr�)r
�debughistorypackr�rLrLrMr�zsr�sdebugkeepsetshg debugkeepsetcs�fdd�}t��|�dS)Ncst��j|t|��Sr�)r#rMrcrrNr�rLrMrQ�szdebugkeepset.<locals>.keyfn)r_re)rHrIrKrQrLr�rM�debugkeepsetsr�sdebugwaitonrepackshg debugwaitonrepackcK�
t�|�Sr�)r
�debugwaitonrepack�rHrIrKrLrLrMr���
r�sdebugwaitonprefetchshg debugwaitonprefetchcKr�r�)r
�debugwaitonprefetchr�rLrLrMr��r�r�cCs�|�d�s8ddg}|�ddd�}|r|�d|�|�ddd�}|r)|�d|�d�|�}t||�}|g|d<|�d	�sAd|d	<|S)
N�revr�sdraft()r-r5s(%s)r4�+�base)rEr�rYr�r~)rHrKrr�r�rLrLrM�resolveprefetchopts�s




r�sprefetch�rr�s prefetch the specified revisionssREVsrun repack after prefetch�br�s'rev that is assumed to already be localshg prefetch [OPTIONS] [FILE...])�helpcategorycOsrt�|�}t|�st�td���t||�}t�||�	d��}|�
||�	d�||�|�	d�r7tj|dd�dSdS)atprefetch 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.
    srepo is not shallowr�r�r>Tr�N)
rrvrDrrFrr�rr�rEr�r_r�)rHrIrzrKr�rLrLrMr��s


�r�s
backgroundsrun in a background processsincrementalsdo an incremental repack�	packsonlys&only repack packs (skip loose objects)shg repack [OPTIONS]c
Os�|�d�rtj||�d�|�dd�d�dSd|�d�i}z|�d�r-tj||d�WdStj||d�WdStjyR}z|j�d|�WYd}~dSd}~ww)	N�
backgroundr��	packsonlyF)r�r�r�)�optionsrS)rEr_r�r`�
fullrepackrbrHrV)rHrIrzrKr��exrLrLrM�repack_�s 

�
��r�r�r)o�__doc__�
__future__rrTr�r]�mercurial.noderr�mercurial.i18nr�mercurial.pycompatr�	mercurialrrr	r
rrr
�hgdebugcommandsrrrrrrrr/rrr�rrrrrrrrrr �r"r#r$r%r&r'r_r(r)r*r+r,�command�cmdtable�configtable�
configitem�dynamicdefault�
_defaultlimit�
testedwithr��	repoclass�_basesupportedryr�rDr�r]rcr�r�rirkrlrnrorprqrrrtrurvrwrr�r{r|rIr@r`r~r�r�rarjrzr�r�r�r�r�r�r�r��walkopts�CATEGORY_MAINTENANCEr�r�rLrLrLrM�<module>sBxp8

�
�QV	
	




	
/
W(
%^#��
��
��
	

	

���
���