
    q&fVi                     &   d Z ddlZddlZddlZddlZddlm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 ddlmZ ddlmZ d	Zed
z   ZdZej@                  d;d       Z!d<dZ"d Z#d Z$efdZ%d Z&d Z' G d dej                        Z(d;dZ)d Z*d=dZ+d>dZ,d>dZ-d Z.d Z/d Z0d Z1d Z2d Z3d?d Z4d! Z5d" Z6d# Z7d$ Z8d% Z9d& Z:d' Z;d( Z<d) Z=d* Z>d+ Z?d, Z@d- ZAd. ZBd/ ZC G d0 d1eD      ZEd2 ZFd3 ZGd4 ZHd5 ZId6 ZJd7 ZK G d8 d9      ZLd?d:ZMy)@zGlargefiles utility code: must not import other modules in this package.    N)_)hex)open)dirstateencodingerrorhttpconnectionmatchpycompatrequirementsscmutilsparseutilvfs)hashutil)	timestamps   .hglf   /
   largefilesc              #   d   K   t        | dd      }|| _        	 d  || _        y # || _        w xY ww)NlfstatusF)getattrr   )repovalueoldvalues      9/usr/lib/python3/dist-packages/hgext/largefiles/lfutil.pyr   r   +   s1     tZ/HDM! s   0$ 0	-0c                     |}|s|r| j                  t        d|      }|r	 t        |      }|t	        j
                  t        d            |S # t        $ r" t	        j
                  t        d      |z        w xY w)Ns   minsize)defaults)   largefiles: size must be number (not %s)
s-   minimum size for largefiles must be specified)configlongnamefloat
ValueErrorr   Abortr   )uiassumelfilesoptr   lfsizes        r   
getminsizer'   5   s    Fl8ZA	6]F
 ~kk!LMNNM  	++?@6I 	s   A +A:c                    t        j                  t        j                  j	                  |             	 t        j
                  | |       y# t        $ r t        | d      5 }t        j                  |      5 }t        j                  |      D ]  }|j                  |        	 ddd       n# 1 sw Y   nxY wddd       n# 1 sw Y   nxY wt        j                  |t        j                  |       j                         Y yw xY w)z@Try to create hardlink - if that fails, efficiently make a copy.   rbN)r   makedirsospathdirnameoslinkOSErrorr   atomictempfilefilechunkiterwritechmodstatst_mode)srcdestsrcfdstfchunks        r   linkr;   E   s    MM"''//$'(-C -#u 	"t':':4'@ 	"D++D1 "

5!"	" 	" 	" 	" 	" 	" 	rwws|++,-sA   A D C6,B,#	C,B51C8	DC
	:DDc                 T    t         j                  j                  t        |       |      S )zReturn the correct location in the "global" largefiles cache for a file
    with the given hash.
    This cache is used for sharing of largefiles across repositories - both
    to preserve download bandwidth and storage space.)r+   r,   join_usercachedir)r#   hashs     r   usercachepathr@   R   s    
 77<<b)400    c                    | j                  |d      }|r|S d}t        j                  rrt        j                  j                  dt        j                  j                  d            }|r t        j                  j                  ||      S t        d      dd|fz  }n8t        j                  rTt        j                  j                  d      }|r"t        j                  j                  |dd|      S t        d	      d|fz  }nt        j                  rt        j                  j                  d
      }|r t        j                  j                  ||      S t        j                  j                  d      }|r!t        j                  j                  |d|      S t        d      d
d|fz  }n/t        j                  t        d      t        j                  z        t        j                  t        d      |z  |      )z5Return the location of the "global" largefiles cache.s	   usercacheNs   LOCALAPPDATAs   APPDATAs7   define %s or %s in the environment, or set %s.usercaches   HOMEs   Librarys   Cachess1   define %s in the environment, or set %s.usercaches   XDG_CACHE_HOMEs   .caches   unknown operating system: %s
s   unknown %s usercache location)hint)
configpathr   	iswindowsr   environgetr+   r,   r=   r   isdarwinisposixr   r"   osname)r#   namer,   rC   appdatahomes         r   r>   r>   Z   s   ==|,DD""&&X--11*=
 77<<..KLP
 

 
		##G,77<<j)TBBEFJ
 
 
		##$5677<<d++##G,77<<i66KLP
 
 kk/08??B
 	
 ++a89D@t
LLrA   c                 X    t        | |      }t        j                  j                  |      S N)r@   r+   r,   exists)r#   r?   r,   s      r   inusercacherQ      s!    T"D77>>$rA   c                 N   t        | |      \  }}|r)| j                  j                  t        d      |z         |S t	        | j                  |      rU| j                  j                  t        d      |z         t        | |      }t        t        | j                  |      |       |S y)zReturn store path of the largefile with the specified hash.
    As a side effect, the file might be linked from user cache.
    Return None if the file can't be found locally.s   found %s in store
s   found %s in system cache
N)findstorepathr#   noter   rQ   	storepathr;   r@   )r   r?   r,   rP   s       r   findfilerV      s     !t,LD&Q-.56	TWWd	#Q45<=t$]477D)40rA   c                        e Zd ZdZdZ fdZ fdZ fdZd fd	Z fdZ	 fdZ
 fd	Z fd
Z fdZd Z fdZ xZS )largefilesdirstateTs   -large-filesc                 <    t         t        |   t        |            S rO   )superrX   __getitem__unixpath)selfkey	__class__s     r   r[   zlargefilesdirstate.__getitem__   s    ':8C=IIrA   c                 <    t         t        |   t        |            S rO   )rZ   rX   set_trackedr\   r]   fr_   s     r   ra   zlargefilesdirstate.set_tracked   s    ':8A;GGrA   c                 <    t         t        |   t        |            S rO   )rZ   rX   set_untrackedr\   rb   s     r   re   z largefilesdirstate.set_untracked   s    '<Xa[IIrA   c                 <    t         t        |   t        |            S rO   )rZ   rX   normalr\   )r]   rc   parentfiledatar_   s      r   rg   zlargefilesdirstate.normal   s     '5hqkBBrA   c                 <    t         t        |   t        |            S rO   )rZ   rX   remover\   rb   s     r   rj   zlargefilesdirstate.remove       '5hqkBBrA   c                 <    t         t        |   t        |            S rO   )rZ   rX   addr\   rb   s     r   rm   zlargefilesdirstate.add   s    '28A;??rA   c                 <    t         t        |   t        |            S rO   )rZ   rX   dropr\   rb   s     r   ro   zlargefilesdirstate.drop   s    '3HQK@@rA   c                 <    t         t        |   t        |            S rO   )rZ   rX   forgetr\   rb   s     r   rq   zlargefilesdirstate.forget   rk   rA   c                 <    t         t        |   t        |            S rO   )rZ   rX   normallookupr\   rb   s     r   rs   zlargefilesdirstate.normallookup   s    ';HQKHHrA   c                      yNF )r]   rc   s     r   _ignorezlargefilesdirstate._ignore   s    rA   c                 V    |r|j                  dd       t        t        |   d        y )Ns   largefiles/dirstates   plain)location)	addbackuprZ   rX   r2   )r]   trr_   s     r   r2   zlargefilesdirstate.write   s)     LL/(LC $-d3rA   rO   )__name__
__module____qualname___large_file_dirstate_tr_key_suffixr[   ra   re   rg   rj   rm   ro   rq   rs   rw   r2   __classcell__)r_   s   @r   rX   rX      sS    $NJHJC
C@ACI4 4rA   rX   c           	      X   t        j                  dd      }||S j                  }t        }t	        j                  |j                  |            }t        j                  j                  v }t        || j                  j                  j                  fdj                  |      }|r|j                  |j                  |d            s	 j                  d      5  |j                        5  t              }	j                  j!                  |	g dd      }
t#        |
      dkD  r|j%                  |       |
D ]"  }t'        |      }|j)                  |d	d	d	
       $ 	 ddd       ddd       |S |S # 1 sw Y   xY w# 1 sw Y   |S xY w# t*        j,                  $ r Y |S w xY w)z
    Return a dirstate object that tracks largefiles: i.e. its root is
    the repo root, but it is saved in .hg/largefiles/dirstate.

    If a dirstate object already exists and is being used for a 'changing_*'
    context, it will be returned.
    _sub_dirstateNc                  .    t        j                         S rO   )r   matcher)r   s   r   <lambda>z openlfdirstate.<locals>.<lambda>   s    t$ rA   s   dirstateF)waitsubreposunknownignoredr   T)
p1_tracked
wc_trackedpossibly_dirty)r   r   r   r   vfsmodr=   r   DIRSTATE_V2_REQUIREMENTrX   root	_validatenodeconstantsrP   wlockchanging_filesgetstandinmatcherwalklenr*   splitstandinhacky_extension_update_filer   	LockError)r#   r   createsub_dirstater   
lfstorediropeneruse_dirstate_v2
lfdirstater   standinsstandinlfiles    `           r   openlfdirstater      s    4==/4@L
((CJZZ,-F"::d>O>OOO#
		$J cjj*k!BC	' )B)B4)H +D1==--b% .  x=1$LL,' G(1E::#'#''+	 ;  , :-  ,   	 	sI   F !F3A1E9%F-F 9F	>FF
F F F)(F)c                 @   |d   }t        j                         }| j                  |g ddd      \  }}}|j                  |j                  }}|d    }	|D ]  }
	 |t        |
         }|r&t        |      t        |j                  |
            k7  r|j                  |
       L|j                  |
       |	|
   j                         }|j                  }|j                  }t        j                  ||      }||||f}| j!                  |
|        |S # t        $ r d }Y w xY w)N   .Fr   r   cleanr   )matchmodalwaysstatusmodifiedr   r   LookupErrorreadasstandinhashfilewjoinappendlstatr5   st_sizer   reliable_mtime_of	set_clean)r   r   pctxr
   unsuresmtime_boundaryr   r   wctxr   fctxstmodesizemtime
cache_datas                    r   lfdirstatestatusr     s(   :DOOE * 1 1E !2 !FA~ jj!''eH:D 8	'D }T*htzz%7H.IIOOE"LLe""$B::D::D//NCE "D%0
$$UJ78  H  	D	s   DDDc                     |t        |       }| |   j                  |      D cg c]4  }|%| j                  j                  |      j                  rt        |      6 c}S c c}w )zNreturn a list of largefiles in the working copy or the
    specified changeset)r   r   r   	get_entryany_trackedr   )r   revr   rc   s       r   
listlfilesr      sb     #D)
 c(?dmm55a8DD 	Q  s   9A c                 V    t         j                  j                  t        | ||            S )zBReturn true if a largefile with the given hash exists in the store)r+   r,   rP   rU   r   r?   
forcelocals      r   instorer   /  s    77>>)D$
;<<rA   c                     |s;| j                         r+| j                  j                  | j                  t        |      S | j                  j                  t        |      S )zbReturn the correct location in the repository largefiles store for a
    file with the given hash.)sharedr   reljoin
sharedpathr   r=   r   s      r   rU   rU   4  sA     $++-xx4@@88==4((rA   c                     t        | |d      }t        | |      r|dfS | j                         rt        | |d      rt        | |d      dfS |dfS )zSearch through the local store path(s) to find the file for the given
    hash.  If the file is not found, its path in the primary store is returned.
    The return value is a tuple of (path, exists(path)).
    FT)rU   r   r   r   r?   r,   s      r   rS   rS   <  sX     T4'DtTd|	74t4tT*D00%=rA   c                    | j                   }t        | |      }|y|j                  |j                  |j	                  |                   t        |d      5 } ||d      5 }t        t        j                  |      |      }ddd       ddd       |k7  r<| j                  j                  t        d      |||fz         |j                  |       yy# 1 sw Y   SxY w# 1 sw Y   WxY w)a.  Copy the specified largefile from the repo or system cache to
    filename in the repository. Return true on success or false if the
    file was not found in either cache (which should not happened:
    this is meant to be called only after ensuring that the needed
    largefile exists in the cache).NFr)   s   wbs'   %s: data corruption in %s with hash %s
T)wvfsrV   r*   r-   r=   r   copyandhashr   r1   r#   warnr   unlink)r   r?   filenamer   r,   srcfddestfdgothashs           r   copyfromcacher   N  s     99DD$D|MM$,,tyy234 
dE	 AeT(E%: Afd007@A A$9:w'(	
 	HA A A As$   
C! CCC	CC(c                     | j                   }t        ||         }t        | |      ry |j                  |      rt	        | |j                  |      |       y | j                  j                  t        d      ||fz         y )Ns0   %s: largefile %s not available from local store
)	r   r   r   rP   copytostoreabsoluter=   r#   r   r   )r   ctxfilefstandinr   r?   s         r   copytostorer   g  sk    99DX'DtT{{4D$))D/48BCTl	
rA   c                     | |   }|j                         D ]1  }t        |      }|||j                         v s$t        | |||       3 y)z4Copy all largefiles in a given revision to the storeN)filesr   manifestr   )r   noder   r   realfiles        r   copyalltostorer   u  sM     t*CIIK 7)H$>c8X67rA   c                 D   t        | j                  |      r+t        t        | j                  |      t	        | |             y t        j                  t        j                  j                  t	        | |                   t        |d      5 }t        j                  t	        | |      | j                  j                        5 }t        j                  |      D ]  }|j                  |        	 d d d        d d d        t!        | |       y # 1 sw Y   xY w# 1 sw Y   "xY w)Nr)   )
createmode)rQ   r#   r;   r@   rU   r   r*   r+   r,   r-   r   r0   storer   r1   r2   linktousercache)r   r   r?   r8   r9   r:   s         r   r   r     s    477D!]477D)9T4+@Abggooid&;<=$ 	&$$$$%$**2G2G &!//5 &EJJu%&&	& 	d#& &	& 	&s$   
6D ,D
-D
D	DDc                 \    t        | j                  |      }t        t        | |      |       y)zRLink / copy the largefile with the specified hash from the store
    to the cache.N)r@   r#   r;   rU   r   s      r   r   r     s%     $'D4	%rA   c                 p   | j                   }t        }d }|rn|j                         s^|j                         D cg c]  }|j	                  ||       }}|s|j	                  |      g}t        j                  | d   ||      }|S t        j                  | d   |j	                  |      g|      }|S c c}w )zDReturn a match object that applies rmatcher to the standin directoryc                      y rO   rv   )rc   msgs     r   r   z#getstandinmatcher.<locals>.<lambda>      rA   N)badfn)r   	shortnamer   r   r=   r   r
   )r   rmatcherr   
standindirr   patpatsr
   s           r   r   r     s    99DJ  E)6>nn6FGs		*c*GGIIj)*Dd4j$e< L d4j499Z+@*AOL Hs   B3c                 T    t        |       }|j                  fd}||_        |S )zReturn a matcher that accepts standins corresponding to the
    files accepted by rmatcher. Pass the list of files in the matcher
    as the paths specified by the user.c                 L     |       xr j                  t        |             S rO   )matchfnr   )rc   	isstandinr   s    r   composedmatchfnz.composestandinmatcher.<locals>.composedmatchfn  s!    |A 0 0a AArA   )r   r   )r   r   smatcherr   r   s    `  @r   composestandinmatcherr     s1     !x0H  IB 'HOrA   c                 :    t         t        j                  |       z   S )zLReturn the repo-relative path to the standin for the specified big
    file.)shortnameslashr   pconvertr   s    r   r   r     s     DMM(333rA   c                 ,    | j                  t              S )zsReturn true if filename is a big file standin. filename must be
    in Mercurial's internal form (slash-separated).)
startswithr   r  s    r   r   r     s     ~..rA   c                     t        j                  |       j                  dd      }t        |      dk(  r|d   t        k(  r|d   S y )Nr         r   )r   r   splitr   r   )r   bitss     r   r   r     sA     =="((q1D
4yA~$q'Y.AwrA   c                     | j                  |      }| j                  j                  |      r%t        |      }t	        |      }t        | |||       yt        j                  t        d      |z        )zRe-calculate hash value of lfile and write it into standin

    This assumes that "lfutil.standin(lfile) == standin", for efficiency.
    s   %s: file not found!N)	r   r   rP   r   getexecutablewritestandinr   r"   r   )r   r   r   r   r?   
executables         r   updatestandinr    s_    
 ::eDyy~"4(
T7D*5kk!23e;<<rA   c                 >    | j                         j                         S )zxread hex hash from given filectx of standin file

    This encapsulates how "standin" data is stored into storage layer.)datastrip)r   s    r   r   r     s     99;rA   c                 @    | j                  ||dz   |xr dxs d       y)z#write hash to <repo.root>/<standin>   
   xrA   N)wwrite)r   r   r?   r  s       r   r  r    s     KKz':d'AcBrA   c                     t        j                  d      }| D ]$  }|j                  |       |j                  |       & t	        |j                               S )zRead bytes from instream (iterable) and write them to outfile,
    computing the SHA-1 hash of the data along the way. Return the hash.rA   )r   sha1updater2   r   digest)instreamoutfilehasherr  s       r   r   r     sL     ]]3F dd v}}rA   c                     t         j                  j                  |       syt        | d      5 }t	        |      cd d d        S # 1 sw Y   y xY w)NrA   r)   )r+   r,   rP   r   hexsha1)r   fds     r   r   r     s=    77>>$	dE	 br{  s   AAc                     t        j                  |       j                  }|t        j                  z  xr( |t        j                  z  xr |t        j
                  z  S rO   )r+   r4   r5   S_IXUSRS_IXGRPS_IXOTH)r   r   s     r   r
  r
    sI    778$$D		 	"DLL 	"DLL rA   c                 >    d } || |      }|D ]  } |||      } |S )Nc                 d    | j                  d      s| dz  } |j                  d      r|dd  }| |z   S )Nr   r  )endswithr  )leftrights     r   r=   zurljoin.<locals>.join	  s:    }}T"DLDD!!"IEe|rA   rv   )firstsecondargr=   urlas         r   urljoinr-    s4     uf
C 3lJrA   c                     t        j                         }t        j                  |       D ]  }|j	                  |        t        |j                               S )zUhexsha1 returns the hex-encoded sha1 sum of the data in the file-like
    object data)r   r  r   r1   r  r   r  )fileobjhr:   s      r   r  r    sD     	A##G, 	qxxz?rA   c                 0    t        j                  | |d      S )Nr)   )r	   httpsendfile)r#   r   s     r   r2  r2    s    &&r8U;;rA   c                 f    t        j                  t        j                  j	                  |             S )z@Return a version of path normalized for use with the lfdirstate.)r   r   r+   r,   normpath)r,   s    r   r\   r\   #  s     ==))$/00rA   c                     d| j                   v r@| j                  j                         D ]#  }|j                  st        |j
                  v s# y t        t        | j                  | d            S )z,Return true if the repo is a largefile repo.r   TF)	r   r   data_entries	is_revlogr   	target_idanyr   r#   )r   entrys     r   islfilesrepor;  (  s[    )))ZZ,,. 	E>U__#D	 ~dggtU344rA   c                       e Zd Zd Zy)storeprotonotcapablec                     || _         y rO   )
storetypes)r]   r?  s     r   __init__zstoreprotonotcapable.__init__3  s	    $rA   N)r|   r}   r~   r@  rv   rA   r   r=  r=  2  s    %rA   r=  c                     g }t        |       }| d    }| j                  j                  |g dd      D ]/  }t        |      }	 t	        ||         }|j                  ||f       1 |S # t
        $ r d }Y $w xY w)NFr   )r   r   r   r   r   IOErrorr   )r   r   r   r   r   r   r?   s          r   getstandinsstaterC  7  s    H%G:D==%%"eU &  ' W%	 g/D 	&' O  	D	s   A&&A43A4c                     t        |      }|| j                  vr|j                  |dd       y | j                  j                  |      }|j                  ||j                  |j
                  |j                  d       y )NF)r   r   T)r   r   p2_infor   )r   r   r   r   trackedr   rE  )r   r   r   rs   	lfstandinr:  s         r   synclfdirstaterH  G  sy    I%.. 	/ 	
 ''	2..}}''MM 	/ 	
rA   c                 <   |j                         }|j                  j                  |      5   | |       t        |j                  |      }|j                         D ]  }t        |      }|t        |||d         	 d d d        t        ||       y # 1 sw Y   xY wru   )	r   r   changing_parentsr   r#   r   r   rH  r   )origr   r   r   r   rc   r   s          r   markcommittedrL  Z  s    88:D		'	'	- ?T
 $DGGT2
 	?A OE tZ>	??0 41? ?s   ?B,BBc                     t        |       j                  t        |            }g }|D ]  }|d   |vs|j                  |d            |S )Nr   )setsymmetric_differencer   )oldstandinsnewstandinschangedstandinsfilelistrc   s        r   getlfilestoupdaterT  x  sS    +&;;C<LMOH "Q4xOOAaD!" OrA   c           
         | j                   j                  } |t        d      t        d      t        |            5 }t	        |      D ]  \  }}|j                  |       | |   j                         D cg c]  }|| j                  k7  s| }}t        | d      5  | |   }	d d d        t        	j                               }
t        |      dk(  r|	j                         }|	j                         j                         }|	j                         j                         }|D ]  }||vs|
j                  |        |D ]  }||vs|
j                  |        |D ]D  }||   |j                  |d       k7  s||   |j                  |d       k7  s4|
j                  |       F |
D ](  }t!        |      s||	v s ||t#        |	|                *  	 d d d        y c c}w # 1 sw Y   ?xY w# 1 sw Y   y xY w)Ns   finding outgoing largefiless	   revisions)unittotalF)r   r  )r#   makeprogressr   r   	enumerater  parentsnullidr   rN  r   r   p1p2rm   rG   r   r   )r   missingaddfuncrX  progressinprZ  r   r   mcmp1mp2rc   fns                   r   getlfilestouploadrh    s   77''L		
()|_'l
 8 
g& 	8DAqOOA"&q'//"3HQqDKK7GqHGH$e, 1g 		$E7|q \\^ffh'')ffh'') %A{		!%  %A{		!%  %A!u4 00BqESWWQ=M4M		!%  8R=R3YBc"g 678+	88 8 I 8 8s[   9G.6GGG.G!$BG.)G.AG.#G.3G.8G.G.!G+&G..G7c                    | j                   }||j                         rt        j                         }| j                  j	                  |       5  t        ||       }|j                  |g ddd      \  }}}ddd       j                  z   |j                  z   |j                  z   }t        |       D ]W  }	|	|v st        |	      }
| j                  j                  |
      s/| j                  j                  |	      sKt        | |	|
       Y |S t        |       | j                  |j!                               |_        t%        | |      }| j                  j'                  |g dd      s|S t        ||       }D ]6  }
t)        |
      }	|j+                  |	      j,                  s*t        | |	|
       8 t/        j.                  |      }|j0                  |xj"                  t3              z  c_        g }|j"                  D ]  }t        |      }
|v s|
v rq| j                  j+                  |
      j                  s&| j                  j+                  |      j                  s'a| j                  j+                  |      j4                  s|j7                  |        ||_        fd}||_        |S # 1 sw Y   @xY w)zUpdate standins in the working directory according to specified match

    This returns (possibly modified) ``match`` object to be used for
    subsequent commit process.
    NFr   r   c                 $     |       r| vS | v S rO   rv   )rc   lfilesorigmatchfnr   s    r   r   z&updatestandinsbymatch.<locals>.matchfn  s    q>F?"= rA   )r#   r   r   r   running_statusr   r   r   addedremovedr   r   r   rP   r  
_subdirlfsr   _filesr   r   r   r   rF  copyr   sortedr   r   )r   r
   r#   
dirtymatchr   r   r   r   modifiedfilesr   r   r   actualfilesrc   r   rk  rl  r   s                  @@@r   updatestandinsbymatchrw    s    
B
 } __&
]]))$/ 	'D1J(2(9(9 ): )%FA~	 +agg5		AD!  	=E%"5>99##H- yy''.%dE8<	= F??5;;=&9EL %T51H}}!!2ue " H   D)J 1X&&..$x01 IIeE--K
 
LLF8$$LK\\ 1: ;(h.==**84<<}}..q199]],,Q/;;1 EL! EMLs	 	s   'J66K c                       e Zd ZdZd Zd Zy)automatedcommithooka  Stateful hook to update standins at the 1st commit of resuming

    For efficiency, updating standins in the working directory should
    be avoided while automated committing (like rebase, transplant and
    so on), because they should be updated before committing.

    But the 1st commit of resuming automated committing (e.g. ``rebase
    --continue``) should update them, because largefiles may be
    modified manually.
    c                     || _         y rO   )resuming)r]   r{  s     r   r@  zautomatedcommithook.__init__  s	     rA   c                 D    | j                   rd| _         t        ||      S |S ru   )r{  rw  )r]   r   r
   s      r   __call__zautomatedcommithook.__call__   s"    ==!DM(u55LrA   N)r|   r}   r~   __doc__r@  r}  rv   rA   r   ry  ry    s    	!rA   ry  c                 ^    |t        |d      r|j                  d   S |r| j                  S d S )a)  Return the function to write largefiles specific status out

    If ``forcibly`` is ``None``, this returns the last element of
    ``repo._lfstatuswriters`` as "default" writer function.

    Otherwise, this returns the function to always write out (or
    ignore if ``not forcibly``) status.
    _largefilesenabledc                       y rO   rv   )r   optss     r   r   z!getstatuswriter.<locals>.<lambda>7  r   rA   )hasattr_lfstatuswritersr   )r#   r   forciblys      r   getstatuswriterr  (  s8     GD*>?$$R((99,,rA   )T)
   )NN)FrO   )Nr~  
contextlibrr  r+   r4   mercurial.i18nr   mercurial.noder   mercurial.pycompatr   	mercurialr   r   r   r	   r
   r   r   r   r   r   r   r   r   mercurial.utilsr   mercurial.dirstateutilsr   r   r   r   contextmanagerr   r'   r;   r@   r>   rQ   rV   rX   r   r   r   r   rU   rS   r   r   r   r   r   r   r   r   r   r   r  r   r  r   r   r
  r-  r  r2  r\   r;  	Exceptionr=  rC  rH  rL  rT  rh  rw  ry  r  rv   rA   r   <module>r     sg   N   	    #    % -	T!
 ! ! 
-1 $ /Md 
 *4** *4Z4n6=
)$2
7$&&
4/=C
 <1
5%9 %
 
&<8Bl^ .-rA   