
    	^c                     H   d dl Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZ ej        Zej        Z G d d          Z G d	 d
e          Z G d dej                  Zd Z G d de	j                  Z G d de	j         e	j!                  Z"ddZ#dS )    N   )_)sha1nodeconstants)	branchmap	changelogerror	localrepomanifest
namespacespathutilpycompatrequirementsurlutilvfs)urlutilc                   @    e Zd Zd Zd Zd Zd Zd
dZd Zd Z	d	 Z
dS )httprangereaderc                 >    || _         d| _        || _        || _        d S )Nr   )r   posopenername)selfr   r   s      :/usr/lib/python3/dist-packages/mercurial/statichttprepo.py__init__zhttprangereader.__init__&   s"    			    c                     | S N r   s    r   	__enter__zhttprangereader.__enter__-   s    r   c                 .    |                                   d S r   )close)r   exc_type	exc_value	tracebacks       r   __exit__zhttprangereader.__exit__0   s    

r   c                     || _         d S r   )r   )r   r   s     r   seekzhttprangereader.seek3   s    r   Nc                    t                               t          j        | j                            }d}|r| j        |z   dz
  }| j        s|r |                    dd| j        |fz             	 | j                            |          }|	                                }|j
        }nt# t          j        $ r;}|j
        dk    rt          j        pd }t          |t!          |                    d }~wt          j        $ r}t          d |j                  d }~ww xY w|dk    r*|r|| j        | j        |z            }n|| j        d          }n|r
|d |         }| xj        t'          |          z  c_        |S )Nr   r   Rangezbytes=%d-%si     )urlreqrequestr   strurlr   r   
add_headerr   openreadcodeurlerr	httperrorerrnoENOENTIOErrorstrurlerrorreasonlen)	r   bytesreqendfdatar3   instnums	            r   r2   zhttprangereader.read6   s   nnX_TX6677 	'(U"Q&C8 	Es 	ENN7MTXsO$CDDD	-  %%A6688D6DD 	* 	* 	*)s"3u|;tC #s4yy))) 	- 	- 	-$,,,	- 3;;  (DHtx%'778DHJJ' 	 <DCIIs$   -5B# #D26C((D:DDc                 P    |                                                      d          S )NT)r2   
splitlinesr    s    r   	readlineszhttprangereader.readlinesW   s    yy{{%%d+++r   c                 D    t          |                                           S r   )iterrF   r    s    r   __iter__zhttprangereader.__iter__Z   s    DNN$$%%%r   c                     d S r   r   r    s    r   r#   zhttprangereader.close]       r   r   )__name__
__module____qualname__r   r!   r'   r)   r2   rF   rI   r#   r   r   r   r   r   %   s                   B, , ,& & &    r   r   c                       e Zd ZdZdS )_RangeErrorz6Error raised when an unsatisfiable range is requested.N)rL   rM   rN   __doc__r   r   r   rP   rP   d   s        @@@@r   rP   c                       e Zd ZdZd Zd ZdS )_HTTPRangeHandlera  Handler that enables HTTP Range headers.

    This was extremely simple. The Range header is a HTTP feature to
    begin with so all this class does is tell urllib2 that the
    "206 Partial Content" response from the HTTP server is what we
    expected.
    c                 ~    t                               |||                                          }||_        ||_        |S r   )r-   
addinfourlget_full_urlr3   msg)r   r>   fpr3   rW   hdrsrs          r   http_error_206z _HTTPRangeHandler.http_error_206q   s8    b$(8(8(:(:;;r   c                      t          d          )Ns   Requested Range Not Satisfiable)rP   )r   r>   rX   r3   rW   rY   s         r   http_error_416z _HTTPRangeHandler.http_error_416x   s    <===r   N)rL   rM   rN   rQ   r[   r]   r   r   r   rS   rS   h   s<           > > > > >r   rS   c                     t          j        | |                              t                                  G fddt          j                  }|S )Nc                   (    e Zd Zd Zd fd	Zd ZdS )#build_opener.<locals>.statichttpvfsc                 "    || _         i | _        d S r   )baseoptions)r   rb   s     r   r   z,build_opener.<locals>.statichttpvfs.__init__   s    DIDLLLr      rc                     |dvrt          d          d                    | j        t                              |          f          }t          |          S )N)rd   s   rbs   Permission denied   /)r8   joinrb   r-   quoter   )r   pathmodeargskwr@   	urlopeners         r   __call__z,build_opener.<locals>.statichttpvfs.__call__   sQ    =((2333		49fll4&8&89::A"1i000r   c                 H    |rt          j        | j        |          S | j        S r   )r   rg   rb   )r   ri   s     r   rg   z(build_opener.<locals>.statichttpvfs.join   s&     !}TY555y r   N)rd   )rL   rM   rN   r   rn   rg   )rm   s   r   statichttpvfsr`      sQ        	 	 		1 	1 	1 	1 	1 	1	! 	! 	! 	! 	!r   rp   )r   r   add_handlerrS   vfsmodabstractvfs)uiauthinforp   rm   s      @r   build_openerrv   }   sn    
2x((I+--...! ! ! ! ! ! !* ! ! !" r   c                       e Zd Zd Zd ZdS )statichttppeerc                     d S r   r   r    s    r   localzstatichttppeer.local   s    tr   c                     dS NFr   r    s    r   canpushzstatichttppeer.canpush       ur   N)rL   rM   rN   rz   r}   r   r   r   rx   rx      s2              r   rx   c                   d     e Zd Zej        j        Zd Z fdZd Z	d Z
d Zd
dZd
dZd	 Z xZS )statichttprepositoryc                 B   || _         || _        || _        t          j        |                    d          dz             }|                                \  | _        }t          ||          } || j                  | _	         || j	        
                    d                    | _        g | _        t          j                    | _        d | _        d | _        t#                      | _        t#                      | _        	 t#          | j	                            d                                                    }n# t,          $ r t#                      }	 | 	                    d          }|                    d           |                                 n4# t,          $ r' t1          d          |z  }t3          j        |          w xY wY nw xY wt6          j        |v rZ || j	        
                    d                    }	|t#          |	                    d                                                    z  }t;          j        |          }
t;          j        ||
           t;          j         ||           tB          | _"        | j"        j#        | _#        t;          j$        || j        |          | _%        | j%        j        | _&        | j%        j'        | _(        | j%        j
        | _)        i | _*        || _+        tY          j-        | j"        | j(                  }tY          j.        | j(        | || /                                          | _.        ta          j0        | j(                  | _0        d | _1        d | _2        tg          j4                    | _5        d | _6        d | _7        d | _8        d | _9        d S )	Nrf   s   /.hgs   caches   requiress   00changelog.ir   s+   '%s' does not appear to be an hg repositorys   store):_urlrt   rootr   r   rstripru   ri   rv   r   rg   cachevfs_phasedefaultsr   names
filtername_extrafilteridset_wanted_sidedatafeaturesr2   rE   FileNotFoundErrorr#   r   r   	RepoErrorrequirementsmodSHARESAFE_REQUIREMENTr	   gathersupportedrequirementsensurerequirementsrecognizedensurerequirementscompatibler   nodeconstantsnullid	makestorestorespathr   svfssjoin
_filecacher   r
   manifestrevlogmanifestlognarrowmatchr   _tagsnodetagscacher   BranchMapCache_branchcaches_revbranchcache
encodepats
decodepats	_transref)r   rt   ri   uru   vfsclassr   rX   rW   storevfssupportedrequirementsrootmanifests               r   r   zstatichttprepository.__init__   s(   		KD))G344jjll	8H--8DI&& x!8!899 *,,
" #	+tx}}[99DDFFGGLL  	+ 	+ 	+55L+XX.//






$ + + +FGG$Noc***+ 
	+ 0L@@xh 7 788HCk : : E E G GHHHL ) Eb I I./	
 	
 	
 	.r<@@@.(/ (ty(KK
Z_
J%	Z_
(.t/A49MM#/It\4+;+;+=+=
 
 #,TY77
!&577#s*   =9D7 7G>FG1G  GGc                     t          t          |                               |          }|                    dg          S )Ns   pushkey)superr   _restrictcapabilities
difference)r   caps	__class__s     r   r   z*statichttprepository._restrictcapabilities   s5    )400FFtLL
|,,,r   c                     | j         S r   )r   r    s    r   r   zstatichttprepository.url   s
    yr   c                     dS r|   r   r    s    r   rz   zstatichttprepository.local   r~   r   c                      t          |           S r   )rx   r    s    r   peerzstatichttprepository.peer   s    d###r   Tc                 d    t          j        dt          d          dt          d                    Nr   s   lock not availables   locks"   cannot lock static-http repositoryr   LockUnavailabler   r   waits     r   wlockzstatichttprepository.wlock   5    ##$$344	
 
 	
r   c                 d    t          j        dt          d          dt          d                    r   r   r   s     r   lockzstatichttprepository.lock   r   r   c                     d S r   r   r    s    r   _writecachesz!statichttprepository._writecaches  rK   r   )T)rL   rM   rN   r	   localrepository_basesupported	supportedr   r   r   rz   r   r   r   r   __classcell__)r   s   @r   r   r      s         )8I@ @ @D- - - - -    $ $ $
 
 
 

 
 
 
      r   r   c                 x    |r!t          j        t          d                    t          | |dd                    S )Ns(   cannot create new static-http repository   )r   Abortr   r   )rt   ri   createintents
createoptss        r   instancer     s<     Jk!GHHIIIDH---r   )NN)$r6   i18nr   noder    r   r   r   r	   r
   r   r   r   r   r   r   r   r   rr   utilsr   r4   r-   r   r8   rP   basehandlerrS   rv   	localpeerrx   r   revlogfilestorager   r   r   r   r   <module>r      s          # # # # # #                                 
	9 9 9 9 9 9 9 9~A A A A A' A A A> > > > >* > > >*  2    Y(   e e e e ey:e e eP. . . . . .r   