o ]Lb @sRdZddlmZddlZddlmZddlmZddlm Z Gdd d e j Z dS) z [infinitepush] # Server-side option. Used only if indextype=disk. # Filesystem path to the index store indexpath = PATH )absolute_importN)util) stringutil)indexapicseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZZS) fileindexapicsntt|||_|jdd}|stjdd}tj|d|_ tj|d|_ tj|d|_ d|_ dS)Ns infinitepushs indexpathsscratchbranchessindexsnodemaps bookmarkmapsnodemetadatamap) superr__init___repouiconfigospathjoin_nodemap _bookmarkmap _metadatamap_lock)selfreporoot __class__A/usr/lib/python3/dist-packages/hgext/infinitepush/fileindexapi.pyr s zfileindexapi.__init__cCs|j|_|SN)r wlockr)rrrr __enter__&s zfileindexapi.__enter__cCs|jr |j|||dSdSr)r__exit__)rexc_typeexc_valexc_tbrrrr*szfileindexapi.__exit__cCs.|D]}tj|j|}|||qdSr)r rrrhex_write)rbundleidnodesctxnodenodepathrrr addbundle.szfileindexapi.addbundlecCs tj|j|}|||dSr)r rrrr#)rbookmarkr& bookmarkpathrrr addbookmark3szfileindexapi.addbookmarkcCs"|D] \}}|||qdSr)itemsr+)r bookmarksr)r&rrraddmanybookmarks7szfileindexapi.addmanybookmarkscCs<|D]}||D]\}}tj|j|}||q qdSr)_listbookmarksr rrr_delete)rpatternspatternr)_r*rrrdeletebookmarks;s  zfileindexapi.deletebookmarkscCtj|j|}||Sr)r rrr_read)rr&r'rrr getbundleA zfileindexapi.getbundlecCr5r)r rrrr6)rr)r*rrrgetnodeEr8zfileindexapi.getnodecCst||Sr)dictr/)rqueryrrr getbookmarksIszfileindexapi.getbookmarkscCs$|jj}|tj|j||dSr)r vfswriter rrr)rr& jsonmetadatar=rrrsaveoptionaljsonmetadataLsz%fileindexapi.saveoptionaljsonmetadatac cs|drd|ddd}t|\}}}t|jd}|jj|jD],\}}}|D]$} tj || |d} t | } || sEq.| | tj || fVq.q'dS)N*sre:^s.*r)endswithr stringmatcherlenrr r=walkr rrrpconvertr6) rr2kindpatmatcher prefixlendirpathr3booksbookr)rrrr/Ps  zfileindexapi._listbookmarkscCs6|jj}||}||s|||||dSr)r r=dirnameexistsmakedirsr>)rrvaluer=rOrrrr#]s    zfileindexapi._writecC |jj}||s dS||Sr)r r=rPreadrrr=rrrr6e  zfileindexapi._readcCrSr)r r=rPunlinkrUrrrr0krVzfileindexapi._delete)__name__ __module__ __qualname__r rrr(r+r.r4r7r9r<r@r/r#r6r0 __classcell__rrrrrs    r) __doc__ __future__rr mercurialrmercurial.utilsrrrrrrrs