cZX ddlmZddlmZmZmZmZmZddlm Z m Z ej dZ ejdZejZee jZnejZdZGdd ZGd d eZeGd d eZdSdS) )_)errorpathutilpolicytxnutilutil)docketv2parsersdirstateNicveZdZdZdZdZdZdZddZdZ dZ dZ d Z d Z dd Zed ZdZdZdS)_dirstatemapcommonz Methods that are identical for both implementations of the dirstatemap class, with and without Rust extensions enabled. Nc||_||_||_||_||_d|_d|_d|_d|_d|_ d|_ dS)NsdirstateF) _use_dirstate_v2_nodeconstants_ui_opener_root _filename_nodelen_parents _dirtyparents_docket _pendingmode)selfuiopenerroot nodeconstantsuse_dirstate_v2s 7/usr/lib/python3/dist-packages/mercurial/dirstatemap.py__init__z_dirstatemapcommon.__init__.s[ /+  $  " !c|jdS)z5Loads the underlying data, if it's not already loadedN_maprs r"preloadz_dirstatemapcommon.preload=s  r$c8|j||SN)r'get)rkeydefaults r"r,z_dirstatemapcommon.getAsy}}S'***r$c*t|jSr+)lenr'r(s r"__len__z_dirstatemapcommon.__len__Ds49~~r$c*t|jSr+iterr'r(s r"__iter__z_dirstatemapcommon.__iter__GsDIr$c||jvSr+r&)rr-s r" __contains__z_dirstatemapcommon.__contains__Jsdir$c|j|Sr+r&)ritems r" __getitem__z_dirstatemapcommon.__getitem__Msyr$ctj|j|j|j\}}|j@|j|kr5|tjtd||_|S)Ns1working directory state may be changed parallelly) r trypendingrrrrcloserAbortr)rfpmodes r"_opendirstatefilez$_dirstatemapcommon._opendirstatefileRsr%dj$,OOD   (T->$-F-F HHJJJ+FGG ! r$c |5}||cdddS#1swxYwYdS#t$rYdSwxYw)Nr$)rAreadFileNotFoundError)rsizer?s r"_readdirstatefilez$_dirstatemapcommon._readdirstatefile\s '')) %Rwwt}} % % % % % % % % % % % % % % % % % %    33 s-A8 A<A<A AAc|jsW|jstjdtj||j|_|jS)Ns'dirstate only has a docket in v2 format) rrrProgrammingError docketmodDirstateDocketparserGrr(s r"r z_dirstatemapcommon.docketdsi| ( ,>%399&&(($*=DL|r$c` j}tjt ||}|j|jkrtjd| j || | | |jrH| d fd }|r!d|jz}|||n ||_dS)Nsdirstate docket name collisionc8jSr+)runlink)_tr data_filenamers r"z7_dirstatemapcommon.write_v2_no_append..sdl&9&9-&H&Hr$sdirstate-v2-clean-r+)r rJrK with_new_uuidparentsr0uuidrrIrQrwrite serializer= addpostcloser) rtrstmetapacked old_docket new_docketrOcategoryrQs ` @r"write_v2_no_appendz%_dirstatemapcommon.write_v2_no_appendps#[ -;; LLNNCKK   ?jo - -()JKK K"0022  =&111 %%''(((   ? &4466MHHHHHHF 0:?B&1111! r$c|js|jr|jj|_n|jdz}||}t |}||kr,|d|j||jd|jzf|_nE|dkr|jj|jjf|_n!tj td|jS)Ns(working directory state appears damaged!) rrr rTrrGr0rnullidrr>r)rread_lenrZls r"rTz_dirstatemapcommon.parentss} $  $ 3 =1,++H55GG==?T]?+4=1t}+<<=%DMM!VV+2+2%DMM  +EFF}r$r+)rB)__name__ __module__ __qualname____doc__r'copymapr#r)r,r1r5r7r:rArGpropertyr r`rTr$r"rr#s DG ! ! !++++      X """8r$rc.eZdZdZedZedZdZdZeZ dZ dZ dd Z d Z d Zed ZddZd dZedZedZdZdZedZedZ d!dZdZdZdZdZdZdZd S)" dirstatemapaMap encapsulating the dirstate's contents. The dirstate contains the following state: - `identity` is the identity of the dirstate file, which can be used to detect when changes have occurred to the dirstate file. - `parents` is a pair containing the parents of the working copy. The parents are updated by calling `setparents`. - the state map maps filenames to tuples of (state, mode, size, mtime), where state is a single character representing 'normal', 'added', 'removed', or 'merged'. It is read by treating the dirstate as a dict. File state is updated by calling various methods (see each documentation for details): - `reset_state`, - `set_tracked` - `set_untracked` - `set_clean` - `set_possibly_dirty` - `copymap` maps destination filenames to their source filename. The dirstate also provides the following views onto the state: - `filefoldmap` is a dict mapping normalized filenames to the denormalized form that they appear as in the dirstate. - `dirfoldmap` is a dict mapping normalized directory names to the denormalized form that they appear as in the dirstate. cFi|_||jSr+)r'rDr(s r"r'zdirstatemap._maps  yr$c,i|_|j|jSr+)rkr'r(s r"rkzdirstatemap.copymaps  |r$cf|j|j||jj|jjt j|dt j|dt j|dt j|ddS)N_dirs_alldirss filefoldmap dirfoldmap)r'clearrk setparentsrrdrclearcachedpropertyr(s r"rvzdirstatemap.clears   +2D4G4NOOO  x000  {333  ~666  }55555r$c4|jSr+r'itemsr(s r"r{zdirstatemap.itemssy   r$c#xK|D]"\}}||j|j|j|jfV#dS)z Return an iterator of (filename, state, mode, size, mtime) tuples `all` is unused when Rust is not enabled N)r{stater@rFmtime)rallfilenamer9s r" debug_iterzdirstatemap.debug_itersT !%  K K XtTZDItzJ J J J J K Kr$c4|jSr+)r'keysr(s r"rzdirstatemap.keyssy~~r$Fc||f|_d|_i}|r\|jD]B\}}|jr6|j|d}|r|||<|C|SNT)rrr'r{p2_inforkpopdrop_merge_data)rp1p2fold_p2copiesfssources r"rwzdirstatemap.setparentssR !  ( )) ( (19(!\--a66F+$*q %%''' r$cvtj|j|j|_|jr@|jj sdS|j |j }n| }|sdStj tdr/tt!|dz|_|jrO|jj}|jj}tjt*j}||j|j||n5tjtj}||j|j|}|js |j||jj|_|jj|_|jj|_dS)Nsdict_new_presizedG)rfilestatfrompathrjoinridentityrr rUrDrQrG safehasattrr dict_new_presizedr0r'rT tree_metadatanogcr parse_dirstaterkrrwr7r:r,)rrZpr[rs r"rDzdirstatemap.reads .. L  dn - -      *;# ""4;#<#<#>#>??BB''))B  F  G%9 : : A 11#b''R-@@DI   < #A;,D!Yr'899N N49dlB = = = =!Yw'=>>Nty$,;;A! DOQ  !I2909=r$cZ|jr;tj|j|j\}}|||||nat |j|j|}||| d|_ dSNF) rr pack_dirstater'rkr`r rTrVr=r)rrYrZr\r[s r"rVzdirstatemap.write9s   +DIt|DDLFD  # #BD& 9 9 9 9** 4<F HHV    HHJJJ"r$c|j|jSr+r'rr(s r"rzdirstatemap.identityEs }r$Nc||jr#d|jvr|j||%d|jvr|j|dSdSdS)z,increment the dirstate counter if applicableN_dirs_alldirs)removed__dict__raddpathr)rr old_entrys r" _dirs_incrzdirstatemap._dirs_incrMsq  !2 && J  x ( ( (  t}!* %%h///  , dm ; ; M ! !( + + + DM ) )]8,,F    . . . . . * )r$c tj}||jtjtjS#t $rYnwxYwi}tj}|jD]\}}|j s||||<d|d<|S)zeReturns a dictionary mapping normalized case paths to their non-normalized versions. .) r make_file_foldmapr'r normcasespecnormcasefallbackAttributeErrorrr{r)rmakefilefoldmaprrnamers r"rzdirstatemap.filefoldmapcs  %7O#? 4,d.C     D  =y(( ) )GD!9 )$(((4..!$s 4 AAcRi}tj}|jD]}||||<|Sr+)rrrrrrrs r" dirfoldmapzdirstatemap.dirfoldmapys9 =J % %D $Ahhtnn  r$c||jvS)zo Returns True if the dirstate contains a tracked (not removed) file in this directory. )rrds r" hastrackeddirzdirstatemap.hastrackeddirs DJr$c||jvS)zn Returns True if the dirstate contains a file (tracked or removed) in this directory. )rrs r"hasdirzdirstatemap.hasdirs DM!!r$c8tj|jdS)NT) only_trackedrdirsr'r(s r"rzdirstatemap._dirss}TYT::::r$c4tj|jSr+rr(s r"rzdirstatemap._alldirss}TY'''r$Tct|j|d|sL|sJ|sH|j|}|||||dS|j|}|||t|||||}||j|<dS)ahSet a entry to a given state, diregarding all previous state This is to be used by the part of the dirstate API dedicated to adjusting the dirstate after a update/merge. note: calling this might result to no entry existing at all if the dirstate map does not see any point at having one for this file anymore. N)r) wc_tracked p1_trackedrhas_meaningful_mtimeparentfiledata)rkrr'r, _drop_entryrr DirstateItem) rrrrrrrrentrys r" reset_statezdirstatemap.reset_states( 4((( g   h//I   X & & & OOH O : : : FIMM(++  ),,,!!!5)    $ (r$cd}||}|2||td}||j|<d}nt|jsC|||||||d}n*|||||S)NFT)r)r,rrr'tracked set_tracked_refresh_entryset_possibly_dirty)rrnewrs r"rzdirstatemap.set_trackeds"" = OOH % % % E#(DIh CC 1 OOHe , , ,         % 0 0 0CC  $ $ & & &   % 0 0 0 r$c ||}|dS||||j |js|j|d||||dS)z4Mark a file as no longer tracked in the dirstate mapNF)rrT)r,raddedrrkr set_untrackedrrrrs r"rzdirstatemap.set_untrackeds  =5 OOA5;O O O O= *   D)))    ! ! !   5 ) ) )4r$c||}|tz}||||||||j|ddS)z$mark a file as back to a clean stateN) rangemask set_cleanrrkr)rrr@rFr~rs r"rzdirstatemap.set_cleans_Xi dE*** He,,, 4(((((r$cj||}||||dS)z|j} | } | | d5} | | j | | j ksJ| |} | ,| t|ksJ| t|fdddn #1swxYwY| xj t|z c_ || _|| _|| |n|||||t'j|dd|_dS)NFsr+bs_map)rrTr'write_v1rVr=rr rUwrite_v2rQrseekrtellr0rrWr`rrx) rrYrZrrr\ can_appendr[appendr rQr?writtens r"rVzdirstatemap.writeZs1( B++B33    %*")5J#'9#5#5j#A#A FD& > & 4 4 6 6 \\-88NBGGF,---7799(88888 hhv..G*&#f++555V7M555 NNNNNNNNNNNNNNN   CKK/  !%'+$))++,,, ''Bf===  $T7 3 3 3!&D   s A=EEEc4|jS)zmReturns a dictionary mapping normalized case paths to their non-normalized versions. )r'filefoldmapasdictr(s r"rzdirstatemap.filefoldmap}s 9..00 0r$c6|j|Sr+)r'rrs r"rzdirstatemap.hastrackeddir9**1-- -r$c6|j|Sr+)r'rrs r"rzdirstatemap.hasdirs9##A&& &r$cvi}tj}|jD]}||||<|Sr+)rrr' tracked_dirsrs r"rzdirstatemap.dirfoldmapsEA}H ..00 ) )$(((4..!!Hr$c6|j|Sr+)r'rrs r"rzdirstatemap.set_trackeds9((++ +r$c6|j|Sr+)r'rrs r"rzdirstatemap.set_untrackedrr$c@|j||||dSr+)r'r)rrr@rFr~s r"rzdirstatemap.set_cleans$ I  $e < < < < rs & 9 % % & J ' '"  ?'LL'L  @@@@@@@@FY"Y"Y"Y"Y"$Y"Y"Y"x  lllll(lllllr$