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

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


��Qc@s�ddlmZddlZddlZddlZddlZddlZddlZejZ	d�Z
eede
�Zd�Z
d�Ze�\ZZd�Zd�Zd	�Zeed
d�p�e�Zd(Zd)Zd�ZdZdZdeddZd�Zd�Zd�Zeede�Zd�Zd�Z dZ!de"fd��YZ#de#fd ��YZ$d!e"fd"��YZ%d#ej&ej'fd$��YZ(d%e#fd&��YZ)d'�Z*dS(*i�(t_NcCs(|jdd�jdd�jdd�S(sI
    >>> _encodedir('data/foo.i')
    'data/foo.i'
    >>> _encodedir('data/foo.i/bla.i')
    'data/foo.i.hg/bla.i'
    >>> _encodedir('data/foo.i.hg/bla.i')
    'data/foo.i.hg.hg/bla.i'
    >>> _encodedir('data/foo.i\ndata/foo.i/bla.i\ndata/foo.i.hg/bla.i\n')
    'data/foo.i\ndata/foo.i.hg/bla.i\ndata/foo.i.hg.hg/bla.i\n'
    s.hg/s.hg.hg/s.i/s.i.hg/s.d/s.d.hg/(treplace(tpath((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt
_encodedirst	encodedircCs8d|kr|S|jdd�jdd�jdd�S(s�
    >>> decodedir('data/foo.i')
    'data/foo.i'
    >>> decodedir('data/foo.i.hg/bla.i')
    'data/foo.i/bla.i'
    >>> decodedir('data/foo.i.hg.hg/bla.i')
    'data/foo.i.hg/bla.i'
    s.hg/s.d.hg/s.d/s.i.hg/s.i/s.hg.hg/(R(R((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt	decodedir"s	csGd}gdD]}t|�^q
}tgtd�D]}t|�t|�f^q5��x9td�tdd�|D]}d|�t|�<qzWxTttd�td	�d
�t|�gD]&}|t|�j��t|�<q�Wi�x$�j�D]\}}|�|<qW�fd���fd��fd
�fS(s�
    >>> enc, dec = _buildencodefun()

    >>> enc('nothing/special.txt')
    'nothing/special.txt'
    >>> dec('nothing/special.txt')
    'nothing/special.txt'

    >>> enc('HELLO')
    '_h_e_l_l_o'
    >>> dec('_h_e_l_l_o')
    'HELLO'

    >>> enc('hello:world?')
    'hello~3aworld~3f'
    >>> dec('hello~3aworld~3f')
    'hello:world?'

    >>> enc('thequick�hot')
    'the~07quick~adshot'
    >>> dec('the~07quick~adshot')
    'the\x07quick\xadshot'
    Rs\:*?"<>|ii i~is~%02xtAtZic3szd}xm|t|�kruxTtdd�D]=}y#�||||!V||7}PWq+tk
rgq+Xq+Wt�q	WdS(Niii(tlentxrangetKeyError(tstitl(tdmap(s3/sys/lib/python2.7/site-packages/mercurial/store.pytdecodeTs

cs$djg|D]}�|^q
�S(Nt(tjoin(Rtc(tcmap(s3/sys/lib/python2.7/site-packages/mercurial/store.pyt<lambda>`scsdjt�|���S(NR(Rtlist(R(R(s3/sys/lib/python2.7/site-packages/mercurial/store.pyRas(tordtdictR	tchrtrangetlowert	iteritems(tetxtwinreservedtktv((RRRs3/sys/lib/python2.7/site-packages/mercurial/store.pyt_buildencodefun2s7$3$cCstt|��S(s}
    >>> encodefilename('foo.i/bar.d/bla.hg/hi:world?/HELLO')
    'foo.i.hg/bar.d.hg/bla.hg.hg/hi~3aworld~3f/_h_e_l_l_o'
    (t_encodefnameR(R((s3/sys/lib/python2.7/site-packages/mercurial/store.pytencodefilenameescCstt|��S(s}
    >>> decodefilename('foo.i.hg/bar.d.hg/bla.hg.hg/hi~3aworld~3f/_h_e_l_l_o')
    'foo.i/bar.d/bla.hg/hi:world?/HELLO'
    (Rt_decodefname(R((s3/sys/lib/python2.7/site-packages/mercurial/store.pytdecodefilenamelscs�gdD]}t|�^q}tgtd�D]}t|�t|�f^q/��x9td�tdd�|D]}d|�t|�<qtWxCttd�td�d	�D]"}t|�j��t|�<q�W�fd
�S(s�
    >>> f = _buildlowerencodefun()
    >>> f('nothing/special.txt')
    'nothing/special.txt'
    >>> f('HELLO')
    'hello'
    >>> f('hello:world?')
    'hello~3aworld~3f'
    >>> f('thequick�hot')
    'the~07quick~adshot'
    s\:*?"<>|ii i~is~%02xRRics$djg|D]}�|^q
�S(NR(R(RR(R(s3/sys/lib/python2.7/site-packages/mercurial/store.pyR�s(RRR	RRR(RR((Rs3/sys/lib/python2.7/site-packages/mercurial/store.pyt_buildlowerencodefunss7$& tlowerencodetauxtcontprntnultcomtlptcCs[xTt|�D]F\}}|s%q
n|rd|ddkrddt|d�|d}|||<n�|jd�}|dkr�t|�}n|dkr�|d tks�dkr |dd	kr |dd
kr |d tkr dt|d�}|dd!||d}|||<n|ddkr
|d dt|d�||<q
q
W|S(s�
    Encodes filenames containing names reserved by Windows or which end in
    period or space. Does not touch other single reserved characters c.
    Specifically, c in '\:*?"<>|' or ord(c) <= 31 are *not* encoded here.
    Additionally encodes space or period at the beginning, if dotencode is
    True. Parameter path is assumed to be all lowercase.
    A segment only needs encoding if a reserved name appears as a
    basename (e.g. "aux", "aux.foo"). A directory or file named "foo.aux"
    doesn't need encoding.

    >>> s = '.foo/aux.txt/txt.aux/con/prn/nul/foo.'
    >>> _auxencode(s.split('/'), True)
    ['~2efoo', 'au~78.txt', 'txt.aux', 'co~6e', 'pr~6e', 'nu~6c', 'foo~2e']
    >>> s = '.com1com2/lpt9.lpt4.lpt1/conprn/com0/lpt0/foo.'
    >>> _auxencode(s.split('/'), False)
    ['.com1com2', 'lp~749.lpt4.lpt1', 'conprn', 'com0', 'lpt0', 'foo~2e']
    >>> _auxencode(['foo. '], True)
    ['foo.~20']
    >>> _auxencode([' .foo'], True)
    ['~20.foo']
    is. s~%02xit.i�iit9t1i(t	enumerateRtfindRt_winres3t_winres4(Rt	dotencodeRtnR
tec((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt
_auxencode�s$
,
'ixiiicCs}t|�j�}t|�jd�d}t||�}|d}tjj|�\}}g}d}	x�|d D]�}
|
t }|ddkr�|d d}n|	dkr�t	|�}n$|	dt	|�}|t
kr�n|j|�|}	qsWdj|�}
t	|
�dkr(|
d7}
nd|
||}t
t	|�}|dkry|| }d|
|||}n|S(Nt/ii�is. Rsdh/(t_shat	hexdigestR'tsplitR8tosRtsplitextt
_dirprefixlenRt_maxshortdirslentappendRt_maxstorepathlen(RR5tdigesttletpartstbasenamet_roottexttsdirstsdirslentptdtttdirstrest	spacelefttfiller((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_hashencode�s6





cCsat|�}t|�jd�}djt||��}t|�tkr]t||�}n|S(seencodes path with a length limit

    Encodes all paths that begin with 'data/', according to the following.

    Default encoding (reversible):

    Encodes all uppercase letters 'X' as '_x'. All reserved or illegal
    characters are encoded as '~xx', where xx is the two digit hex code
    of the character (see encodefilename).
    Relevant path components consisting of Windows reserved filenames are
    masked by encoding the third character ('aux' -> 'au~78', see _auxencode).

    Hashed encoding (not reversible):

    If the default-encoded path is longer than _maxstorepathlen, a
    non-reversible hybrid hashing of the path is done instead.
    This encoding uses up to _dirprefixlen characters of all directory
    levels of the lowerencoded path, but not more levels than can fit into
    _maxshortdirslen.
    Then follows the filler followed by the sha digest of the full path.
    The filler is the beginning of the basename of the lowerencoded path
    (the basename is everything after the last path separator). The filler
    is as long as possible, filling in characters from the basename until
    the encoded path has _maxstorepathlen characters (or all chars of the
    basename have been taken).
    The extension (e.g. '.i' or '.d') is preserved.

    The string 'data/' at the beginning is replaced with 'dh/', if the hashed
    encoding was used.
    R9(RR"R<RR8RRBRR(RR5tefRO((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt
_hybridencode�scCs{t|�}t|�tkr+t|t�St|�jd�}djt|t��}t|�tkrwt|t�S|S(NR9(	RRRBRRtTrueR"R<RR8(RtdeRSRO((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_pathencodes

t
pathencodecCs
t|t�S(N(RTtFalse(tf((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_plainhybridencode
scCsRy4|j�j}dtj@d|@kr3d}nWntk
rMd}nX|S(Ni�(tstattst_modetutiltumasktNonetOSError(tvfstmode((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt	_calcmodes


sNdata 00manifest.d 00manifest.i 00changelog.d 00changelog.i phaseroots obsstoret
basicstorecBsVeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	s&base class for local repository storescCsa||�}|j|_t|�|_|j|_||_tj|t�|_|j|_	dS(N(
tbaseRRdt
createmodetrawvfstscmutilt	filtervfsRRbtopener(tselfRtvfstypeRb((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt__init__ s	cCs|jdt|�S(NR9(RR(RlRZ((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR)scCs7|j}|r |d|7}nt|j�d}g}|jj|�r)|g}|jj}x�|r%|j�}x�||dt�D]�\}	}
}|d|	}|
tjkr�ddkr�j
||�}
|jt|
�|
|j
f�q�|
tjkr�|r�|j|�q�q�WqcWn|j�|S(s!yields (unencoded, encoded, size)R9iR\i�s.ds.i(s.ds.i(RRRhtisdirtreaddirtpopRUR\tS_IFREGR^tpconvertRARtst_sizetS_IFDIRtsort(RltrelpathtrecurseRtstriplenR
tvisitRpRKRZtkindtsttfpR6((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_walk,s&			""
cCs|jdt�S(Ntdata(R~RU(Rl((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt	datafilesBsccsHx|j�D]}|Vq
Wx%t|jdt��D]}|Vq5WdS(s!yields (unencoded, encoded, size)RN(R�treversedR~RY(RlR((s3/sys/lib/python2.7/site-packages/mercurial/store.pytwalkEs	cCsdgtj�S(Ntrequires(t_dataR<(Rl((s3/sys/lib/python2.7/site-packages/mercurial/store.pytcopylistNscCsdS(N((Rl((s3/sys/lib/python2.7/site-packages/mercurial/store.pytwriteQscCsmdjd|f�}tjj|j|d��r8tS|jd�sT|d}ntjj|j|��S(s!Checks if the store contains pathR9Rs.i(RR=RtexistsRUtendswith(RlR((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt__contains__Ts
(t__name__t
__module__t__doc__RnRR~R�R�R�R�R�(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRes									tencodedstorecBs,eZd�Zd�Zd�Zd�ZRS(cCse||d�}|j|_t|�|_|j|_||_tj|t�|_|j|_	dS(Ns/store(
RfRRdRgRhRiRjR#RbRk(RlRRmRb((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRn`s	ccsbx[|jdt�D]G\}}}yt|�}Wntk
rKd}nX|||fVqWdS(NR(R~RUR%R
R`(Rltatbtsize((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR�is"

cCs|jdt|�S(NR9(RR#(RlRZ((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRqscCs+ddggtj�D]}d|^qS(NR�s
00changelog.isstore/(R�R<(RlRZ((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR�ts	(R�R�RnR�RR�(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR�_s				tfncachecBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCs||_d|_t|_dS(N(RbR`tentriesRYt_dirty(RlRb((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRn{s		cCs�t|_y|jddd�}Wntk
rBt�|_dSXtt|j��j��|_d|jkr�|j	d�xRt
|�D]A\}}|jd�s�td�|d	}t
j|��q�q�Wn|j�dS(
s&fill the entries from the fncache fileR�RctrbNRis
s!invalid entry in fncache, line %si(RYR�RbtIOErrortsetR�Rtreadt
splitlinestseekR1trstripRR^tAborttclose(RlR}R6tlineRM((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_load�s	
!
cCs[|jdddd|�}|rD|jtdj|�d��n|j�t|_dS(NR�Rctwbt
atomictemps
(RbR�RRR�RYR�(RltfilesR�R}((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_write�s
#
cCs#|j|t�t|�|_dS(N(R�RYR�R�(RlR�((s3/sys/lib/python2.7/site-packages/mercurial/store.pytrewrite�scCs#|jr|j|jt�ndS(N(R�R�R�RU(Rl((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR��s	cCsK|jdkr|j�n||jkrGt|_|jj|�ndS(N(R�R`R�RUR�tadd(Rltfn((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR��s

	cCs)|jdkr|j�n||jkS(N(R�R`R�(RlR�((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR��s
cCs)|jdkr|j�nt|j�S(N(R�R`R�titer(Rl((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt__iter__�s
(
R�R�RnR�R�R�R�R�R�R�(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR�xs							t_fncachevfscBs&eZd�Zdd�Zd�ZRS(cCs)tjj||�||_||_dS(N(RitauditvfsRnR�tencode(RlRbtfncR�((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRn�s	trcOsM|dkr.|jd�r.|jj|�n|j|j|�|||�S(NR�R�sdata/(R�srb(t
startswithR�R�RbR�(RlRRctargstkw((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt__call__�scCs3|r|jj|j|��S|jj|�SdS(N(RbRR�(RlR((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR�s(R�R�RnR�R(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR��s	tfncachestorecBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCs�|rt}nt}||_||d�}|j|_|jd|_t|�|_|j|_||_t	|�}||_	t
|||�|_|j|_dS(Ns/storeR9(
RWR[R�RfRtpathsepRdRgRhR�R�RbRk(RlRRmR5R�RbR�((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRn�s				cCs|j|j|�S(N(R�R�(RlRZ((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR�scCs|jj|�jS(N(RhR\Rt(RlR((s3/sys/lib/python2.7/site-packages/mercurial/store.pytgetsize�sccs�t}g}x�t|j�D]q}|j|�}y(|||j|�fV|j|�Wqtk
r�}|jtjkr��nt	}qXqW|r�|jj
|�ndS(N(RYtsortedR�R�R�RARaterrnotENOENTRUR�(RlR�texistingRZRSterr((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR��scCs1d}ddgg|j�D]}d|^qS(NsYdata dh fncache phaseroots obsstore 00manifest.d 00manifest.i 00changelog.d 00changelog.iR�s
00changelog.isstore/(R<(RlRLRZ((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR��s	cCs|jj�dS(N(R�R�(Rl((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR��scCsW|j|�}y|j|�tSWn,tk
rR}|jtjkrN�ntSXdS(N(R�R�RURaR�R�RY(RlRZRSR�((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_exists�s
cCs�djd|f�}|d}||jkrA|j|�rAtS|jd�s]|d7}nx3|jD](}|j|�rg|j|�rgtSqgWtS(s!Checks if the store contains pathR9Rs.i(RR�R�RUR�R�RY(RlRR((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR�s

(
R�R�RnRR�R�R�R�R�R�(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR��s							cCsHd|kr;d|kr.t||d|k�St||�St||�S(NtstoreR�R5(R�R�Re(trequirementsRRm((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR�s

(R(R)R*R+(R,R-(+ti18nRRiR^tparsersR=R\R�tsha1R:RtgetattrRRR!R"R$R#R%R&R`R'R3R4R8RBR?R@RRRTRWR[RdR�tobjectReR�R�tabstractvfsR�R�R�R�(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt<module>s>$$				1				,		&	
		A: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].