o ]Lb{@svdZddlmZddlmZddlmZmZmZddl m Z m Z ddl m Z mZmZejZejZGdd d e j Zd S) z4remote largefile store; the base class for wirestore)absolute_import)_)errorpycompatutil) stringutilurlutil) basestorelfutil localstorecsheZdZdZfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ZS) remotestorez)a largefile store accessed over a networkcs@tt||||d|_|durt|j|j|j|_dSdS)N)superr __init___lstorer uirepo)selfrrurl __class__>/usr/lib/python3/dist-packages/hgext/largefiles/remotestore.pyr$s zremotestore.__init__cCsN|||rttd|t|jf|jtd|t|jfdS)Ns0remotestore: could not put %s to remote store %ss'remotestore: put %s to remote store %s ) sendfilerAbortrr hidepasswordrrdebug)rsourcehashrrrput*s zremotestore.putcCsddt||DS)NcSsi|] \}}||dkqS)rr).0hsrrr 6sz&remotestore.exists..)r iteritems_statrhashesrrrexists5s zremotestore.existsc Cs|jd||fz!t|j|}|||WdWS1s$wYWdStyE}zttd|t |fd}~ww)Nsremotestore: sendfile(%s, %s) s'remotestore: could not open file %s: %s) rrr httpsendfile_putIOErrorrrrr forcebytestr)rfilenamerfderrrr=s ( zremotestore.sendfilec Csz||}WnJtjy }z t|||jt|d}~wtjy:}zt dt |j|j fd}~wtyQ}z t|||jt|d}~wwt||S)Ns%s: %s)_geturlerr httperrorr StoreErrorrrr,urlerrorrrrrreasonr+r copyandhash)rtmpfiler-rchunksr/rrr_getfileHs& zremotestore._getfilecs"|j|fdd|D}|S)Ncsg|]}|r|qSrr)r rexistslocallymaprr asz7remotestore._hashesavailablelocally..)rr()rr' localhashesrr:r_hashesavailablelocally_s z#remotestore._hashesavailablelocallyc sd}dd|D}|||fdd|D}|D]M\}}}|vr7|||f} |j|| g} | r6d}q||} | ri| dkrP|jtd||fd}q| dkrc|jtd ||fd}qtd | q|S) NFcSsg|]\}}}|qSrr)r csetr- expectedhashrrrr<fs z,remotestore._verifyfiles..csg|]}|vr|qSrr)r r@r=rrr<ks Tr s"changeset %s: %s: contents differ schangeset %s: %s missing s6verify failed: unexpected response from statlfile (%r))r>r%r _verifyfilesrwarnr RuntimeError) rcontents filestocheckfailedexpectedhashesstatsr?r-r@ filetocheck verifyresultstatrrArrCdsP   zremotestore._verifyfilescCtd)z1Put file with the given hash in the remote store.abstract methodNotImplementedError)rrr.rrrr*zremotestore._putcCrN)z/Get a iterator for content with the given hash.rOrP)rrrrrr0rRzremotestore._getcCrN)zGet information about availability of files specified by hashes in the remote store. Return dictionary mapping hashes to return code where 0 means that file is available, other values if not.rOrPr&rrrr%szremotestore._stat)__name__ __module__ __qualname____doc__rrr(rr9r>rCr*r0r% __classcell__rrrrr !s   +r N)rV __future__rmercurial.i18nr mercurialrrrmercurial.utilsrrr r r r1urlreqr rrrrs