Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�8�c@s�dZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZmZm
Z
mZddlmZddlmZddlZddlZd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zeed�Z d�Z!dd�Z#dd�Z$de%d�Z&d�Z'dd�Z(ieddded�dfddeed�fged�fd 6e(d!d"ged#�fgej)ed$�fd%6Z*ej+d&7_+dS('s=High-level command function for lfconvert, plus the cmdtable.i�N(	tutiltmatchthgtnodetcontextterrortcmdutiltscmutiltcommands(t_(treleasecs�|drt}n*t}tj|t|jd�dd�}tj|�shtj	t
d�|��ntj|�s�tj	t
d�|��ntj||��|jt
d�|�tj||dt�}t}d}	}
z�|j
�}	|j�}
�fd��jjd�j��dD�}itjtj6}|rt�}
t�}|s}|jtjd	dg�}n|r�tj�jd
t|��}nd}i}xh|D]`}|jt
d�|j�dt
d
�d�dj��t�||||
||||�q�W|jt
d�d�tjj |j!tj"��rkt#j$|j!tj"��nx�|j%�D]t}tjj&|j!|��r�tj'|j!|��ny&tj(tjj)|j!|���Wqxt*k
r�qxXqxW|
r�|j+j,d�|j-�q�nux\|D]T}|jt
d�|j�dt
d
�d�dj��t.|�|||�qW|jt
d�d�t}Wd|j/j0�t1|
|	�|s�t#j$|j�nXdS(sMconvert a normal repository to a largefiles repository

    Convert repository SOURCE to a new repository DEST, identical to
    SOURCE except that certain files will be converted as largefiles:
    specifically, any file that matches any PATTERN *or* whose size is
    above the minimum size threshold is converted as a largefile. The
    size used to determine whether or not to track a file as a
    largefile is the size of the first version of the file. The
    minimum size can be specified either with --size or in
    configuration as ``largefiles.size``.

    After running this command you will need to make sure that
    largefiles is enabled anywhere you intend to push the new
    repository.

    Use --to-normal to convert largefiles back to normal files; after
    this, the DEST repository can be used without largefiles at all.t	to_normaltsizetdefaults %s is not a local Mercurial reposinitializing destination %s
tcreatec3s|]}�|VqdS(N((t.0tctx(trsrc(s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pys	<genexpr>Gsitpatternstsconverting revisionstunittrevisionttotalttipt
largefilesN(2tFalsetTruetlfutilt
getminsizetgettNoneRtislocalRtAbortR	t
repositorytstatustwlocktlockt	changelogtnodesbetweentheadsRtnullidtsett
configlisttlongnametmatch_Rtroottlisttprogresstrevt_lfconvert_addchangesettostpathtexiststwjoint	shortnametshutiltrmtreetkeystisfiletunlinkt
removedirstdirnametOSErrortrequirementstaddt_writerequirementst
_addchangesettdirstatetclearR
(tuitsrctdesttpatstoptsttolfileRtrdsttsuccesstdstwlocktdstlocktctxstrevmaptlfilestnormalfilestmatchertlfiletohashRtf((Rs?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt	lfconvertsp
	$
		!
&




c	s�t���}t�|�������fd�}g}xC�D];}tj|�rt|jtj|��qF|j|�qFWt||�||��dS(Nc	s�tj|��kr�y�jtj|��}Wntjk
rMt�nX|j�}|rvtj|d�}n|j�j	�}tj
�|�}|dkrt���j
��tj
�|�}|dkrtjtd�|t
j�j
��f��qnd}d}zt|d�}|j�}Wd|rO|j�nXtj||d|j�kd|j�k|�St|j�|��SdS(Nis'missing largefile '%s' from revision %sRtrbtltx(RtstandintfilectxRtLookupErrortIOErrortrenamedtsplitstandintdatatstriptfindfileRtcachelfilesRRR R	thextopentreadtcloseRt
memfilectxtflagst_getnormalcontextRE(	trepotmemctxRUtfctxR^thashR3R`tfd(RtfilesRPRRE(s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt
getfilectx�s6
	%(t_convertparentst_getchangedfilesRt	isstandintappendR_t_commitcontext(	RERRKRRPtparentsRqtdstfilestfile((RRpRPRREs?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyRB{s&
c	
s�t���}	t�|	�}
g}xN|
D]F}||kr||krt|�||�}
|�j�kr�j|�}|j�}|o�|d|k}|
|O}
d|j�kr�r�tjt	d�|��nt
}
q�|
r|j|�q|j|�n||krd|jt
j|��|�j�krq�j|�}d|j�kr�|j�}|r�|d|kr�tjt	d�|��q�ntjd�}|j�|j��|j�}|�ks�||kra|j|�|j��|j��d�|j�k}t
j|t
j|�||�|�|<qaqqq+|j|�q+W���fd�}t||	�||��dS(NiRXs+renamed/copied largefile %s becomes symlinkslargefile %s becomes symlinkRRYcs�tj|�r�tj|�}y�j|�}Wntjk
rMt�nX|j�}|rvtj|d�}nt	j
|�|dd|j�kd|j�k|�St|j
�|��SdS(Nis
RXRY(RRtR_R[RR\R]R^RZRRhRiRjRE(RkRlRUtsrcfnameRmR^(RRTRP(s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyRq�s
"(RrRst_islfiletmanifestR[R^RiRR R	RR@RuRRZtsha1tupdateR`t	hexdigesttwwritetwritestandinRv(RRKRRPRQRRRSRRTRwRpRxRUtislfileRmR^trenamedlfiletmRnt
executableRq((RRTRPs?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyR1�sP

	
'c	Csutj|||j�|||j�|j�|j��}|j|�}|j|�|jj	�||j
�<dS(N(RRltdescriptiontusertdatetextrat	commitctxt
setparentsR%RR(RKRwRRxRqRPtmctxtret((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyRv�s
$
cCs�t|j��}tj|kr�|j�}|j�dj�}|j�dj�}|t|�t|�Bt|�O}xY|D]N}|||j|d�ks�|||j|d�kr�|j|�q�q�Wn|S(Nii(	R)RpRR(R|RwRRR@(RRwRptmctmp1tmp2RU((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyRss$
8cCsag}x+|j�D]}|j||j��qWx&t|�dkr\|jtj�q7W|S(Ni(RwRuRtlenR((RRPRwtp((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyRrscCs�y|j|�}Wntjk
r/t�nX|j�}|rO|d}n|j�}|dkr|t|||�}ntj||d|j	�kd|j	�k|�S(Nis.hgtagsRXRY(
R[RR\R]R^R`t_converttagsRRhRi(RERRURPRmR^R`((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyRjs

cCsg}x�j�D]�y|jdd�\}}Wn+tk
rb|jtd|��qnXytj|�}Wn+tk
r�|jtd|��qnXy(|jdtj	||�|f�Wqt
k
r�|jtd�|�qqXqWdj|�S(Nt is&skipping incorrectly formatted tag %s
s%skipping incorrectly formatted id %s
s%s %s
sno mapping for id %s
R(t
splitlinestsplitt
ValueErrortwarnR	Rtbint	TypeErrorRuRdtKeyErrortjoin(RERPR`tnewdatatlinetidtnametnewid((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyR�,s*


cCs|dks$|dks$|dkr(tS|r>||�r>tSy%|j|�j�|ddkSWntjk
rztSXdS(slReturn true if file should be considered a largefile, i.e.
    matcher matches it or it is larger than size.s.hgtagss	.hgignores.hgsigsiN(RRR[RRR\(RyRRSR((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyR{Cs$%c	s|s
dStj||dt�}d}|jdt|��|j|��t�fd�|�}|jdt|��x�|D]|}|jtd�|dd	d
t|��t	j
||�}|s�jtd�|��n|j
||�|d7}q�W|jtd�d�dS(
s&upload largefiles to the central storeNtputis,sending statlfile command for %d largefiles
cs	�|S(N((th(tretval(s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt<lambda>[ss"%d largefiles need to be uploaded
suploading largefilesRt	largefileRs6largefile %s missing from store (needs to be uploaded)i(t	basestoret
_openstoreRtdebugR�R4tfilterR/R	RRbRR R�R(RERRKRptstoretatRntsource((R�s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pytuploadlfilesPs$


cCsF|rtt|��}n	dg}tj|�}|j|d|�S(s)Verify that every largefile revision in the current changeset
    exists in the central store.  With --contents, also verify that
    the contents of each local largefile file revision are correct (SHA-1 hash
    matches the revision ID).  With --all, check every changeset in
    this repository.t.tcontents(trangeR�R�R�tverify(RERktallR�trevsR�((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pytverifylfilesjs
	cCs{tj||�}xbt|jj��D]K\}}d|dd@tj@}|jd|d||d|f�q(WdS(s2Show basic information for the largefiles dirstates%3oii�s%c %s %10d %s
iiN(Rtopenlfdirstatetsortedt_mapt	iteritemsRtumasktwrite(RERkt
lfdirstatetfile_tenttmode((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt
debugdirstatezs"cCs�tj||�}|r1t|�t|�@}ng}x�|D]�}y'||tj|�j�j�}Wn.tk
r�}|jtjkr�q>n�nXtj	||�s>|j
||f�q>q>W|r�j|�}	|	j
|�}
|
SggfS(s.cachelfiles ensures that all largefiles needed by the specified revision
    are present in the repository's largefile cache.

    returns a tuple (cached, missing).  cached is the list of files downloaded
    by this operation; missing is the list of files that were needed but could
    not be found.(Rt
listlfilesR)RZR`RaR]terrnotENOENTRbRuR�R�R(RERkRtfilelistRQttogettlfiletexpectedhashterrR�R�((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyRc�s$
'c
Cs�tj|d|jtj�gi�}d�}d}d}|gkr�xhtj||i|d6|�D]D}t|||j	��\}}	|t
|�7}|t
|	�7}qiWn|jtd�|�|dkr�jtd�|�n||fS(NcSsdS(N((Rtfns((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pytprepare�siR0s %d additional largefiles cached
s!%d largefiles failed to download
(
RRRR5RR6RtwalkchangerevsRcRR�R"R	(
RERkR0tmatchfnR�ttotalsuccessttotalmissingRRLtmissing((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pytdownloadlfiles�s
	
cCs�|j�}zptj||�}ttj|��t|�B}|dk	rtg|D]}||krS|^qS}nt}|r�|r�|jtd��t	}t
||d|�nd\}	}
x�|D]y}t|||�}|r|dkr�|7}	q|
|8}
n|r�|
s|	r�|r�|jtd��t	}q�q�W|j�|r{|r{|jtd�|	|
f�nWd|j
�XdS(Nsgetting changed largefiles
is"%d largefiles updated, %d removed
(ii(R#RR�R)R�RRR"R	RRct_updatelfileR�R
(RERkR�tprintmessageR#R�RQRUtprintedtupdatedtremovedti((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pytupdatelfiles�s4(




c	Cs\d}|j|�}|jtj|��}tjj|�rltjj|d�r~tjj|�r~tj||d�ntj||�}|dkr&tjj|�s�|tj	|�kr&tj
|||�s||dkr�j
|dt�n|j|�dS|j|�d}ntj|�j}|tj|�jkr�tj||�d}q�nDtjj|�r�|jj|�|dkr�tj
|�d}n|jtj|�}|dkrt|dt�r�j|�qX|j|�nT|d	kr |j|�n8|d
kr<|j|�n|dkrX|j|�n|S(
s(updates a single largefile and copies the state of its standin from
    the repository's dirstate to its state in the lfdirstate.

    returns 1 if the file was modified, -1 if the file was removed, 0 if the
    file was unchanged, and None if the needed largefile was missing from the
    cache.is.origRt
ignoremissingii�tnt_isrebasingtrtat?N(R5RRZR2R3R4R7tcopyfiletreadstandinthashfilet
copyfromcacheRRt
unlinkpathRtnormallookuptnormaltstattst_modetchmodRCt	normalizetgetattrRtremoveR@tdrop(	RkR�R�R�tabslfilet
absstandint
expecthashR�tstate((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyR��sJ(

	
	R
c	Ks�||_|jdg�}|s9tjtd���ntj||�}d}xM|D]E}|jtd�|�t|||�\}}|t	|�7}qXW|j
td�|�dS(s0pull largefiles for the specified revisions from the specified source

    Pull largefiles that are referenced from local changesets but missing
    locally, pulling from a remote repository to the local cache.

    If SOURCE is omitted, the 'default' path will be used.
    See :hg:`help urls` for more information.

    .. container:: verbose

      Some examples:

      - pull largefiles for all branch heads::

          hg lfpull -r "head() and not closed()"

      - pull largefiles on the default branch::

          hg lfpull -r "branch(default)"
    R0sno revisions specifiedis#pulling largefiles for revision %s
s%d largefiles cached
N(tlfpullsourceRRR R	RtrevrangetnoteRcR�R"(	RERkR�RIR�t	numcachedR0tcachedR�((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pytlfpulls	
tsRRs9minimum size (MB) for files to be converted as largefilestSIZEs	to-normals/convert from a largefiles repo to a normal repos#hg lfconvert SOURCE DEST [FILE ...]RVR�R0s#pull largefiles for these revisionss--r REV... [-e CMD] [--remotecmd CMD] [SOURCE]R�s
 lfconvert(,t__doc__R2R�R7t	mercurialRRR,RRRRRRRtmercurial.i18nR	tmercurial.lockR
RR�RVRBR1RvRsRrRjR�R{R�RR�R�RRcR�RR�R�R�t
remoteoptstcmdtablet	inferrepo(((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt<module>	sJ@	c	6	M		
					
		"	<%			

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].