
    6hX              
      j   S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	J
r
  SSKJrJrJrJrJrJrJrJrJrJr  SSKJr  SS	KJrJr  S
SKJrJr  \R>                  r\R                  " 5       r \ RC                  SSSS\" S5      S4SSS\" S5      4/\" S5      SSS9S 5       r"S r#S r$S r%S r&S r'S r(S r)S  r*S.S! jr+S/S" jr,S# r- S0S$ jr.\ RC                  S%S&S'/ \" S(5      4/\R^                  -   \" S)5      5      S1S* j5       r0\ RC                  S+/ \R^                  -   \" S,5      5      S- 5       r1g)2z=High-level command function for lfconvert, plus the cmdtable.    )annotationsN)_)binhex)
cmdutilcontexterror	exthelperhglock
logcmdutilmatchscmutilutil)hashutil   )convcmdfilemap   )lfutilstorefactorys	   lfconvert   ss   size    s9   minimum size (MB) for files to be converted as largefiless   SIZEs	   to-normalFs/   convert from a largefiles repo to a normal repos#   hg lfconvert SOURCE DEST [FILE ...]T)norepo	inferrepoc                
  ^^ US   (       a  SnO(Sn[         R                  " U SUR                  S5      SS9n[        R                  " U5      (       d"  [
        R                  " [        S5      U-  5      e[        R                  " U5      (       d"  [
        R                  " [        S5      U-  5      e[        R                  " X5      mU R                  [        S5      U-  5        [        R                  " XSS	9nSnS=p U4S
 jTR                  R                  STR                  5       5      S    5       nTR                  UR                  0nU(       Ga!  UR                  5       n	UR                  5       n
[!        5       n[!        5       nU(       d   U R#                  [         R$                  S5      nU(       a,  [&        R(                  " TR*                  S[-        U5      5      nOSn0 nU R/                  [        S5      [        S5      TS   R1                  5       S9 nU H5  nUR3                  UR1                  5       5        [5        TUUUUUUWU5	        M7     SSS5        UR6                  R9                  [         R:                  5      (       a)  UR6                  R=                  [         R:                  5        UR?                  5        Hs  nUR6                  RA                  U5      (       a  UR6                  RC                  U5         UR6                  RE                  UR6                  RG                  U5      5        Mu     U(       a1  URJ                  RM                  S5        [N        RP                  " U5        O " U4S jS[R        RT                  5      m " U4S jS[V        RX                  5      n[[        U T5      u  nnUS:w  a  [
        R                  " [        S5      5      e[V        RX                  nU[V        l,         [V        R\                  " XUSSS9  U[V        l,        SnU(       aI  UR^                  Ra                  U5         UR^                  Rc                  5         SSS5        [e        X5        U(       d!  [f        R<                  " UR*                  5        gg! , (       d  f       GNK= f! [H         a     GM  f = f! U[V        l,        f = f! , (       d  f       Nv= f! U(       a[  UR^                  Ra                  U5         UR^                  Rc                  5         SSS5        O! , (       d  f       O= f[e        X5        U(       d!  [f        R<                  " UR*                  5        f f = f)a  convert a normal repository to a largefiles repository

Convert repository SOURCE to a new repository DEST, identical to
SOURCE except that certain files will be converted as largefiles:
specifically, any file that matches any PATTERN *or* whose size is
above the minimum size threshold is converted as a largefile. The
size used to determine whether or not to track a file as a
largefile is the size of the first version of the file. The
minimum size can be specified either with --size or in
configuration as ``largefiles.size``.

After running this command you will need to make sure that
largefiles is enabled anywhere you intend to push the new
repository.

Use --to-normal to convert largefiles back to normal files; after
this, the DEST repository can be used without largefiles at all.	to_normalFTsizeN)defaults    %s is not a local Mercurial repos   initializing destination %s
)createc              3  .   >#    U  H
  nTU   v   M     g 7fN ).0ctxrsrcs     =/usr/lib/python3/dist-packages/hgext/largefiles/lfcommands.py	<genexpr>lfconvert.<locals>.<genexpr>q   s      
I IIs   r   s   patternsr   s   converting revisionss	   revisionss   tipunittotals
   largefilesc                  8   >^  \ rS rSrU 4S jrU U4S jrSrU =r$ )lfconvert.<locals>.lfsource   c                t   > [         TU ]  XS 5        SU R                  R                  [        R
                  '   g )N   .)super__init__
filemapperrenamer   	shortname)selfuisource	__class__s      r'   r3   $lfconvert.<locals>.lfsource.__init__   s,    G$R6?CDOO**6+;+;<r   c                X  > Uu  p4[         TU ]  X5      nUR                  [        R                  5      (       a  US   c  U$ US   R                  5       n[        R                  " T	U5      nUc#  [        R                  " [        S5      X44-  5      e[        R                  " U5      US   4$ )Nr   s    missing largefile for '%s' in %sr   )r2   getfile
startswithr   shortnameslashstripfindfiler	   Abortr   r   readfile)
r7   namerevrealnamerealrevfhashpathr:   r&   s
           r'   r=   #lfconvert.<locals>.lfsource.getfile   s    (+%H2A %//0E0EFFQ4<  Q4::<D!??46D|#kkAB'12   ==.!44r   r#   )__name__
__module____qualname____firstlineno__r3   r=   __static_attributes____classcell__)r:   r&   s   @r'   lfsourcer.      s    D5 5r   rR   c                  ,   >^  \ rS rSrU U4S jrSrU =r$ )lfconvert.<locals>.converter   c                8   > T" X5      n[         TU ]  XX4U5        g r"   )r2   r3   )	r7   r8   r9   dest
revmapfileoptssrcr:   rR   s	          r'   r3   %lfconvert.<locals>.converter.__init__   s    "2.CG$RdEr   r#   )rL   rM   rN   rO   r3   rP   rQ   )r:   rR   s   @r'   	converterrT      s    F Fr   r\   s&   all largefiles must be present locallys   hg)source_type	dest_type)4r   
getminsizegetr   islocalr	   rB   r   
repositorystatus	changelognodesbetweenheadsnullidwlockr   set
configlistlongnamematchmodr   rootlistmakeprogressrE   update_lfconvert_addchangesetwvfsexistsr6   rmtreekeysisfileunlink
removedirsdirnameOSErrorrequirementsaddr   writereporequirementsr   filemap_sourcer   r\   downloadlfilesconvertdirstatechanging_parentsclearreleaseshutil)r8   rZ   rW   patsrY   tolfiler   rdstsuccessdstwlockdstlockctxsrevmaplfilesnormalfilesmatcherlfiletohashprogressr%   rH   r\   foundmissingorigrR   r&   s                           @@r'   	lfconvertr   3   s   P K  T488F+;TJ::c??kk!?@3FGG::dkk!?@4GHH==!DIIa01D89==$/DGHv%

~~224FqI
 ++t{{+ zz|HiikGUF%K}}V__kB"..CdDK)*|_6l&&( !  COOCGGI.+##
  & yy 0 011		  !1!12 %%'99##A&&II$$Q'II(():):1)=>	 ( !!%%m4--d35711 54FG-- F ,B5NE7!|kk!$M"NOO$$D )G)Tu %)!//5##% 6G&MM$))$ s 6  l %)!
 65 //5##% 655G&MM$))$ s    DS" <RB-S" 4R/;CS"  S S" S
R,'S" /
R>9S" =R>>S" SS" 
S"#U.T) 	U.)
T73;U.c	                *  ^^^ [        TT5      n	[        TU	5      n
/ nU
 GHX  nX;  a  X;  a  [        UTXg5      nUTR                  5       ;   aw  TR	                  U5      nUR                  5       nUc  SnU=(       a    X;   nUU-  nSUR                  5       ;   a+  U(       a"  [        R                  " [        S5      U-  5      eSnU(       a  UR                  U5        OUR                  U5        X;   Gaq  [        R                  " U5      nUR                  U5        UTR                  5       ;   Ga2  TR	                  U5      nSUR                  5       ;   a>  UR                  5       nU(       a'  X;   a"  [        R                  " [        S5      U-  5      e[        R                  " S5      nUR!                  TU   R#                  5       5        [%        UR'                  5       5      nUT;  d	  TU   U:w  al  UR)                  UTU   R#                  5       TU   R                  5       5        STU   R                  5       ;   n[        R*                  " UUUU5        UTU'   GMA  GMD  GMG  UR                  U5        GM[     UUU4S jn[-        XTUUT5        g )NF   ls+   renamed/copied largefile %s becomes symlinks   largefile %s becomes symlinkr      xc           
       > [         R                  " U5      nUb   TR                  U5      nUR                  5       nU(       a  [         R                  " U5      n[        R                  " U UUTU   S-   SUR                  5       ;   SUR                  5       ;   U5      $ [        U TUT5      $ ! [        R                   a     g f = f)N   
r   r   )r   splitstandinfilectxr	   LookupError
copysourcestandinr   
memfilectxflags_getnormalcontext)	repomemctxrH   srcfnamefctxrenamedr%   r   r   s	         r'   
getfilectx+_lfconvert_addchangeset.<locals>.getfilectx#  s    &&q){{8, oo'G !..1%%H%-

$

$  %T36::% $$ s   B, ,CC)_convertparents_getchangedfiles_islfilemanifestr   r   r   r	   rB   r   r|   r   r   appendr   sha1rp   datar   digestwwritewritestandin_commitcontext)r&   r   r%   r   r   r   r   r   r   parentsfilesdstfilesrH   islfiler   r   renamedlfilefstandinmrI   
executabler   s     ``    `             r'   rq   rq      s0    c6*G S'*EH?q3q#w5G CLLN"{{1~//+? $G&<7+<<'4::<'##kkLM   $G

1";~~a(HOOH%CLLN"{{1~4::<'"oo/G7#4#kk=>B 
 MM#&Q'188:K';q>T+AKK3q6;;=#a&,,.A!%Q!7J''hjI%)KN	 ,B #( OOAe h;8 4#xVDr   c                r   [         R                  " U UUR                  5       UUUR                  5       UR	                  5       UR                  5       5      nU R                  U5      n[        R                  " X5        U R                  U5        U R                  R                  5       XRR                  5       '   g r"   )r   r   descriptionuserdateextra	commitctxr   copyalltostore
setparentsrd   tipnode)r   r   r%   r   r   r   mctxrets           r'   r   r   B  s    >>

			D ..
C
$$OOC++-F88:r   c                0   [        U R                  5       5      nU R                  5       R                  U;  a^  U R	                  5       nU R                  5        H:  nUR	                  5       R                  U5       H  nUR                  U5        M     M<     U$ r"   )ri   r   r   rg   r   r   diffr|   )r%   r   r   mcpctxfns         r'   r   r   T  sn    		E
xxz'\\^KKMDmmo**2.		" / " Lr   c                   / nU R                  5        H$  nUR                  XR                  5          5        M&     [        U5      S:  a:  UR                  U R	                  5       R
                  5        [        U5      S:  a  M:  U$ )Nr   )r   r   r   lenr   rg   )r%   r   r   ps       r'   r   r   _  sc    G[[]vffh'( 
g,
sxxz(() g,
Nr   c           
     J    UR                  U5      nUR                  5       nUR	                  5       nUS:X  a  [        U R                  X65      n[        R                  " XX&SUR                  5       ;   SUR                  5       ;   U5      $ ! [        R                   a     g f = f)N   .hgtagsr   r   )
r   r	   r   r   r   _converttagsr8   r   r   r   )r   r%   rH   r   r   r   r   s          r'   r   r   i  s    {{1~ ooG99;DJDGGV21DDJJL0$$**,2F   s   B B"!B"c                   / nUR                  5        HF  n UR                  SS5      u  pV [        U5      n UR                  S[        X   5      U4-  5        MH     SR                  U5      $ ! [         a!    U R                  [	        S5      U-  5         M  f = f! [        R                   a!    U R                  [	        S5      U-  5         M  f = f! [         a!    U R                  [	        S5      U-  5         M  f = f)N    r   s&   skipping incorrectly formatted tag %s
s%   skipping incorrectly formatted id %s
s   %s %s
s   no mapping for id %s
r   )
splitlinessplit
ValueErrorwarnr   r   binasciiErrorr   r   KeyErrorjoin)r8   r   r   newdatalineidrD   newids           r'   r   r   y  s    G!	zz$*HB	GE	NN:V]);T(BBC "  88G  	GGA@ADHI	
 ~~ 	GGA?@2EF	
  	GGA/0256	s3   A.B!C.'BB1CC'C?>C?c                    U S:X  d  U S:X  d  U S:X  a  gU(       a  U" U 5      (       a  g UR                  U 5      R                  5       US-  S-  :  $ ! [        R                   a     gf = f)zhReturn true if file should be considered a largefile, i.e.
matcher matches it or it is larger than size.r   s	   .hgignores   .hgsigsFTi   )r   r   r	   r   )filer%   r   r   s       r'   r   r     sn     zT\1TZ5G74=={{4 %%'4$;+=== s   'A A)(A)c                   U(       d  g[         R                  " XSS9nSnU R                  S[        U5      -  5        UR	                  U5      nU Vs/ s H  ovU   (       a  M  UPM     nnU R                  S[        U5      -  5        U R                  [        S5      [        S5      [        U5      S	9 nU Hi  n	UR                  U5        [        R                  " X5      n
U
(       d"  [        R                  " [        S
5      U	-  5      eUR                  X5        US-  nMk     SSS5        gs  snf ! , (       d  f       g= f)z&upload largefiles to the central storeNT)putr   s,   sending statlfile command for %d largefiles
s"   %d largefiles need to be uploaded
s   uploading largefiless   filesr*   s6   largefile %s missing from store (needs to be uploaded)r   )r   	openstoredebugr   rs   ro   r   rp   r   rA   r	   rB   r   )r8   r&   r   r   storeatretvalhr   rI   r9   s              r'   uploadlfilesr     s    ""448E	
BHH=E
JK\\% F/1AYQE/HH3c%j@A		
!"8CJ 
 
	DOOB__T0Fkk3 	  IIf#!GB 
 
 0
 
s   D-#D-4A0D22
E c                    U(       a  UR                  S5      nOS/n[        R                  " U5      nUR                  XCS9$ )a  Verify that every largefile revision in the current changeset
exists in the central store.  With --contents, also verify that
the contents of each local largefile file revision are correct (SHA-1 hash
matches the revision ID).  With --all, check every changeset in
this repository.s   all()r1   )contents)revsr   r   verify)r8   r   allr   r   r   s         r'   verifylfilesr     s=     yy"v""4(E<<<00r   c                   [         R                  " X5      nU(       a  [        U5      [        U5      -  n/ nX   nU H`  n [         R                  " U[         R                  " U5         5      n[         R                  " X5      (       a  MN  UR                  Xx45        Mb     U(       a)  [        R                  " U5      n	U	R                  U5      n
U
$ / / 4$ ! [
         a     M  f = f)a  cachelfiles ensures that all largefiles needed by the specified revision
are present in the repository's largefile cache.

returns a tuple (cached, missing).  cached is the list of files downloaded
by this operation; missing is the list of files that were needed but could
not be found.)r   
listlfilesri   readasstandinr   FileNotFoundErrorrA   r   r   r   r`   )r8   r   r   filelistr   togetr%   lfileexpectedhashr   r   s              r'   cachelfilesr     s     t*FVs8},E
*C	!//FNN54I0JKL t22LL%./  &&t,ii
8O ! 		s   -C
C#"C#c                p   UR                   R                  nSnSnUR                  SS[        R                  -   5       H3  n[        XU" U5      5      u  pgU[        U5      -  nU[        U5      -  nM5     U R                  [        S5      U-  5        US:  a  U R                  [        S5      U-  5        X44$ )Nr   s   file(%s)s   path:s    %d additional largefiles cached
s!   %d largefiles failed to download
)	rd   r   r   r   r6   r   r   rc   r   )r8   r   tonodetotalsuccesstotalmissingrE   r   r   s           r'   r   r     s    ^^  FLLyyh1A1A&AB&r=G$G$ C IIa45DEa
		!9:\IJ%%r   c           	     	   [         R                  " XU5      nUR                  5          [         R                  " X5      n[	        [         R
                  " U5      5      [	        U5      -  nUb$  [	        U5      nU Vs/ s H  oU;   d  M
  UPM     nn0 n	[	        5       n
Su  pUR                  nUS   nU GH  n[        R                  R                  [        R                  " XU5      UR                  S9n[         R                  " U5      n[        R                  R                  [        R                  " XU5      UR                  S9nUR                  U5      (       a  UR                  U5      (       a\  UR                  U5      (       aF  [        R                   " UR#                  U5      UR#                  U5      5        UR%                  U5        [         R&                  " UU   5      nUS:w  aj  X;  aL  UR(                  R+                  U5      R,                  (       a  UR%                  USS9  OU
R/                  U5        UR1                  USSSS9  UX'   GM  GM  UR                  U5      (       d  GM  UR(                  R3                  U5      U;  d  GM  UR%                  U5        US-  nGM     UR5                  UR7                  5       5        U(       a  U Vs/ s H  oU
;  d  M
  UPM     nnU
 HM  nUR                  R%                  [         R                  " U5      5        UR8                  R;                  U5        MO     U" [=        S	5      5        [?        XSU5        U GH  nS
nU	RA                  U5      nU(       a2  [         RB                  " UUU5      (       d  M=  UR1                  USSS9  Sn[         R                  " U5      nUR                  U5      (       a  URE                  U5      RF                  S-  nURE                  U5      nURF                  nUUS-  :w  a=  US-  nU(       a  UUS-	  S-  [H        RJ                  ) -  -  nURM                  UU5        SnUU-  n[         RN                  " XX5        GM     UR5                  UR7                  5       5        U(       a  U" [=        S5      X4-  5        SSS5        gs  snf s  snf ! , (       d  f       g= f)zUpdate largefiles according to standins in the working directory

If ``printmessage`` is other than ``None``, it means "print (or
ignore, for false) message forcibly".
N)r   r   )startr   T)ignoremissing)
p1_tracked
wc_trackedpossibly_dirtyr   s   getting changed largefiles
r   )r  r  @   ir   I   s"   %d largefiles updated, %d removed
)(r   getstatuswriterrh   openlfdirstateri   r   rr   osrJ   relpathr   
backuppathrm   r   rs   r   copyfiler   
unlinkpathr   r   	get_entryany_trackedr|   hacky_extension_update_file	normalizewritecurrenttransaction_mapreset_stater   r   r`   copyfromcachestatst_moder   umaskchmodsynclfdirstate)r8   r   r   printmessagenormallookupstatuswriter
lfdirstater   rH   rp   droppedupdatedremovedrr   wctxr   	lfileorigr   standinorig
expecthashupdate1standinexecstmodes                           r'   updatelfilesr-    s    ))"LAL	**24
V&&t,-J?8}H!'9A=aF9%yyDzE""2U3499 ( I nnU+G''//""2W5TYY * K {{7##;;{++E0B0BOODIIe$4dii	6JKOOK0#11$w-@
$(==227;GG OOEOF#KK.
 ::#'#''+	 ;  %/FM! %. KK&&//6dBOOE*qLGQ V 	0023!'<AG+;aF<		$$V^^A%67 ++A.	  :;<$/EGE*J++D*eDD 66## 7 
  nnU+G{{7##"ii0885@YYu%zz$,.FND"e 3tzzk AAJJud+GwG!!$EHG J 	002389W<NN[ 
 :j =w 
sE   AS<	S	SG!S5SAS	S)S/GS
S
Ss   lfpull   rs   revs#   pull largefiles for these revisionss-   -r REV... [-e CMD] [--remotecmd CMD] [SOURCE]c                n   X!l         UR                  S/ 5      nU(       d  [        R                  " [	        S5      5      e[
        R                  " X5      nSnU H<  nU R                  [	        S5      U-  5        [        XU5      u  pxU[        U5      -  nM>     U R                  [	        S5      U-  5        g)a  pull largefiles for the specified revisions from the specified source

Pull largefiles that are referenced from local changesets but missing
locally, pulling from a remote repository to the local cache.

If SOURCE is omitted, the 'default' path will be used.
See :hg:`help urls` for more information.

.. container:: verbose

  Some examples:

  - pull largefiles for all branch heads::

      hg lfpull -r "head() and not closed()"

  - pull largefiles on the default branch::

      hg lfpull -r "branch(default)"
rE   s   no revisions specifiedr   s#   pulling largefiles for revision %d
s   %d largefiles cached
N)lfpullsourcer`   r	   rB   r   r   revrangenoter   r   rc   )	r8   r   r9   rY   r   	numcachedrE   cachedr   s	            r'   lfpullr5  r  s    6 88E2Dkk!5677t*DI
9:S@A'#6S[ 	  IIa)*Y67r   s
   debuglfputs   FILEc                    [         R                  " U5      n[        R                  " U5      R	                  X$5        U R                  SU-  5        g)Ns   %s
r   )r   hashfiler   r   r   r  )r8   r   filepathkwargsrI   s        r'   
debuglfputr:    s<    ??8$D4 $$X4HHWt^r   )FFr"   )NNF)s   default)2__doc__
__future__r   r   r  r   mercurial.i18nr   mercurial.noder   r   	mercurialr   r   r	   r
   r   r   r   r   rl   r   r   mercurial.utilsr   r   r   r    r   r   r   ehcommandr   rq   r   r   r   r   r   r   r   r   r   r   r-  
remoteoptsr5  r:  r#   r   r'   <module>rE     s   D "  	  
   %
 #
,,   JK	
 @A		
 ,-'  *Z%+*Z%zZEz.$ *B1:& >Cxv 
FB@ABC67	!8!8H M2 2 22AgJ? @r   