
    6h,                       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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  SSKJr  \R6                  (       a  SS	KJr  \R:                  rS
rSrS r S/SS/SS/S/SS/S.r!S r"S r#SSS r$S r% " S S5      r& " S S5      r' " S S5      r(\(\&S  S! S" S# \'S$.r)     S&             S'S% jjr*g)(    )annotationsN)Optional   )_nullrev)error	formattermatchpycompatscmutilutilvfs)
stringutil)	localrepoi   i   c                $   U(       a  [         R                  " U5      nO[        U [        5      (       d  [	        S5      e[
        R                  R                  U 5      nUR                  5       n[        R                  U/ 5       H*  nUR                  U5      (       d  M  US[        U5      *  n  O   [
        R                  R                  [         R                  " U5      5      n[         R                  " U5      nUR                  S5      (       d  US-  nUR                  S5      (       a  USS nUR                  S5      (       d*  [
        R                  R!                  U5      (       d  SU;   a  ["        R$                  " ['        S5      5      eU$ )	zSchoose prefix to use for names in archive.  make sure prefix is
safe for consumers.zdest must be bytes if no prefixN   /s   ./   s   ../s   /../s*   archive prefix contains illegal components)r   normpath
isinstancebytes
ValueErrorospathbasenamelowerextsgetendswithlen	localpathpconvert
startswithisabsr	   Abortr   )destkindprefixr   sfxlpfxs         4/usr/lib/python3/dist-packages/mercurial/archival.py
tidyprefixr,   2   s-    v&$&&>??!!$'88D"%C~~c""3s8), & 77DNN623D]]4 F??4  $   BGGMM$$7$77f;Lkk!IJKKM    s   .tars   .tbz2s   .tar.bz2s   .tgzs   .tar.gzs   .zips   .txzs   .tar.xz)   tar   tbz2   tgz   zip   txzc                |   ^  [         R                  5        H#  u  p[        U 4S jU 5       5      (       d  M!  Us  $    g )Nc              3  F   >#    U  H  nTR                  U5      v   M     g 7fN)r   ).0extr&   s     r+   	<genexpr>guesskind.<locals>.<genexpr>Y   s     8Zct}}S!!Zs   !)r   itemsany)r&   r'   
extensionss   `  r+   	guesskindr=   W   s1     JJL8Z888K ) r-   c                .    U  H  nX   s  $    U [            $ r5   r   )reporevs     r+   _rootctxrA   ^   s    y =r-   sy  
repo: {root}
node: {ifcontains(rev, revset("wdir()"), "{p1node}{dirty}", "{node}")}
branch: {branch|utf8}
{ifeq(latesttagdistance, 0, join(latesttag % "tag: {tag}", "\n"),
      separate("\n",
               join(latesttag % "latesttag: {tag}", "\n"),
               "latesttagdistance: {latesttagdistance}",
               "changessincelatesttag: {changessincelatesttag}"))}
c                   U R                  5       nSUR                  R                  SS[        5      0n[        R
                  " 5       n[        R                  " UR                  USU5      nUR                  5         UR                  U S9  UR                  [        U5      R                  5       S9  U R                  5       c'  SnU R                  SS	9(       a  S
nUR                  US9  UR                  5         UR                  5       $ )z!build content of .hg_archival.txts   templates   experimentals   archivemetatemplates   archivectx)rootr-   T)missing   +)dirty)r?   uiconfig_defaultmetatemplater   stringior
   	startitemcontextdatarA   hexr@   rH   endgetvalue)rD   r?   optsoutfmrH   s         r+   buildmetadatarV   v   s    88:D 	TWW^^35I
D --/C			TWWc:t	<BLLNJJ3JGG$##%G&
wwy99T9"E
eFFH<<>r-   c                  2    \ rS rSrSrSS	S jjrS rS rSrg)
tarit   z]write archive to tar file or stream.  can write uncompressed,
or compress with gzip or bzip2.c                   ^ ^^ TT l         S T l         S     SUUU 4S jjjn[        U[        5      (       a  U" SUS9T l        g U" SUS9T l        g )Nc                  > TS:X  ak  U SS n U(       d  [        XS-   5      n[        R                  " UU S-   [        R                  UTS9nUTl        [        R                  R                  USU5      $  [        R                   " XT-   U5      $ ! [        R                   a/  n[        R                  " [        R                  " U5      5      eS nAff = f)Ngzr   r   b)mtimew)opengzipGzipFilezlibZ_BEST_COMPRESSIONfileobjtarfileTarFiletaropenCompressionErrorr	   r%   r   forcebytestr)modenamere   	gzfileobjer'   r^   selfs        r+   rh   tarit.__init__.<locals>.taropen   s     t|Aay"44G MM3J++	  )..tS)DDB"<<Tk7CC// B++j&=&=a&@AABs   4B C"*CCzw:)rl   zw|)re   )r-   N)rk   strrl   r   returnztarfile.TarFile)r^   re   r   r   z)ro   r&   r^   r'   rh   s   ` `` r+   __init__tarit.__init__   sh    
 37	B	B"	B	B 	B, dE""T-DFT40DFr-   c                   [         R                  " U5      n[        R                  " U5      nU R                  Ul        [        U5      Ul        U(       aA  [        R                  Ul        SUl	        [         R                  " U5      Ul
        S nSUl        OX%l	        [        U5      nU R                  R                  XT5        g )N  r   )r   fsdecoderf   TarInfor^   r    sizeSYMTYPEtyperk   linknamerL   rs   addfile)ro   rl   rk   islinkrO   is         r+   r~   tarit.addfile   s      &OOD!**T__AFAF!**40AJDAFFD>Dqr-   c                    U R                   R                  5         U R                  (       a  U R                  R                  5         g g r5   )rs   closere   ro   s    r+   done
tarit.done   s+    <<LL  r-   )re   r^   rs   N) )r'   rq   	__name__
__module____qualname____firstlineno____doc__rt   r~   r   __static_attributes__ r-   r+   rX   rX      s    '1>  !r-   rX   c                  .    \ rS rSrSrSS jrS rS rSrg)	zipit   zYwrite archive to zip file or stream.  can write uncompressed,
or compressed with deflate.c                J   [        U[        5      (       a  [        R                  " U5      n[        R
                  " USU=(       a    [        R                  =(       d    [        R                  5      U l        SnX$:  a  UnX l	        [        R                  " U5      S S U l        g )Nr_   i    )r   r   r   rx   zipfileZipFileZIP_DEFLATED
ZIP_STOREDrs   r^   timegmtime	date_time)ro   r&   r^   compressepochs        r+   rt   zipit.__init__   sy    dE""$$T*D#x8G$8$8NG<N<N
 =E
U+BQ/r-   c                   [         R                  " [        R                  " U5      U R                  5      nU R
                  R                  Ul        SUl        [        nU(       a  Sn[        nX&-  S-  Ul        U=R                  [        R                  " SSSS[        U R                   5      5      -  sl        U R
                  R#                  XT5        g )N   rw      s   <hhBliUT     r   )r   ZipInfor   rx   r   rs   compressioncompress_typecreate_system
_UNX_IFREG
_UNX_IFLNKexternal_attrextrastructpackintr^   writestr)ro   rl   rk   r   rO   r   ftypes          r+   r~   zipit.addfile   s    OOH--d3T^^D&&,, DE<B. 	
6;;

O
 	
 	 r-   c                8    U R                   R                  5         g r5   )rs   r   r   s    r+   r   
zipit.done   s    r-   )r   r^   rs   N)Tr   r   r-   r+   r   r      s    #0 !.r-   r   c                  *    \ rS rSrSrS rS rS rSrg)fileit   z$write archive as files in directory.c                f    Xl         [        R                  " U R                   5      U l        X l        g r5   )basedirvfsmodr   openerr^   )ro   rl   r^   s      r+   rt   fileit.__init__   s     jj.
r-   c                   U(       a  U R                   R                  XA5        g U R                  USSS9nUR                  U5        UR                  5         [        R
                  R                  U R                  U5      n[        R                  " Xb5        U R                  b-  [        R                  " X`R                  U R                  45        g g )N   wF)
atomictemp)r   symlinkwriter   r   r   joinr   chmodr^   utime)ro   rl   rk   r   rO   fdestfiles          r+   r~   fileit.addfile  s    KK+KKduK5			77<<d3
 ::!HHX

DJJ78 "r-   c                    g r5   r   r   s    r+   r   fileit.done  s    r-   )r   r^   r   Nr   r   r-   r+   r   r      s    .

9r-   r   c                    [        XS5      $ )Nbz2rX   rl   r^   s     r+   <lambda>r         tE!:r-   c                    [        XS5      $ )Nr\   r   r   s     r+   r   r         d4 8r-   c                    [        XS5      $ )Nxzr   r   s     r+   r   r     r   r-   c                    [        XS5      $ )NF)r   r   s     r+   r   r     r   r-   )   filesr.   r/   r0   r2   s   uzipr1   c	                
  ^ ^^^^^^^^^^ T[         ;  a"  [        R                  " [        S5      T-  5      eTS:X  a'  T(       a  [        R                  " [        S5      5      eO[	        TTT5      mSmT U   mUUUUUUU U4S jmUUUUU 4S jmT(       d  [
        R                  " T 5      m[        TR                  5       R                  T5      5      n	[        U	5      n
U
(       a  U	R                  5         [
        R                  " T TR                  5       [
        R                  " T U	5      4/5        T R                  R!                  [        S5      [        S5      U
S9nUR#                  S	5        U	 HS  nTR%                  U5      nT" US
U;   =(       a    S=(       d    SSU;   TU   R&                  5        UR)                  US9  MU     UR+                  5         U(       ab  [-        TR.                  5       HI  nTR1                  U5      n[2        R4                  " UT5      nTU-   S-   nXR7                  TUUT5      -  n
MK     U
S	:X  a  [        R                  " [        S5      5      eTc   S5       eTR9                  5         U
$ )a_  create archive of repo as it was at node.

dest can be name of directory, name of archive file, a callable, or file
object to write archive to. If it is a callable, it will called to open
the actual file object before the first archive member is written.

kind is type of archive to create.

decode tells whether to put files through decode filters from
hgrc.

match is a matcher to filter names of files to write to archive.

prefix is name of path to put before every archive member.

mtime is the modified time, in seconds, or None to use the changeset time.

subrepos tells whether to include subrepos.
s   unknown archive type '%s'r   s*   cannot give prefix when archiving to filesNc                   > Tc  [        T5      (       a  T" 5       n OTn [        T   " U T=(       d    TR                  5       S   5      mTc   eTR                  R	                  SS5      (       a  SnT" U5      (       a  T	" USSU4S j5        T$ )zReturn the archiver instance, creating it if necessary.

This function is called when the first actual entry is created.
It may be called multiple times from different layers.
When serving the archive via hgweb, no errors should happen after
this point.
r   s   uis   archivemetas   .hg_archival.txt  Fc                    > [        T 5      $ r5   )rV   rC   s   r+   r   /archive.<locals>.opencallback.<locals>.<lambda>[  s
    -:Lr-   )callable	archiversdaterI   
configbool)
outputmetanamearchiverrD   r&   r'   r   r^   r?   r   s
     r+   opencallbackarchive.<locals>.opencallbackG  s     ~~ vu/E
1FH'''ww!!%88.??(E52LMr-   c                   > Tc  T" 5         Tc   S5       eU" 5       nT(       a  T	R                  X5      nTR                  TU -   XU5        g )Nzarchive should be opened by now)
wwritedatar~   )
rl   rk   r   getdatarO   r   decoder   r(   r?   s
        r+   r   archive.<locals>.write^  sN    N#F%FF#y??4.D$d;r-   s	   archiving)unittotalr      xi  r      l)itemr   s"   no files match the archive patternz&archive should have been opened before)r   r	   r%   r   r,   r   matchalllistmanifestwalkr    sortprefetchfilesr@   
matchfilesrI   makeprogressupdateflagsrO   	incrementcompletesortedsubstate
workingsubmatchmodsubdirmatcherarchiver   )r?   r&   noder'   r   r   r(   r^   subreposfilesr   progressr   ffsubpathsubsubmatch	subprefixr   rD   r   r   s   `` `````          @@@@r+   r   r     s"   > 9kk!89D@AAx++a MNOO  D$/H
t*C .< <   &$$U+,EJE

CGGIw11$>?@	
 77''lO!H+U ( 
 	A1B!TRZ)E2UDBJALA&  	cll+G..)C--gu=H(4/I[[y(FKKE	 , zkk!ABCCI!IIMMOLr-   )TNr-   NF)r?   zlocalrepo.localrepositoryr'   r   r   boolr(   r   r^   zOptional[float]r   r  rr   r   )+
__future__r   ra   r   r   rf   r   typingr   rc   r   i18nr   r   r   r   r	   r
   r   r   r   r   r   r   r   utilsr   TYPE_CHECKINGr   rL   r   r   r,   r   r=   rA   rK   rV   rX   r   r   r   r   r   r-   r+   <module>r     s[   #  	           	 == 

: I$j!Ij!	 B 66! 6!r, ,^ 2 :88:	  
!l
#l 	l
 l l l l 	lr-   