aQc@sddlmZddlZddlZddlZddlZddlZddlZejZ dZ e ede Z dZ dZe\ZZdZdZd Ze ed dpeZd(Zd)ZdZdZdZdeddZdZdZdZe edeZdZdZ dZ!de"fdYZ#de#fd YZ$d!e"fd"YZ%d#ej&ej'fd$YZ(d%e#fd&YZ)d'Z*dS(*i(t_NcCs(|jddjddjddS(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|jddjddjddS(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 }tgtdD]}t|t|f^q5x9tdtdd|D]}d|t|>> 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('thequickshot') 'the~07quick~adshot' >>> dec('the~07quick~adshot') 'the\x07quick\xadshot' Rs\:*?"<>|ii i~is~%02xtAtZic3szd}xm|t|kruxTtddD]=}y#||||!V||7}PWq+tk rgq+Xq+Wtq WdS(Niii(tlentxrangetKeyError(tstitl(tdmap(s3/sys/lib/python2.7/site-packages/mercurial/store.pytdecodeTs  cs$djg|D]}|^q S(Nt(tjoin(R tc(tcmap(s3/sys/lib/python2.7/site-packages/mercurial/store.pyt`scsdjt|S(NR(Rtlist(R (R(s3/sys/lib/python2.7/site-packages/mercurial/store.pyRas(tordtdictR tchrtrangetlowert iteritems(tetxt winreservedtktv((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.pytdecodefilenamelscsgdD]}t|^q}tgtdD]}t|t|f^q/x9tdtdd|D]}d|t|>> f = _buildlowerencodefun() >>> f('nothing/special.txt') 'nothing/special.txt' >>> f('HELLO') 'hello' >>> f('hello:world?') 'hello~3aworld~3f' >>> f('thequickshot') 'the~07quick~adshot' s\:*?"<>|ii i~is~%02xRRics$djg|D]}|^q S(NR(R(R R(R(s3/sys/lib/python2.7/site-packages/mercurial/store.pyRs(RRR RRR(RR((Rs3/sys/lib/python2.7/site-packages/mercurial/store.pyt_buildlowerencodefunss 7$& t lowerencodetauxtcontprntnultcomtlptc Cs[xTt|D]F\}}|s%q n|rd|ddkrddt|d|d}||||' 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.iiit9t1i(t enumerateRtfindRt_winres3t_winres4(Rt dotencodeR tnR tec((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt _auxencodes$  , 'ixiiicCs}t|j}t|jdd}t||}|d}tjj|\}}g}d} x|d D]} | t } | ddkr| d d} n| dkrt | } n$| dt | } | t krPn|j | | } qsWdj |} t | dkr(| d7} nd| ||}t t |}|dkry|| }d| |||}n|S(Nt/iiis. Rsdh/(t_shat hexdigestR'tsplitR8tosRtsplitextt _dirprefixlenRt_maxshortdirslentappendRt_maxstorepathlen(RR5tdigesttletpartstbasenamet_roottexttsdirstsdirslentptdtttdirstrest spacelefttfiller((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt _hashencodes6         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 _hybridencodes  cCs{t|}t|tkr+t|tSt|jd}djt|t}t|tkrwt|tS|S(NR9( RRRBRRtTrueR"R<RR8(RtdeRSRO((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt _pathencodes   t pathencodecCs t|tS(N(RTtFalse(tf((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_plainhybridencode scCsRy4|jj}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 basicstorecBsVeZdZdZdZdZdZdZdZdZ dZ 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|jd}g}|jj|r)|g}|jj}x|r%|j}x||dtD]\} } } |d| } | tjkr| ddkrt j | |} |j t | | | j fq| tjkr|r|j | qqWqcWn|j|S(s!yields (unencoded, encoded, size)R9iR\is.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|jdtS(Ntdata(R~RU(Rl((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt datafilesBsccsHx|jD] }|Vq Wx%t|jdtD] }|Vq5WdS(s!yields (unencoded, encoded, size)RN(RtreversedR~RY(RlR((s3/sys/lib/python2.7/site-packages/mercurial/store.pytwalkEs cCsdgtjS(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|dr8tS|jdsT|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~RRRRR(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRes     t encodedstorecBs,eZdZdZdZdZRS(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[|jdtD]G\}}}yt|}Wntk rKd}nX|||fVqWdS(NR(R~RUR%R R`(Rltatbtsize((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRis "  cCs|jdt|S(NR9(RR#(RlRZ((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRqscCs+ddggtjD]}d|^qS(NRs 00changelog.isstore/(RR<(RlRZ((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRts (RRRnRRR(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyR_s  tfncachecBsPeZdZdZdZdZdZdZdZdZ RS(cCs||_d|_t|_dS(N(RbR`tentriesRYt_dirty(RlRb((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRn{s  cCst|_y|jddd}Wntk rBt|_dSXtt|jj|_d|jkr|j dxRt |D]A\}}|j dst d|d }t j|qqWn|jdS( s&fill the entries from the fncache fileRRctrbNRis s!invalid entry in fncache, line %si(RYRRbtIOErrortsetRRtreadt splitlinestseekR1trstripRR^tAborttclose(RlR}R6tlineRM((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_loads   ! cCs[|jdddd|}|rD|jtdj|dn|jt|_dS(NRRctwbt atomictemps (RbRRRRRYR(RltfilesRR}((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_writes # cCs#|j|tt||_dS(N(RRYRR(RlR((s3/sys/lib/python2.7/site-packages/mercurial/store.pytrewritescCs#|jr|j|jtndS(N(RRRRU(Rl((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRs cCsK|jdkr|jn||jkrGt|_|jj|ndS(N(RR`RRURtadd(Rltfn((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRs   cCs)|jdkr|jn||jkS(N(RR`R(RlR((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRs cCs)|jdkr|jnt|jS(N(RR`Rtiter(Rl((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt__iter__s ( RRRnRRRRRRR(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRxs       t _fncachevfscBs&eZdZddZdZRS(cCs)tjj||||_||_dS(N(RitauditvfsRnRtencode(RlRbtfncR((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRns trcOsM|dkr.|jdr.|jj|n|j|j||||S(NRRsdata/(Rsrb(t startswithRRRbR(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.pyRs(RRRnRR(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRs  t fncachestorecBsPeZdZdZdZdZdZdZdZdZ RS(cCs|rt}nt}||_||d}|j|_|jd|_t||_|j|_||_t |}||_ t ||||_ |j |_ dS(Ns/storeR9( RWR[RRfRtpathsepRdRgRhRRRbRk(RlRRmR5RRbR((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRns       cCs|j|j|S(N(RR(RlRZ((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRscCs|jj|jS(N(RhR\Rt(RlR((s3/sys/lib/python2.7/site-packages/mercurial/store.pytgetsizesccst}g}xt|jD]q}|j|}y(|||j|fV|j|Wqtk r}|jtjkrnt }qXqW|r|jj |ndS(N( RYtsortedRRRRARaterrnotENOENTRUR(RlRtexistingRZRSterr((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRscCs1d}ddgg|jD]}d|^qS(NsYdata dh fncache phaseroots obsstore 00manifest.d 00manifest.i 00changelog.d 00changelog.iRs 00changelog.isstore/(R<(RlRLRZ((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRs cCs|jjdS(N(RR(Rl((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRscCsW|j|}y|j|tSWn,tk rR}|jtjkrNntSXdS(N(RRRURaRRRY(RlRZRSR((s3/sys/lib/python2.7/site-packages/mercurial/store.pyt_existss cCsdjd|f}|d}||jkrA|j|rAtS|jds]|d7}nx3|jD](}|j|rg|j|rgtSqgWtS(s!Checks if the store contains pathR9Rs.i(RRRRURRRY(RlRR((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRs  ( RRRnRRRRRRR(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRs       cCsHd|kr;d|kr.t||d|kSt||St||S(NtstoreRR5(RRRe(t requirementsRRm((s3/sys/lib/python2.7/site-packages/mercurial/store.pyRs    (R(R)R*R+(R,R-(+ti18nRRiR^tparsersR=R\Rtsha1R:RtgetattrRRR!R"R$R#R%R&R`R'R3R4R8RBR?R@RRRTRWR[RdRtobjectReRRt abstractvfsRRRR(((s3/sys/lib/python2.7/site-packages/mercurial/store.pyts>$$    1    ,  &   A:M