
    6hq                    \   S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	  S SK
Jr  S SKJr  S SKJrJrJrJrJrJrJrJrJr  S SKJrJr  SS	KJr  \R@                  " S
5      r! " S S\R0                  5      r" " S S\"5      r# " S S\RH                  5      r% " S S5      r&S r' " S S\RP                  RR                  5      r* " S S5      r+ " S S5      r, " S S5      r- " S S5      r.\+\+\,\-\.S.r/S r0S  r1S&S! jr2 " S" S#\Rf                  5      r4 " S$ S%\Rj                  5      r6g)'    )annotationsN)Optional)_)hex)	encodingerrorhttpconnectionpathutilpycompaturlutilvfsworker)
stringutilurlutil   )lfutils   \A[a-f0-9]{64}\Zc                  6   ^  \ rS rSrSU 4S jjrSS jrSrU =r$ )lfsvfs/   c                   > [         R                  U5      (       d  [        R                  " SU-  5      e[        TU ]  " USS USS /UQ76 $ )z9split the path at first two characters, like: XX/XXXXX...s   unexpected lfs path: %sr   r   N)_lfsrematchr   ProgrammingErrorsuperjoin)selfpathinsidef	__class__s      5/usr/lib/python3/dist-packages/hgext/lfs/blobstore.pyr   lfsvfs.join0   sK    ||D!!(()Cd)JKKw|D1ItABx:'::    c           
   #    #    [         R                  R                  U R                  5      n[	        [
        R                  " U5      5      n/ n[         R                  " U R                  U R                  U=(       d    S5      US9 H]  u  pgnXdS n[	        U5      S:X  d  M  UR                  U V	s/ s H%  n	[        R                  Xi-   5      (       d  M!  Xi-   PM'     sn	5        M_     S/ U4v   gs  sn	f 7f)zxYield (dirpath, [], oids) tuple for blobs under path

Oids only exist in the root of this vfs, so dirpath is always ''.
r#   )onerrorNr   )osr   normpathbaselenr
   normasprefixwalkreljoinextendr   r   )
r   r   r%   root	prefixlenoidsdirpathdirsfilesfs
             r!   r+   lfsvfs.walk6   s     
 ww		* --d34	$&GGLLDKC0'%
 G5 j)G 7|q */M%Q6<<3L[W[%M%
 Bo Ns   BC3 C3/ C.
C.
C3 )r   Optional[bytes]r   bytesreturnr8   NN)__name__
__module____qualname____firstlineno__r   r+   __static_attributes____classcell__r    s   @r!   r   r   /   s    ; r#   r   c                  B    \ rS rSrS rS	S
S jjrS rSS jrSS jrSr	g)nullvfsO   c                    g Nr6   r   s    r!   __init__nullvfs.__init__P       r#   Nc                    g)NFr6   )r   r   s     r!   existsnullvfs.existsS   s    r#   c                d    [        [        R                  [        R                  " SU-  5      5      e)Ns   %s: No such file or directory)OSErrorerrnoENOENTr   sysstrr   oids     r!   readnullvfs.readV   s*    
 LLOO<sBC
 	
r#   c                    S/ / 4$ )Nr#   r6   )r   r   r%   s      r!   r+   nullvfs.walk`   s    R}r#   c                    g)Nr   r6   )r   argskwargss      r!   writenullvfs.writec   s    r#   r6   rF   )r   r7   r9   boolr:   )r9   int)
r;   r<   r=   r>   rH   rL   rU   r+   r\   r?   r6   r#   r!   rC   rC   O   s    
r#   rC   c                  2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )lfsuploadfileg   z+a file-like object that supports keepalive.c                \   > [         TU ]  XS5        U R                  R                  U l        g Ns   rb)r   rH   _datarU   )r   uifilenamer    s      r!   rH   lfsuploadfile.__init__j   s!    u-JJOO	r#   c                    g rF   r6   rG   s    r!   _makeprogresslfsuploadfile._makeprogressn   s    r#   )rU   )	r;   r<   r=   r>   __doc__rH   rj   r?   r@   rA   s   @r!   ra   ra   g   s    5$ r#   ra   c                  ^    \ rS rSrSrS rS rS rS rS r	S r
S	 rSS
 jrS rS rS rSrg)localr   zLocal blobstore for large file contents.

This blobstore is used both as a cache and as a staging area for large blobs
to be uploaded to the remote blobstore.
c                @   UR                   R                  S5      n[        U5      U l        UR                  R                  SS5      (       a  [        5       U l        O1[        R                  " UR                  S5      n[        U5      U l        UR                  U l        g )Ns   lfs/objects   experimentals   lfs.disableusercache   lfs)
svfsr   r   r   rf   
configboolrC   cachevfsr   _usercachedir)r   repofullpath	usercaches       r!   rH   local.__init__y   sn    99>>.1(#77o/FGG#IDM,,TWWf=I"9-DM''r#   c                8    [        U R                  U5      S5      $ )z_Open a read-only file descriptor to the named blob, in either the
usercache or the local store.rb)openr   rS   s     r!   r}   
local.open   s     DIIcND))r#   c                    U R                   R                  U5      (       a  U R                   R                  U5      $ U R                  R                  U5      $ )aK  Build the path for the given blob ``oid``.

If the blob exists locally, the path may point to either the usercache
or the local store.  If it doesn't, it will point to the local store.
This is meant for situations where existing code that isn't LFS aware
needs to open a blob.  Generally, prefer the ``open`` method on this
class.
)ru   rL   r   r   rS   s     r!   r   
local.path   sA     ==$$==%%c**xx}}S!!r#   c                   [         R                  " 5       nSnU R                  USSS9 n[        R                  " USS9 H3  nUR                  U5        UR                  U5        U[        U5      -  nM5     Ub4  [        U5      U:w  a%  Sn[        [        U5      U[        U5      U4-  5      e[        UR                  5       5      n	X:w  a  [        [        S	5      U-  5      e SSS5        U R                  U5        g! , (       d  f       N = f)
zfRead the blob from the remote source in chunks, verify the content,
and write to this local blobstore.r      wbT
atomictemp   sizeNsE   Response length (%d) does not match Content-Length header (%d) for %ss   corrupt remote lfs object: %s)hashlibsha256r   r   filechunkiterr\   updater)   r_   LfsRemoteErrorr   r   digestLfsCorruptionError_linktousercache)
r   rT   srccontent_lengthr   r   fpchunkmsgrealoids
             r!   downloadlocal.download   s     !XXc5TX2b++Cg>e$E
" ? )c..AT.I*  %QsVtS5H#.N%NOO&--/*G~(67#=  / 38 	c"9 32s   B9C==
Dc                    U R                  USSS9 nUR                  U5        SSS5        U R                  U5        g! , (       d  f       N = f)zWrite blob to local blobstore.

This should only be called from the filelog during a commit or similar.
As such, there is no need to verify the data.  Imports from a remote
store must use ``download()`` instead.r   Tr   N)r   r\   r   )r   rT   datar   s       r!   r\   local.write   sA     XXc5TX2bHHTN 3 	c" 32s	   >
Ac                f   [        U R                  [        5      (       d  U R                  R	                  U5      (       dq  U R
                  R                  [        S5      U-  5        [        R                  " U R                  R                  U5      U R                  R                  U5      5        ggg)a_  Link blobs found in the user cache into this store.

The server module needs to do this when it lets the client know not to
upload the blob, to ensure it is always available in this store.
Normally this is done implicitly when the client reads or writes the
blob, but that doesn't happen when the server tells the client that it
already has the blob.
   lfs: found %s in the usercache
N)
isinstanceru   rC   r   rL   rf   noter   r   linkr   rS   s     r!   linkfromusercachelocal.linkfromusercache   su     $--11$((//#:N:NGGLL>?#EFKK**3/s1CD ;O1r#   c                f   U R                   R                  U5      (       d  [        U R                   [        5      (       dq  U R                  R                  [        S5      U-  5        [        R                  " U R                  R                  U5      U R                   R                  U5      5        g g g )Ns    lfs: adding %s to the usercache
)ru   rL   r   rC   rf   r   r   r   r   r   r   rS   s     r!   r   local._linktousercache   s}     }}##C((MM72
 2
 GGLL?@3FGKKc*DMM,>,>s,CD	2
(r#   c                X   U R                   R                  U5      (       d  U R                  U R                  X5      nU(       d1  [	        [
        R                  " U5      R                  5       5      U:X  ap  U R                  R                  [        S5      U-  5        [        R                  " U R                  R                  U5      U R                   R                  U5      5        U$ U R                  R                  [        S5      U-  5        U R                  U R                   X5      nU$ )zRead blob from local blobstore.r   s%   lfs: found %s in the local lfs store
)r   rL   _readru   r   r   r   r   rf   r   r   r   r   r   )r   rT   verifyblobs       r!   rU   
local.read   s    xxs##::dmmS9D W^^D188:;sBQBCcIJDMM..s3TXX]]35GH  GGLLDEKL::dhh4Dr#   c                L    UR                  U5      nU(       a  [        X$5        U$ )z0Read blob (after verifying) from the given store)rU   _verify)r   r   rT   r   r   s        r!   r   local._read   s    xx}Cr#   c                   [         R                  " 5       nU R                  U5       n[        R                  " USS9 H  nUR                  U5        M     SSS5        U[        UR                  5       5      :H  $ ! , (       d  f       N*= f)zIIndicate whether or not the hash of the underlying file matches its
name.r   r   N)r   r   r}   r   r   r   r   r   )r   rT   r   r   r   s        r!   r   local.verify   se     !YYs^r++BW=e$ >  c&--/***	 ^s   .A99
Bc                |    U R                   R                  U5      =(       d    U R                  R                  U5      $ )zQReturns True if the local blobstore contains the requested blob,
False otherwise.)ru   rL   r   rS   s     r!   has	local.has  s+     }}##C(@DHHOOC,@@r#   )ru   rf   r   N)T)r;   r<   r=   r>   rl   rH   r}   r   r   r\   r   r   rU   r   r   r   r?   r6   r#   r!   rn   rn   r   sB    	*
"("#H	#EE$	+Ar#   rn   c                   U n[        U R                  [        5      (       a  U R                  n[        US5      (       aG   UR                  R                  S   n[        U[        5      (       a  [        R                  " U5      nU$ [        USS5      (       a   [        R                  " UR                  5      $ [        R                  " U 5      $ ! [
        [        4 a    UR                  n Nf = f)zZCreate a friendly message for the given URLError to be used in an
LfsRemoteError message.
reason   strerrorN)r   r   	ExceptionhasattrrZ   AttributeError
IndexErrorstrr   
unitolocalgetattr
strtolocalr   r   forcebytestr)urlerrorinstr   s      r!   _urlerrorreasonr     s     D(//9--tX	![[%%a(F fc""((0F	z4	(	(""4==11&&x00 
+ 	![[F	!s    C C-,C-c                      \ rS rSrSrS rSrg)lfsauthhandleri%  i  c                $   UR                  SS5      nU(       aw  UR                  5       S   nUR                  5       S:w  aP  [        S5      n[        R
                  R                  UR                  5       U[        R                  " U5      UU5      eg)zpEnforces that any authentication performed is HTTP Basic
Authentication.  No authentication is also acceptable.
zwww-authenticateNr   basics,   the server must support Basic Authentication)
getsplitlowerr   r   urlerr	httperrorget_full_urlr   strfromlocal)r   reqr   coder   headersauthreqschemes           r!   http_error_401lfsauthhandler.http_error_401(  s     ++0$7]]_Q'F||~(GHkk++$$&))#.  r#   r6   N)r;   r<   r=   r>   handler_orderr   r?   r6   r#   r!   r   r   %  s    Mr#   r   c                  J    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rSrg)_gitlfsremotei<  c                   UR                   nX0l         UR                  5       u  pEUR                  S5      U l        UR                   R	                  SS5      nU(       d  S[
        R                  " 5       -  n[        R                  " X5U5      U l	        U R                  R                  [        5       5        UR                  SS5      U l        g )N   /rq   s   lfs.user-agents   git-lfs/2.3.4 (Mercurial %s)rr   s   retry)rf   authinforstripbaseurlconfigr   versionurlmodopener	urlopeneradd_handlerr   	configintretry)r   rw   r   rf   r   r   	useragents          r!   rH   _gitlfsremote.__init__=  s    WWLLN~~d+GGNN?4EF	7$,,.HIrY?"">#34\\&(3
r#   c                <    U R                  [        U5      US5        g)z,Batch upload from local to remote blobstore.   uploadN_batch_deduplicater   pointers	fromstores      r!   
writebatch_gitlfsremote.writebatchI  s    L*IyAr#   c                <    U R                  [        U5      US5        g)z-Batch download from remote to local blostore.   downloadNr   r   r   tostores      r!   	readbatch_gitlfsremote.readbatchM  s    L*G[Ar#   c                   U Vs/ s H8  n[         R                  " UR                  5       5      UR                  5       S.PM:     nn[         R                  " [
        R                  " U[         R                  " U5      S.5      5      nSU R                  -  n[        R                  R                  [         R                  " U5      US9nUR                  SS5        UR                  SS5         [        R                  " U R                  R                  U5      5       nUR!                  5       n	SSS5         [         R6                  " W	5      nU R<                  R>                  (       a  U R<                  RA                  SWRB                  -  5        [         RD                  " URG                  5       5      RI                  5       nU R<                  RA                  SSRK                  [M        URO                  5       5      5      -  5        SU;   a  [M        US   S S9US'   U R<                  RA                  S[         R                  " [
        R                  " USSSS95      -  5        S n[         RP                  " X5      $ s  snf ! , (       d  f       GN[= f! [        R"                  R$                   a  n
['        S	5      U R                  U4-  ['        S
5      U R                  -  S.nUR)                  U
R*                  ['        S5      Xb4-  5      n[-        ['        S5      [.        R0                  " U
5      -  US9eSn
A
f[        R"                  R2                   a<  n
['        S
5      U R                  -  n[-        ['        S5      [5        U
5      -  US9eSn
A
ff = f! [8         a'    [-        ['        S5      W	R;                  S5      -  5      ef = f)zGet metadata about objects pointed by pointers for given action

Return decoded JSON object like {'objects': [{'oid': '', 'size': 1}]}
See https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md
)rT   r   )objects	operations   %s/objects/batch)r   Acceptzapplication/vnd.git-lfs+jsonContent-TypeNs=   check that lfs serving is enabled on %s and "%s" is supporteds/   the "lfs.url" config may be used to override %s)i    s   api=%s, action=%ss   LFS HTTP error: %shint   LFS error: %ss#   LFS server returns invalid JSON: %sutf-8   Status: %d
   %s
   
r   c                    U S   $ )NrT   r6   )ps    r!   <lambda>-_gitlfsremote._batchrequest.<locals>.<lambda>  s    qxr#   keyr   ) z: T)indent
separators	sort_keysc                R    [        U [        5      (       a  U R                  S5      $ U $ )Nr   )r   r   encode)xs    r!   	encodestr._gitlfsremote._batchrequest.<locals>.encodestr  s#    !S!!xx((Hr#   ))r   strurlrT   r   bytesurljsondumpsr   r   urlreqrequest
add_header
contextlibclosingr   r}   rU   r   r   r   r   r   r   r   r   r   r   
json_loads
ValueErrorr  rf   	debugflagdebugstatusbytestrinfostripr   sorted
splitlinesrapply)r   r   actionr  r   requestdatar   batchreqrsprawjsonexhintsr   responser   r  s                   r!   _batchrequest_gitlfsremote._batchrequestQ  s6    
 OOAEEG,affh? 	 
 ''JJ&!)!8
 "DLL0;;&&xs';+&NH&DEN,JK	##DNN$7$7$ABc((* C2	**73H 77GGMM/CJJ67&&sxxz288:GGGMM'EJJvg6H6H6J/K$LLMH$&,Y'-?'# GGMM##JJ  #-"&	
	
 y33[
" CB{{$$ 	! <<(	)
 IJ,,E 99RWWa(<&=&MND '(:+B+B2+FF  {{## 	DE,,  !"#ob&99 	  	 89..)* 	sT   ?I<-/J J-J 6N 
JJ J N1BL77!N7NN1Oc                   U H  nSU;  a   US:X  a  X4R                  S/ 5      ;  a  SnO#M)  UR                  S5      R                  SS5      nU Vs0 s H  ofR                  5       U_M     nnUR                  US   S5      nU(       aA  [        US	S
5      nSSSSS.n	U	R                  USU-  5      n
[        [	        S5      X4-  5      e[        [	        S5      US   -  5      e   gs  snf )zMScans errors from objects

Raises LfsRemoteError if any objects have an errors   errorr      actionsr   s   code     oidNrg   s   unknowns   The object does not exists#   The object was removed by the owners   Validation errors   Internal server error)r   i  i  r1  s   status code %ds   LFS server error for "%s": %ss1   LFS server error. Unsolicited response for oid %s)r   rT   r   r   r   )r   r   	responsesr%  r,  r   r  ptrmaprg   errorsr   s              r!   _checkforservererror"_gitlfsremote._checkforservererror  s    "H
 x'[(V<<< . D  ||H-11'3?*23(Qeegqj(F3

8F+T2A"1j*=5?,1	 jj'84'?@$678/I  %JKv&' A "" 4s   C'c                    UR                  S/ 5      nU R                  X$U5        U Vs/ s H  oSUR                  S/ 5      ;   d  M  UPM     nnU$ s  snf )zextract objects from response of the batch API

response: parsed JSON object returned by batch API
return response['objects'] filtered by action
raise if any object has an error
s   objectsr0  )r   r6  )r   r,  r   r%  r   ofilteredobjectss          r!   _extractobjects_gitlfsremote._extractobjects  s_     ,,z2.!!(V<
 
!AEE*b,A"AAw 	 
 	
s   AAc           
        US   nUS   U   R                  S5      nUS   U   R                  S0 5      R                  5       n[        R                  R	                  [
        R                  " U5      5      nUS:X  a@  UR                  U5      (       d*  [        R                  " [        S5      U-  [        S5      S9eU H?  u  pUR                  [
        R                  " U5      [
        R                  " U	5      5        MA      US:X  aj  [        U R                  UR                  U5      5      Ul        S	 Ul        UR                  S
S5        UR                  SUR                  R"                  5        [$        R&                  " U R(                  R+                  U5      5       n
U
R-                  5       R                  S5      nU R                  nU R                  R.                  (       a  UR1                  SU
R2                  -  5        [
        R4                  " U
R-                  5       5      R7                  5       nUR1                  SSR9                  [;        UR=                  5       5      5      -  5        US:X  a  UR?                  XJU5        O\/ n U
RA                  S5      nU(       d  OURC                  U5        M,  SR9                  U5      nU(       a  UR1                  SX/4-  5        SSS5        UR                  (       a  UR                  RY                  5         gg! , (       d  f       N;= f! [        RD                  RF                   a{  nU R                  R.                  (       a.  U R                  R1                  SUURA                  5       4-  5        [I        [        S5      [J        RL                  " U5      XB4-  5      eSnAf[        RD                  RN                   ac  n[        S5      [
        RP                  " [        RR                  RU                  U5      5      -  n[I        [        S5      [W        U5      -  US9eSnAff = f! UR                  (       a  UR                  RY                  5         f f = f)a  Download or upload a single object using basic transfer protocol

obj: dict, an object description returned by batch API
action: string, one of ['upload', 'download']
localstore: blobstore.local

See https://github.com/git-lfs/git-lfs/blob/master/docs/api/        basic-transfers.md
r2  r0  s   hrefs   headerr      detected corrupt lfs object: %s   run hg verifyr   c                     g)NPUTr6   r6   r#   r!   r  ._gitlfsremote._basictransfer.<locals>.<lambda>  s    Ur#   r   zapplication/octet-streamzContent-Lengths   content-lengthr   r   r  r   r   r#   s   lfs %s response: %sNs   %s: %s
s&   LFS HTTP error: %s (oid=%s, action=%s)s   attempted connection to %sr   )-r   itemsr   r  r  r   r  r   r   Abortr   r  ra   rf   r   r   
get_methodlengthr  r  r   r}   r   r  r  r  r  r!  r   r"  r#  r   rU   appendr   r   r   r   r   r   r  urllibcompat
getfullurlr   close)r   objr%  
localstorerT   hrefr   r  kvrescontentlengthrf   blocksr   r,  r*  r   s                     r!   _basictransfer_gitlfsremote._basictransfer  s    &k:v&**73j/&)--i<BBD++%%hood&;<Y$$S))kk89C?+, 
 DAxq18??13EF 2	%",TWWjooc6JK%2""">3MN""#3W\\5H5HI##DNN$7$7$@AS #
/@ AWW77$$HH_szz9: '..sxxz:@@BGHHWuzz&9K9K9M2N'OOP[( ''-@F"xx0#!d+	   #xx/H!76:L!LM1 BT ||""$ U BA2 {{$$ 	ww  3	"22 !;<**2.<=  {{## 	23h6G6G!!,,W57 D !"#ob&99 		 ||""$ sX   BL- !EL'L- 
L*&L- )Q *L- -QA6O!Q"AQ  QQ .Q6c                ,  ^ ^^ TS;  a  [         R                  " ST-  5      eT R                  UT5      nT R                  XAT5      n[	        S U 5       5      n0 nU H&  nUR                  SS5      XxR                  S5      '   M(     [        S5      [        S5      S.T   n	[        U5      S	:  aF  T R                  R                  [        S
5      [        U5      [        R                  " U5      4-  5        UUU 4S jn
T R                  R                  SS5      (       a3  U 4S jn[        R                  " T R                  SU
S[        US S9US9nOU
" [        US S95      nT R                  R                  U	[        S5      US9 nUR!                  S5        SnSnU HJ  u  nnXU   -  nUS	-  nUR!                  U5        T R                  R                  [        S5      U-  5        ML     S S S 5        WS:  a  TS:X  a>  T R                  R#                  [        S5      U[        R                  " W5      4-  5        g TS:X  a>  T R                  R#                  [        S5      U[        R                  " W5      4-  5        g g g ! , (       d  f       N= f)N)r   r   s   invalid Git-LFS action: %sc              3  D   #    U  H  oR                  S S5      v   M     g7f)   sizer   Nr   ).0r  s     r!   	<genexpr>'_gitlfsremote._batch.<locals>.<genexpr>6  s     7w!EE'1%%ws    rW  r   r2  s   lfs uploadings   lfs downloadingr   s&   lfs: need to transfer %d objects (%s)
c              3  t  >#    U  H  nUR                  SS5      nTR                  R                  (       af  TS:X  a  [        S5      nOTS:X  a  [        S5      nTR                  R	                  WUR                  S5      [
        R                  " U5      4-  5        TR                  n  TR                  UTT5        SUR                  S5      4v   M     g ! [         aT  nUS:  aH  TR                  R	                  [        S	5      [        R                  " U5      U4-  5        US-  n S nAM  e S nAff = f7f)
NrW  r   r   s   lfs: downloading %s (%s)
r   s   lfs: uploading %s (%s)
r2  r   s%   lfs: failed: %r (remaining retry %d)
)r   rf   verboser   r   r   	bytecountr   rS  rO   r   r   )	r   rK  objsizer   r   r*  r%  rL  r   s	         r!   transfer&_gitlfsremote._batch.<locals>.transferD  s    '''1-77??, =>9, ;<GGLLswwvw0GHH 

++CD00   #  19 GGLL !"K L#-#:#:2#>"F!G "QJE$s7   B&D8*(CD8
D5!AD0)D8/D00D55D8rq   s   lfs.worker-enablec                 f   > TR                   R                   H  n [        U SS 5      " 5         M     g )N	close_allc                     g rF   r6   r6   r#   r!   r  7_gitlfsremote._batch.<locals>.prefork.<locals>.<lambda>n  s    Dr#   )r   handlersr   )hr   s    r!   prefork%_gitlfsremote._batch.<locals>.preforkl  s&    00AA{L9; 1r#   g?r6   c                $    U R                  S5      $ Nr2  rX  r9  s    r!   r  &_gitlfsremote._batch.<locals>.<lambda>u  s    aeeFmr#   r  )rh  c                $    U R                  S5      $ rk  rX  rl  s    r!   r  rm  y  s    !%%-r#   s   bytes)unittotals   lfs: processed: %s
r   s   lfs: uploaded %d files (%s)
r   s   lfs: downloaded %d files (%s)
)r   r   r-  r;  sumr   r   r)   rf   r   r   r^  rt   r   r"  makeprogressr   r  )r   r   rL  r%  r,  r   rp  sizesrK  topicr`  rh  r0   progress	processedblobs_onerT   s   ` ``              r!   r   _gitlfsremote._batch0  se   11(()F)OPP%%h7&&x6B7w77C%(WWWa%8E''&/"  )*-.
  w<!GGLL<=w<!678
	< 77o/CDD< ==w$;<D F70GHIDWW!!(5 " 
OOAIE!	c3Z'	
	*Q67#=>	 "
 19"67dnnY789 ;&89dnnY789 ' 
 
s   A&J
Jc                    [        U SS 5      nU(       a7  UR                   H&  nUR                  5         [        USS 5      " 5         M(     g g )Nr   rc  c                     g rF   r6   r6   r#   r!   r  '_gitlfsremote.__del__.<locals>.<lambda>  s    r#   )r   rf  rJ  )r   r   rg  s      r!   __del___gitlfsremote.__del__  s@    D+t4	''	;57 ( r#   )r   r   rf   r   N)r;   r<   r=   r>   rH   r   r   r-  r6  r;  rS  r   r}  r?   r6   r#   r!   r   r   <  s8    
4BBS4j'R&L%\aF8r#   r   c                  *    \ rS rSrSrS rS rS rSrg)_dummyremotei  z,Dummy store storing blobs to temp directory.c                p    UR                   R                  SUR                  5      n[        U5      U l         g )Nrr   )r   r   r   r   )r   rw   r   rx   s       r!   rH   _dummyremote.__init__  s&    88==2(#r#   c                    [        U5       HZ  nUR                  UR                  5       SS9nU R                  UR                  5       SSS9 nUR	                  U5        S S S 5        M\     g ! , (       d  f       Mn  = f)NT)r   r   r   )r   rU   rT   r   r\   )r   r   r   r  contentr   s         r!   r   _dummyremote.writebatch  s^    h'AnnQUUWTn:G!%%'5T:b! ;: (::s   A++
A:	c                    [        U5       HM  nU R                  UR                  5       S5       nUR                  UR                  5       US 5        S S S 5        MO     g ! , (       d  f       Ma  = frd   )r   r   rT   r   )r   r   r   r  r   s        r!   r   _dummyremote.readbatch  sN    h'A!%%'5)R  "d3 *) ())s   "A
A-	)r   N	r;   r<   r=   r>   rl   rH   r   r   r?   r6   r#   r!   r  r    s    6$"4r#   r  c                  *    \ rS rSrSrS rS rS rSrg)_nullremotei  z&Null store storing blobs to /dev/null.c                    g rF   r6   r   rw   r   s      r!   rH   _nullremote.__init__  rJ   r#   c                    g rF   r6   r   s      r!   r   _nullremote.writebatch  rJ   r#   c                    g rF   r6   r   s      r!   r   _nullremote.readbatch  rJ   r#   r6   Nr  r6   r#   r!   r  r    s    0r#   r  c                  8    \ rS rSrSrS rS	S jrS	S jrS rSr	g)
_promptremotei  z)Prompt user to set lfs.url when accessed.c                    g rF   r6   r  s      r!   rH   _promptremote.__init__  rJ   r#   Nc                $    U R                  5         g rF   _prompt)r   r   r   rf   s       r!   r   _promptremote.writebatch      r#   c                $    U R                  5         g rF   r  )r   r   r   rf   s       r!   r   _promptremote.readbatch  r  r#   c                @    [         R                  " [        S5      5      e)Ns   lfs.url needs to be configured)r   rD  r   rG   s    r!   r  _promptremote._prompt  s    kk!=>??r#   r6   rF   )
r;   r<   r=   r>   rl   rH   r   r   r  r?   r6   r#   r!   r  r    s    3@r#   r  )   https   https   files   nullNc                    [         R                  " 5       nU  H  nX!UR                  5       '   M     UR                  5       $ )z0Remove any duplicate oids that exist in the list)r   sortdictrT   values)r   reducedr  s      r!   r   r     s2    mmoG >>r#   c                    [        [        R                  " U5      R                  5       5      nX :w  a  [	        [        S5      U -  [        S5      S9eg )Nr>  r?  r   )r   r   r   r   r   r   )rT   r  r   s      r!   r   r     sL    '..)0023G~ 01C7#$
 	
 r#   c                ,   U R                   R                  SS5      n[        R                  " U=(       d    S5      nUGc  U(       a  UnOC[	        U S5      (       a  U R
                  nO%U R                   R                  SS5      =(       d    Sn[        R                  " U5      nUR                  S;   a  UR                  (       a(  UR                  SS	 S
:w  a  U=R                  S
-  sl        UR                  =(       d    SS-   Ul        [        R                  " [        U5      5      nU R                   R                  [        S5      U-  5        UR                  nU[        ;  a"  [        R                  " [        S5      U-  5      e[        U   " X5      $ )a  remotestore factory. return a store in _storemap depending on config

If ``lfs.url`` is specified, use that remote endpoint.  Otherwise, try to
infer the endpoint, based on the remote repository using the same path
adjustments as git.  As an extension, 'http' is supported as well so that
``hg serve`` works out of the box.

https://github.com/git-lfs/git-lfs/blob/master/docs/api/server-discovery.md
rr   s   urlr#   N_subtoppaths   pathss   default)r  r  r   s   .git/info/lfss   lfs: assuming remote store: %s
s   lfs: unknown url scheme: %s)rf   r   r   r   r   r  r   r   r8   r   r   	_storemapr   rD  )rw   remotelfsurlr   r   
defaulturlr   s          r!   r  r    s1    WW^^FF+F
++fm
$C~DT=)) ##D 77>>(J7>3D[[&
  33:??3B#74#?4')5#9IIJO++eJ/0CGGLL>?#EFZZFYkk!:;fDEEVT''r#   c                      \ rS rSrSrg)r   i  r6   N)r;   r<   r=   r>   r?   r6   r#   r!   r   r     s    r#   r   c                      \ rS rSrSrSrg)r   i  zzRaised when a corrupt blob is detected, aborting an operation

It exists to allow specialized handling on the server side.r6   N)r;   r<   r=   r>   rl   r?   r6   r#   r!   r   r     s    Cr#   r   rF   )7
__future__r   r  rP   r   r  r&   retypingr   mercurial.i18nr   mercurial.noder   	mercurialr   r   r	   httpconnectionmodr
   r   r   r   r   r   vfsmodr   mercurial.utilsr   r   
largefilesr   compiler   r   rC   httpsendfilera   rn   r   r  basehandlerr   r   r  r  r  r  r   r   r  StorageErrorr   rD  r   r6   r#   r!   <module>r     s&   #     	 	  
 
 

   
(	)VZZ @f 0%22 WA WAt12T[[,, .]8 ]8@4 4&
 
@ @" 
	
((V	U'' 	C Cr#   