
    6h                   .   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	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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(  \ RR                  r) " S
 S5      r* " S S\*5      r+ " S S5      r, " S S\,5      r- " S S\*5      r. " S S\.5      r/ " S S\,5      r0 " S S\05      r1 " S S\.5      r2 " S S\05      r3 " S S\/5      r4S  r5S! r6S" r7 " S# S$\.5      r8 " S% S&\05      r9 " S' S(\.5      r: " S) S*5      r;g)+    )annotationsN   )_)hexnullrevshort)dagopencodingerrorfilesetmatch
mergestatemetadataobsoletepatchpathutilphasesrepoviewscmutilsparsesubreposubrepoutiltestingutil)status)dateutil
stringutil)	timestampc                     \ rS rSrSrS rS r\R                  " \5      r	S r
S rS rS rS	 rS
 rS rS r  S5S jr\S 5       rS rS rS rS rS rS rS rS rS rS6S 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*S& r+\S' 5       r,S( r-S) r.S7S* jr/S+ r0S, r1       S8S- jr2         S9S. jr3S/ r4S0 r5      S: S5S1 jjr6S;S2 jr7S3 r8S4r9g)<basectx6   a5  A basectx object represents the common logic for its children:
changectx: read-only context that is already present in the repo,
workingctx: a context that represents the working directory and can
            be committed,
memctx: a context that represents changes in-memory and can also
        be committed.c                    Xl         g N_reposelfrepos     3/usr/lib/python3/dist-packages/mercurial/context.py__init__basectx.__init__>   s    
    c                4    [        U R                  5       5      $ r#   )r   noder'   s    r)   	__bytes__basectx.__bytes__A   s    TYY[!!r,   c                P    S[        U 5      R                  < S[        U 5      < S3$ N< >type__name__strr/   s    r)   __repr__basectx.__repr__F        J//T;;r,   c                     [        U 5      [        U5      :H  =(       a    U R                  UR                  :H  $ ! [         a     gf = fNF)r8   _revAttributeErrorr'   others     r)   __eq__basectx.__eq__I   s>    	:e,Hejj1HH 		s   69 
AAc                    X:X  + $ r#    rB   s     r)   __ne__basectx.__ne__O       ""r,   c                    XR                   ;   $ r#   	_manifestr'   keys     r)   __contains__basectx.__contains__R   s    nn$$r,   c                $    U R                  U5      $ r#   )filectxrN   s     r)   __getitem__basectx.__getitem__U   s    ||C  r,   c                ,    [        U R                  5      $ r#   )iterrM   r/   s    r)   __iter__basectx.__iter__X   s    DNN##r,   c                "    U R                  5       $ )zBuilds a manifest that includes the given status results, if this is
a working copy context. For non-working copy contexts, it just returns
the normal manifest.)manifest)r'   r   s     r)   _buildstatusmanifestbasectx._buildstatusmanifest[   s     }}r,   c                    U$ )zVThis internal method provides a way for child objects to override the
match operator.
rG   )r'   rC   r   s      r)   _matchstatusbasectx._matchstatusa   s	     r,   c           	        SnU R                  5       b3  U R                  5       UR                  5       :  a  U R                  U5      nUR                  U5      nUc  U R                  U5      n/ / p/ n/ nUR                  UR                  UR                  pn[        U5      nUR                  XsUS9nUR                  5        H  u  nnUU;   a  M  Uc  UR                  U5        M$  Uu  u  nnu  nnUc  U
R                  U5        ME  Uc  UR                  U5        M[  UU:w  a  U	R                  U5        Mt  UU R                  R                  R                  ;  a  U	R                  U5        M  U U   R                  UU   5      (       a  U	R                  U5        M  UR                  U5        M     U(       az  U Vs/ s H#  nUU;  d  M  U(       a  U" U5      (       d  M!  UPM%     nnU Vs/ s H#  nUU;  d  M  U(       a  U" U5      (       d  M!  UPM%     nnU Vs/ s H  nUU;  d  M  UPM     nn[        R                  " XXXU5      $ s  snf s  snf s  snf )z.build a status with respect to another contextN)r   clean)revr\   deletedunknownignoredsetdiffitemsappendr%   nodeconstantswdirfilenodeidscmpr   r   )r'   rC   sr   listignored	listcleanlistunknownmf2mf1modifiedaddedremovedrb   rd   re   rf   
deletedsetdfnvaluenode1flag1node2flag2s                           r)   _buildstatusbasectx._buildstatusg   s)    88:!dhhj599;&>++A.C((+;++A.Cb%$%IIqyy!))'\
HHSYH7IBZ}R -2*NUENUE}R r"%#djj66FFF
 #beBi((#R - #0  "!BS= */59 !   "!BS= */59 !   %,DGbr/CrGGD~~Ww
 	

 Es0   ;
I
	I
I
+
I9II
I)Ic                V    [         R                  " X R                  R                  5      $ r#   )r   stater%   uir/   s    r)   substatebasectx.substate   s      zz}}55r,   c                &    U R                   U   S   $ Nr   )r   r'   subpaths     r)   subrevbasectx.subrev   s    }}W%a((r,   c                    U R                   $ r#   )r@   r/   s    r)   rc   basectx.rev   s    yyr,   c                    U R                   $ r#   )_noder/   s    r)   r.   basectx.node       zzr,   c                4    [        U R                  5       5      $ r#   )r   r.   r/   s    r)   r   basectx.hex       499;r,   c                    U R                   $ r#   rL   r/   s    r)   r[   basectx.manifest       ~~r,   c                    U R                   $ r#   )_manifestctxr/   s    r)   manifestctxbasectx.manifestctx   s       r,   c                    U R                   $ r#   r$   r/   s    r)   r(   basectx.repo   r   r,   c                D    [         R                  U R                  5          $ r#   )r   
phasenamesphaser/   s    r)   phasestrbasectx.phasestr   s      ..r,   c                D    U R                  5       [        R                  :  $ r#   )r   r   publicr/   s    r)   mutablebasectx.mutable   s    zz|fmm++r,   Nc                ,    [         R                  " XX#S9$ )N)badfn)r   r   )r'   cwdexprr   s       r)   matchfilesetbasectx.matchfileset   s    }}T::r,   c                f    U R                  5       [        R                  " U R                  S5      ;   $ )z!True if the changeset is obsoletes   obsoleterc   obsmodgetrevsr%   r/   s    r)   r   basectx.obsolete   s"    xxzV^^DJJDDDr,   c                f    U R                  5       [        R                  " U R                  S5      ;   $ )z True if the changeset is extincts   extinctr   r/   s    r)   extinctbasectx.extinct   s"    xxzV^^DJJ
CCCr,   c                f    U R                  5       [        R                  " U R                  S5      ;   $ )z:True if the changeset is not obsolete, but its ancestor is   orphanr   r/   s    r)   orphanbasectx.orphan   s"    xxzV^^DJJ	BBBr,   c                f    U R                  5       [        R                  " U R                  S5      ;   $ )zTrue if the changeset tries to be a successor of a public changeset

Only non-public and non-obsolete changesets may be phase-divergent.
s   phasedivergentr   r/   s    r)   phasedivergentbasectx.phasedivergent   s%    
 xxzV^^DJJ8IJJJr,   c                f    U R                  5       [        R                  " U R                  S5      ;   $ )zIs a successor of a changeset with multiple possible successor sets

Only non-public and non-obsolete changesets may be content-divergent.
s   contentdivergentr   r/   s    r)   contentdivergentbasectx.contentdivergent   s%    
 xxzV^^DJJ8KLLLr,   c                ~    U R                  5       =(       d'    U R                  5       =(       d    U R                  5       $ )zLTrue if the changeset is either orphan, phase-divergent or
content-divergent)r   r   r   r/   s    r)   
isunstablebasectx.isunstable   s,     {{}P 3 3 5P9N9N9PPr,   c                    / nU R                  5       (       a  UR                  S5        U R                  5       (       a  UR                  S5        U R                  5       (       a  UR                  S5        U$ )zreturn the list of instabilities affecting this changeset.

Instabilities are returned as strings. possible values are:
- orphan,
- phase-divergent,
- content-divergent.
r   s   phase-divergents   content-divergent)r   rj   r   r   )r'   instabilitiess     r)   r   basectx.instabilities   sd     ;;==  +    !34  ""  !56r,   c                    U R                   $ )z)return contexts for each parent changeset_parentsr/   s    r)   parentsbasectx.parents   s    }}r,   c                     U R                   S   $ Nr   r   r/   s    r)   p1
basectx.p1   s    }}Qr,   c                h    U R                   n[        U5      S:X  a  US   $ U R                  [           $ )N   r   )r   lenr%   r   )r'   r   s     r)   p2
basectx.p2  s0    --w<11:zz'""r,   c                   SU R                   ;   a   U R                  R                  U5      $ SU R                   ;   d  XR                  5       ;   a9  XR                  ;   a*  U R                  U   U R                  R                  U5      4$ U R                  R                  n X R                  R                     R                  U5      u  p4X44$ ! [         a5    [        R
                  " U R                  =(       d    SU[        S5      5      ef = f! [         a5    [        R
                  " U R                  =(       d    SU[        S5      5      ef = f)NrM   s   Nones   not found in manifest_manifestdelta)__dict__rM   findKeyErrorr   ManifestLookupErrorr   r   filesr   flagsr%   manifestlog
_changesetr[   )r'   pathmflr.   flags        r)   	_fileinfobasectx._fileinfo  s+   $--'~~**400 t}},

0D***''-''--d3  jj$$	__556;;DAJD z+  //JJ)'43K1L    	++

%gtQ/G-H 	s   C  )D ?D?Ec                *    U R                  U5      S   $ r   )r   r'   r   s     r)   filenodebasectx.filenode#  s    ~~d#A&&r,   c                `     U R                  U5      S   $ ! [        R                   a     gf = f)Nr   r,   )r   r   LookupErrorr   s     r)   r   basectx.flags&  s3    	>>$'**   		s    --c                .    [         R                  " U 5      $ r#   )r   computechangesetcopiesr/   s    r)   _copiesbasectx._copies,  s    ..t44r,   c                     U R                   S   $ r   r   r/   s    r)   p1copiesbasectx.p1copies0      ||Ar,   c                     U R                   S   $ r   r   r/   s    r)   p2copiesbasectx.p2copies3  r   r,   c                ,    [         R                   " XUS9$ )z>return a subrepo for the stored revision of path, never wdir())allowcreater   )r'   r   r   s      r)   subbasectx.sub6  s    t{CCr,   c                0    [         R                  " XU5      $ r#   )r   nullsubrepo)r'   r   pctxs      r)   nullsubbasectx.nullsub:  s    ""4t44r,   c                ,    [         R                   " XSS9$ )zMreturn a subrepo for the stored revision, or wdir if this is a wdir
context.
T)	allowwdirr   r   s     r)   
workingsubbasectx.workingsub=  s     tT::r,   c                    U R                   nU(       d  UR                  5       n[        R                  " UR                  UUUUUUR
                  U UUS9
$ )N)auditorctxlistsubreposr   )r%   getcwdmatchmodr   rootnofsauditor)	r'   patsincludeexcludedefaultr  r   r   rs	            r)   r   basectx.matchC  sR     JJ((*C~~FFMM%
 	
r,   c
                    Uc  U R                  5       nUb  U R                  U   n[        R                  " U R                  UU UUUUUUUU	S9$ )z;Returns a diff generator for the given contexts and matcher)r   changesopts
losedatafnpathfncopycopysourcematchhunksfilterfn)r   r%   r   rh   )
r'   ctx2r   r  r  r  r  r  r  r  s
             r)   rh   basectx.diff]  s^     <779D::d#DzzJJ!+'
 	
r,   c                6    U R                   R                  5       $ r#   )rM   dirsr/   s    r)   r  basectx.dirs|  s    ~~""$$r,   c                8    U R                   R                  U5      $ r#   )rM   hasdir)r'   dirs     r)   r  basectx.hasdir  s    ~~$$S))r,   c           
       ^ U nU R                   U   nSn	[        U[        5      (       d  [        U[        5      (       a  Sn	XpU R                   R                  U5      nUR	                  Xr5      n[
        R                  " / / / / / / / 5      n
UR                  XzX#XE5      n
U	(       aD  [
        R                  " U
R                  U
R                  U
R                  / / / U
R                  5      n
U(       a  [
        R                  " Xx5       H}  u  mn UR                  T5      n[        R                   " TU5      nUR                  UUUUUSS9nS H4  n[#        X5      [#        X5      nnUR%                  U4S jU 5       5        M6     M     U
R                  R'                  5         U
R                  R'                  5         U
R                  R'                  5         U
R(                  R'                  5         U
R*                  R'                  5         U
R,                  R'                  5         U
R                  R'                  5         U
$ ! [         a    Sn GN0f = f)a  return status of files between two nodes or node and working
directory.

If other is None, compare this node with working directory.

ctx1.status(ctx2) returns the status of change from ctx1 to ctx2

Returns a mercurial.scmutils.status object.

Data can be accessed using either tuple notation:

    (modified, added, removed, deleted, unknown, ignored, clean)

or direct attribute access:

    s.modified, s.added, ...
FTN)r   rf   rb   re   r  )rt   ru   rv   rd   re   rf   rb   c              3  2   >#    U  H  nS TU4-  v   M     g7f)s   %s/%sNrG   ).0fr   s     r)   	<genexpr>!basectx.status.<locals>.<genexpr>  s     !J6a(gq\"96s   )r%   
isinstance	changectxnarrowmatchr_   r   r   r   rt   rv   ru   rb   itersubreposr   r   r  subdirmatchergetattrextendsortrd   re   rf   )r'   rC   r   ro   rp   rq   r  ctx1r  reversedr  r   rev2submatchrn   krfilessfilesr   s                     @r)   r   basectx.status  s   6 zz%  $	**z$	/J/JH$

&&u-!!$.NN2r2r2r26U
  

AIIqwwBAGGA  ' 4 4T @ ;;w/D $11'5AJJ"'#'!%  A &-Q]GAMFFMM!J6!JJ# !A: 	


														E      D	 s   H??IIc                2    [        SU R                  -  5      e)z)Get a mergestate object for this context.z"%s does not implement mergestate())NotImplementedError	__class__r'   rb   s     r)   r   basectx.mergestate  s    !04>>A
 	
r,   c                   [        U R                  5       5      S:  =(       d]    U R                  5       U R                  5       R                  5       :g  =(       d'    U R	                  5       =(       d    U R                  5       (       + $ r   )r   r   branchr   closesbranchr   r/   s    r)   isemptybasectx.isempty  sb    !# {{}	 0 0 22  " zz|	
 	
r,   r$   returnzistatus.Statusr#   TNNNs   globFNN)	NNNNNNNNN)NNFFFFF):r9   
__module____qualname____firstlineno____doc__r*   r0   r
   	strmethod__str__r;   rD   rH   rP   rT   rX   r\   r_   r   propertycacher   r   rc   r.   r   r[   r   r(   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   rh   r  r  r   r   r@  __static_attributes__rG   r,   r)   r    r    6   s   "   +G<#%!$@
	@
D 6 6) !/,;EDCKMQ
" #6' 5 5D5; 
8 
>%*
 c 
cJ

r,   r    c                  J  ^  \ rS rSrSrS'U 4S jjrS rS r\r\	S 5       r
\	S 5       r\S 5       r\	S	 5       r\	S
 5       rS rS rS rS rS rS rS rS r\	U 4S j5       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$S  r%S(S! jr&S)S" jr'S# r(S$ r)S% r*S&r+U =r,$ )*r)  i  zA changecontext object makes access to data related to a particular
changeset convenient. It represents a read-only context already present in
the repo.c                H   > [         TU ]  U5        X l        X0l        X@l        g r#   )superr*   r@   r   _maybe_filtered)r'   r(   rc   r.   maybe_filteredr:  s        r)   r*   changectx.__init__  s"    	
  .r,   c                d     [        U R                  5      $ ! [         a    [        U 5      s $ f = fr#   )hashr@   rA   idr/   s    r)   __hash__changectx.__hash__  s-    			?" 	d8O	s    //c                (    U R                   [        :g  $ r#   )r@   r   r/   s    r)   __nonzero__changectx.__nonzero__  s    yyG##r,   c                    U R                   (       a  U R                  nOU R                  R                  5       nUR                  R	                  U R                  5       5      $ r#   )rR  r%   
unfiltered	changelogchangelogrevisionrc   r&   s     r)   r   changectx._changeset  sA    ::D::((*D~~//
;;r,   c                6    U R                   R                  5       $ r#   )r   readr/   s    r)   rM   changectx._manifest  s      %%''r,   c                \    U R                   R                  U R                  R                     $ r#   )r%   r   r   r[   r/   s    r)   r   changectx._manifestctx  s!    zz%%doo&>&>??r,   c                P    U R                   R                  5       u  pUc  X l        U$ r#   )r   read_any_fast_deltarM   )r'   basedeltas      r)   r   changectx._manifestdelta"  s'    '';;=<"Nr,   c                v   U R                   nU R                  (       a  UR                  nOUR                  5       R                  nUR	                  U R
                  5      u  p4U[        :X  a  [        XUR                  U5      SS9/$ [        XUR                  U5      SS9[        XUR                  U5      SS9/$ )NFrS  )	r%   rR  r_  r^  
parentrevsr@   r   r)  r.   )r'   r(   clr   r   s        r)   r   changectx._parents)  s    zzB",,Btyy)=dEJKKdEBdEB
 	
r,   c                    U R                   nUR                  UR                  UR                  UR                  UR
                  UR                  4$ r#   )r   r[   userdater   descriptionextra)r'   cs     r)   	changesetchangectx.changeset9  s?    OOJJFFFFGGMMGG
 	
r,   c                .    U R                   R                  $ r#   )r   r[   r/   s    r)   manifestnodechangectx.manifestnodeD  s    '''r,   c                .    U R                   R                  $ r#   )r   rr  r/   s    r)   rr  changectx.userG      ###r,   c                .    U R                   R                  $ r#   )r   rs  r/   s    r)   rs  changectx.dateJ  r~  r,   c                .    U R                   R                  $ r#   )r   r   r/   s    r)   r   changectx.filesM  s    $$$r,   c                    [        U R                  5       5      nUR                  U R                  5       5        UR                  U R	                  5       5        [        U5      $ r#   )rg   r   difference_update
filesaddedfilesremovedsorted)r'   rt   s     r)   filesmodifiedchangectx.filesmodifiedP  sI    tzz|$""4??#45""4#4#4#67hr,   c                &   U R                   R                  nSnU R                  R                  S:X  a  SnO7U R                  R                  R                  SS5      nUS:X  a  SnOUS:w  a  S nUc!  U(       a  [        R                  " U 5      nU$ / nU$ NTs   changeset-sidedataF   experimentals   copies.read-froms   changeset-onlys   compatibility)r   r  r%   filecopiesmoder   configr   computechangesetfilesadded)r'   r  compute_on_nonesources       r)   r  changectx.filesaddedV  s    __//
::$$(==#OZZ]]))/;NOF**"'++!
%@@F
   
r,   c                &   U R                   R                  nSnU R                  R                  S:X  a  SnO7U R                  R                  R                  SS5      nUS:X  a  SnOUS:w  a  S nUc!  U(       a  [        R                  " U 5      nU$ / nU$ r  )r   r  r%   r  r   r  r   computechangesetfilesremoved)r'   r  r  r  s       r)   r  changectx.filesremovedi  s    33::$$(==#OZZ]]))/;NOF**"'++#'DDTJ   "r,   c                R  > U R                   R                  nU R                   R                  nSnU R                  R                  S:X  a  SnO8U R                  R
                  R                  SS5      nUS:X  a  SnO	US:w  a  S =pUc  U(       a  [        TU ]   u  pOUc  0 nUc  0 nX4$ r  )	r   r   r   r%   r  r   r  rQ  r   )r'   r   r   r  r  r:  s        r)   r   changectx._copies|  s    ??++??++::$$(==#OZZ]]))/;NOF **"'++&**%*W_"(#!HH!!r,   c                .    U R                   R                  $ r#   )r   rt  r/   s    r)   rt  changectx.description  s    ***r,   c                t    [         R                  " U R                  R                  R	                  S5      5      $ N   branch)r
   tolocalr   ru  getr/   s    r)   r>  changectx.branch  s(     5 5 9 9) DEEr,   c                4    SU R                   R                  ;   $ Ns   closer   ru  r/   s    r)   r?  changectx.closesbranch  s    4??0000r,   c                .    U R                   R                  $ )z#Return a dict of extra information.r  r/   s    r)   ru  changectx.extra  s    $$$r,   c                L    U R                   R                  U R                  5      $ )zReturn a list of byte tag names)r%   nodetagsr   r/   s    r)   tagschangectx.tags  s    zz""4::..r,   c                L    U R                   R                  U R                  5      $ )z%Return a list of byte bookmark names.)r%   nodebookmarksr   r/   s    r)   	bookmarkschangectx.bookmarks  s    zz''

33r,   c                    U R                   nU R                  (       a  UR                  nOUR                  5       R                  nUR	                  U R
                  5      $ r#   )r%   rR  r_  r^  	fast_rankr@   )r'   r(   ro  s      r)   r  changectx.fast_rank  sB    zzB",,B||DII&&r,   c                v    U R                   R                  R                  U R                   U R                  5      $ r#   )r%   _phasecacher   r@   r/   s    r)   r   changectx.phase  s'    zz%%++DJJ		BBr,   c                ^    U R                   [        R                  " U R                  S5      ;   $ )Ns   visible)r@   r   
filterrevsr%   r/   s    r)   hiddenchangectx.hidden  s"    yyH//

JGGGr,   c                    gr?   rG   r/   s    r)   
isinmemorychangectx.isinmemory      r,   c                    U R                   R                  R                  U R                  5      nU Vs/ s H  o R                   U   PM     sn$ s  snf )zreturn list of changectx contexts for each child changeset.

This returns only the immediate child changesets. Use descendants() to
recursively walk children.
)r%   r_  childrenr   r'   rv  xs      r)   r  changectx.children  s@     JJ  ))$**5'()q!

1q)))s   Ac              #     #    U R                   R                  R                  U R                  /5       H  nU R                   U   v   M     g 7fr#   )r%   r_  	ancestorsr@   )r'   as     r)   r  changectx.ancestors  s8     %%//<A**Q- =   A
Ac              #     #    U R                   R                  R                  U R                  /5       H  nU R                   U   v   M     g7f)zbRecursively yield all children of the changeset.

For just the immediate children, use children()
N)r%   r_  descendantsr@   )r'   rx   s     r)   r  changectx.descendants  s:     
 %%11499+>A**Q- ?r  c                T    Uc  U R                  U5      n[        U R                  XXS9$ )z&get a file context from this changeset)fileidr)  filelog)r   rS   r%   )r'   r   r  r  s       r)   rS   changectx.filectx  s-    >]]4(FJJt
 	
r,   c           	       ^ UR                   nUc  UR                  S   R                   nU R                  R                  R	                  U R                   U5      nU(       d"  U R                  R
                  R                  mGO2[        U5      S:X  a  US   mGOU R                  R                  R                  SS5       H=  n [        R                  " U R                  U5      nUR                  5       mTU;   d  M=    O2   U R                  R                  R                  U R                   U5      mU(       a~  U R                  R                  R!                  [#        S5      [%        T5      [%        U R                   5      [%        U5      4-  SR'                  U4S j[)        U5       5       5      -   5        U R                  T   $ ! [        R                   a     GM  f = f)zreturn the "best" ancestor context of self and c2

If there are multiple candidates, it will show a message and check
merge.preferancestor configuration before falling back to the
revlog ancestor.r   r   s   merges   preferancestors(   note: using %s as ancestor of %s and %s
r,   c              3  b   >#    U  H$  nUT:w  d  M  [        S 5      [        U5      -  v   M&     g7f)s:         alternatively, use --config merge.preferancestor=%s
N)r   r   )r$  nancs     r)   r&  %changectx.ancestor.<locals>.<genexpr>  s=       ".A8#9  (	#
 ".s   
//)r   r   r%   r_  commonancestorsheadsrk   nullidr   r   
configlistr   	revsymbolr   RepoLookupErrorr.   ancestorr   r   r   joinr  )r'   c2warnn2cahsr  r  r  s          @r)   r  changectx.ancestor  s|    XX:Q%%Bzz##88RH****11CY!^q'C ZZ]]--h8IJ!++DJJ:C hhj$; K jj**33DJJC

$$FG :uTZZ'8%)DE hh  "( 	 zz#/ ,, s   !GGGc                v    U R                   R                  R                  U R                  UR                  5      $ )z.True if this changeset is an ancestor of other)r%   r_  isancestorrevr@   rB   s     r)   isancestorofchangectx.isancestorof  s'    zz##11$))UZZHHr,   c                   ^ ^ UU 4S jn[         R                  " T R                  R                  T5      U5      nT R                  R                  U5      $ )Generates matching file names.c                   >^  [        U 4S jTR                   5       5      (       a  g TR                  T [        S5      T-  5        g )Nc              3  d   >#    U  H%  nTU:H  =(       d    TR                  US -   5      v   M'     g7f)   /N)
startswith)r$  rn   ry   s     r)   r&  .changectx.walk.<locals>.bad.<locals>.<genexpr>  s*     M}!275bmmAH55}s   -0s   no such file in rev %s)anyr   badr   )ry   msgr   r'   s   ` r)   r  changectx.walk.<locals>.bad  s6     Mt}}MMMIIb!56=>r,   )r  badmatchr%   r*  rM   walk)r'   r   r  ms   ``  r)   r  changectx.walk  s@    	? djj44U;SA~~""1%%r,   c                $    U R                  U5      $ r#   )r  r'   r   s     r)   matcheschangectx.matches!  s    yyr,   )rM   rR  r   r@   rD  NNrF  )-r9   rG  rH  rI  rJ  r*   rX  r[  __bool__rM  r   rM   propertyr   r   r   rw  rz  rr  rs  r   r  r  r  r   rt  r>  r?  ru  r  r  r  r   r  r  r  r  r  rS   r  r  r  r  rN  __classcell__r:  s   @r)   r)  r)    s#   
.$ H< < ( ( @ @   
 
	
($$% &&  "  "D+F1%/4'CH*  
+ZI&   r,   r)  c                     \ rS rSrSr\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
S r\rS	 r\R                  " \5      rS
 rS rS rS rS rS r\S 5       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#S r$S r%S r&S  r'S! r(S" r)S# r*S$ r+S% r,S& r-S' r.S( r/S) r0S* r1S+ r2S,r3S- r4S<S/ jr5S0 r6S1 r7S=S2 jr8S3 r9S4 r:S5 r;S6 r<S7 r=S>S8 jr>S?S9 jr?S: r@S;rAg.)@basefilectxi%  a8  A filecontext object represents the common logic for its children:
filectx: read-only access to a filerevision that is already present
         in the repo,
workingfilectx: a filecontext that represents files from the working
                directory,
memfilectx: a filecontext that represents files in-memory,
c                L    U R                   R                  U R                  5      $ r#   )r%   file_pathr/   s    r)   _filelogbasefilectx._filelog.  s    zztzz**r,   c                    SU R                   ;   a  U R                  R                  5       $ SU R                   ;   a  U R                  U R                  5      $ U R
                  R                  U R                  5      $ )N
_changectx_descendantrev)r   r  rc   _adjustlinkrevr  r  linkrev_filerevr/   s    r)   	_changeidbasefilectx._changeid2  s_    4==(??&&((. &&t':':;;==((77r,   c                    SU R                   ;   a%  U R                  R                  U R                  5      $ U R                  R                  U R                  5      $ )N_fileid)r   r  lookupr
  r  r   r  r/   s    r)   	_filenodebasefilectx._filenode=  s@    %==''55??++DJJ77r,   c                L    U R                   R                  U R                  5      $ r#   )r  rc   r  r/   s    r)   r  basefilectx._filerevD  s    }}  00r,   c                    U R                   $ r#   r  r/   s    r)   	_repopathbasefilectx._repopathH  s    zzr,   c                R     U R                     g! [        R                   a     gf = fNTF)r  r   r   r/   s    r)   r[  basefilectx.__nonzero__L  s)    	NN   		s    &&c                     SU R                  5       U R                  4-  $ ! [        R                   a    SU R                  5       -  s $ f = f)Ns   %s@%ss   %s@???)r   r  r   r   r/   s    r)   r0   basefilectx.__bytes__V  sG    	+tyy{DOO<<<   	+tyy{**	+s   ! 'A
Ac                P    S[        U 5      R                  < S[        U 5      < S3$ r3   r7   r/   s    r)   r;   basefilectx.__repr__^  r=   r,   c                |     [        U R                  U R                  45      $ ! [         a    [	        U 5      s $ f = fr#   )rV  r  r  rA   rW  r/   s    r)   rX  basefilectx.__hash__a  s7    	T^^455 	d8O	s    # ;;c                     [        U 5      [        U5      :H  =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ ! [         a     gf = fr?   )r8   r  r  rA   rB   s     r)   rD   basefilectx.__eq__g  sZ    	T
d5k) 6JJ%++-6NNeoo5
  		s   AA 
A&%A&c                    X:X  + $ r#   rG   rB   s     r)   rH   basefilectx.__ne__q  rJ   r,   c                    U R                   $ r#   )r  r/   s    r)   filerevbasefilectx.filerevt      }}r,   c                    U R                   $ r#   )r  r/   s    r)   r   basefilectx.filenodew  r   r,   c                L    U R                   R                  U R                  5      $ r#   )r  r   r  r/   s    r)   _flagsbasefilectx._flagsz  s    $$TZZ00r,   c                    U R                   $ r#   )r(  r/   s    r)   r   basefilectx.flags~      {{r,   c                    U R                   $ r#   )r  r/   s    r)   r  basefilectx.filelog  r$  r,   c                    U R                   $ r#   r  r/   s    r)   rc   basefilectx.rev  r   r,   c                L    U R                   R                  U R                  5      $ r#   )r  r  r  r/   s    r)   r  basefilectx.linkrev  s    }}$$T]]33r,   c                6    U R                   R                  5       $ r#   )r  r.   r/   s    r)   r.   basefilectx.node      ##%%r,   c                6    U R                   R                  5       $ r#   )r  r   r/   s    r)   r   basefilectx.hex  s    ""$$r,   c                6    U R                   R                  5       $ r#   )r  rr  r/   s    r)   rr  basefilectx.user  r6  r,   c                6    U R                   R                  5       $ r#   )r  rs  r/   s    r)   rs  basefilectx.date  r6  r,   c                6    U R                   R                  5       $ r#   )r  r   r/   s    r)   r   basefilectx.files      $$&&r,   c                6    U R                   R                  5       $ r#   )r  rt  r/   s    r)   rt  basefilectx.description  s    **,,r,   c                6    U R                   R                  5       $ r#   )r  r>  r/   s    r)   r>  basefilectx.branch  s    %%''r,   c                6    U R                   R                  5       $ r#   )r  ru  r/   s    r)   ru  basefilectx.extra  r?  r,   c                6    U R                   R                  5       $ r#   )r  r   r/   s    r)   r   basefilectx.phase  r?  r,   c                6    U R                   R                  5       $ r#   )r  r   r/   s    r)   r   basefilectx.phasestr      ''))r,   c                6    U R                   R                  5       $ r#   )r  r   r/   s    r)   r   basefilectx.obsolete  rJ  r,   c                6    U R                   R                  5       $ r#   )r  r   r/   s    r)   r   basefilectx.instabilities  s    ,,..r,   c                6    U R                   R                  5       $ r#   )r  r[   r/   s    r)   r[   basefilectx.manifest  rJ  r,   c                    U R                   $ r#   )r  r/   s    r)   r)  basefilectx.changectx  s    r,   c                    U R                   $ r#   _copiedr/   s    r)   renamedbasefilectx.renamed      ||r,   c                F    U R                   =(       a    U R                   S   $ r   rT  r/   s    r)   
copysourcebasefilectx.copysource  s    ||/Q/r,   c                    U R                   $ r#   r$   r/   s    r)   r(   basefilectx.repo  r   r,   c                4    [        U R                  5       5      $ r#   )r   datar/   s    r)   sizebasefilectx.size  r   r,   c                    U R                   $ r#   r  r/   s    r)   r   basefilectx.path  r   r,   c                l     [         R                  " U R                  5       5      $ ! [         a     gf = fr?   )r   binaryr_  OSErrorr/   s    r)   isbinarybasefilectx.isbinary  s0    	$$TYY[11 		s   #& 
33c                (    SU R                  5       ;   $ )N   xr   r/   s    r)   isexecbasefilectx.isexec      tzz|##r,   c                (    SU R                  5       ;   $ N   lrk  r/   s    r)   islinkbasefilectx.islink  rn  r,   c                    g)zwhether this filectx represents a file not in self._changectx

This is mainly for merge code to detect change/delete conflicts. This is
expected to be True for all subclasses of basectx.FrG   r/   s    r)   isabsentbasefilectx.isabsent  s    
 r,   Fc                   UR                   (       a  UR                  U 5      $ U R                  c  [        R                  " S5      eUR                  c  U R
                  R                  (       a4  U R                  R                  U R                  UR                  5       5      $ U R                  5       S-
  UR                  5       :X  a4  U R                  R                  U R                  UR                  5       5      $ U R                  5       UR                  5       :X  d  U R                  5       S:X  a4  U R                  R                  U R                  UR                  5       5      $ g)Fcompare with other file context

returns True if different than fctx.
s;   filectx.cmp() must be reimplemented if not backed by revlog   rq  T)
_customcmprm   r  r   ProgrammingErrorr%   _encodefilterpatsr  r_  r`  r   r'   fctxs     r)   rm   basefilectx.cmp  s    
 ??88D>!>>!((N  >>!zz++}}((EE yy{Q$))+- }}((EE99;$))+%)= ==$$T^^TYY[AA r,   Nc                   U R                   nUR                  5       R                  nUR                  nU R	                  5       nX:X  a  U$ [        U SS5      nSn	Uc=  U R                   S   R                  5        V
s/ s H  oR                  5       PM     nn
SnOU/nUc  UR                  XUS9=pXx;  a  U	c  UR                  XUS9n	U R                  nU R                  nU	 HS  nUb  X:  a    gUR                  U5      nXS   ;   d  M(  UXoS      R                  SS9R                  U5      :X  d  MQ  Us  $    U$ s  sn
f )	a,  return the first ancestor of <srcrev> introducing <fnode>

If the linkrev of the file revision does not point to an ancestor of
srcrev, we'll walk down the ancestors until we find one introducing
this file revision.

:srcrev: the changeset revision we search ancestors from
:inclusive: if true, the src revision will also be checked
:stoprev: an optional revision to stop the walk at. If no introduction
          of this file content could be found before this floor
          revision, the function will returns "None" and stops its
          iteration.
_ancestrycontextNT	inclusive   r   F)exact)r%   r^  r_  r   r  r-  r   rc   r  r  r  rc  read_delta_parentsr  )r'   srcrevr  stoprevr(   ro  r   lkr	memberanciterancprevsfnoder   r  acs                   r)   r  basefilectx._adjustlinkrev  sG    zz__((lln=JD"4d;	>%)ZZ%5%=%=%?@%?EEG%?D@I8D"$,,tI,"NNI,,tI,FNNE::D&1;WWQZa5= qE
55E5BFFtL  ! $ 
= As   ;D;c                Z    U R                  5       U:  a  gU R                  US9nUc  gX!:  $ )zBTrue if a filectx has been introduced after a given floor revisionTr  F)r  	_introrev)r'   changelogrevintrorevs      r)   isintroducedafterbasefilectx.isintroducedafter;  s5    <<>\)>>,>7''r,   c                "    U R                  5       $ )aO  return the rev of the changeset which introduced this file revision

This method is different from linkrev because it take into account the
changeset the filectx was created from. It ensures the returned
revision is one of its ancestors. This prevents bugs from
'linkrev-shadowing' when a file revision is used by multiple
changesets.
)r  r/   s    r)   r  basefilectx.introrevD  s     ~~r,   c                    Sn[        U 5      nSU;   a  U R                  nO SU;   a  U R                  R                  5       nUb  U R	                  USUS9$ SU;   a%  U R	                  U R
                  US9nUb  X@l        U$ U R                  5       $ )a  
Same as `introrev` but, with an extra argument to limit changelog
iteration range in some internal usecase.

If `stoprev` is set, the `introrev` will not be searched past that
`stoprev` revision and "None" might be returned. This is useful to
limit the iteration range.
Nr  r  T)r  r  r  r  )varsr  r  rc   r  r  r  )r'   r  toprevattrsr  s        r)   r  basefilectx._introrevO  s     T
%^^FU"__((*F&&vw&OO&**4+>+>*PH#!)O<<>!r,   c                    U R                  5       nU R                  5       U:X  a  U $ U R                  U R                  5       US9$ )zrReturn filectx having identical contents, but pointing to the
changeset revision where this filectx was introduced)changeid)r  rc   rS   r   )r'   r  s     r)   introfilectxbasefilectx.introfilectxl  s;     ==?88:!K||DMMOh|??r,   c                "   [        U R                  XUS9nS[        U 5      ;   d  S[        U 5      ;   a)  U R                  5       Ul        [        U SS5      Ul        U$ S[        U 5      ;   a#  U R                  Ul        [        U SS5      Ul        U$ )z@create parent filectx keeping ancestry info for _adjustlinkrev()r  r  r  r  r  Nr  )rS   r%   r  rc   r  r-  r  )r'   r   r  r  r~  s        r)   _parentfilectxbasefilectx._parentfilectxt  s    tzz4H$t*$T
(B
 #'((*D$+D2Dd$KD!
 	 d+"&"5"5D$+D2Dd$KD!r,   c           
     
   U R                   nU R                  nU R                  R                  U R                  5      nU Vs/ s H,  nX@R                  R
                  R                  :w  d  M(  XU4PM.     nnUR                  U R                  5      nU(       a7  UR                  SUS   US   U R                  R                  US   5      45        U VVV	s/ s H  u  pxoR                  XxU	5      PM     sn	nn$ s  snf s  sn	nnf Nr   r   )r  r  r   r  r%   rk   r  rV  insertr  r  )
r'   r  flr   r.   plr  r   r  ls
             r)   r   basefilectx.parents  s    

]]--''7  
zz//666 U" 	 
 JJt~~& IIa!A$!djjooad&;<=JLM"Q##D3"MM%
$ Ns   'C9-C9C>c                (    U R                  5       S   $ r   )r   r/   s    r)   r   basefilectx.p1  s    ||~a  r,   c                    U R                  5       n[        U5      S:X  a  US   $ [        U R                  U R                  SU R
                  S9$ )Nr   r   r  )r   r   rS   r%   r  r  )r'   r  s     r)   r   basefilectx.p2  s>    LLNq6Q;Q4Ktzz4::b$--PPr,   c                  ^ ^^	 [         R                  " U 4S j5      m	UU	4S jnT R                  5       n[        USS5      c  T R                  R                  5       R                  nT R                  5       c=  UR                  T R                  5        Vs/ s H  owR                  5       PM     snSS9nOUR                  T R                  5       /SS9nXl
        [        R                  " XTX#S9$ s  snf )a  Returns a list of annotateline objects for each line in the file

- line.fctx is the filectx of the node where that line was last changed
- line.lineno is the line number at the first appearance in the managed
  file
- line.text is the data on that line (including newline character)
c                :   > TR                   R                  U 5      $ r#   )r%   r  )r  r'   s    r)   <lambda>&basefilectx.annotate.<locals>.<lambda>  s    TZZ__Q-?r,   c                .  > U R                     U R                  5       nT(       d5  U Vs/ s H(  o"R                  5       U R                  5       :X  d  M&  UPM*     nnU H0  nSUR                  ;  d  M  T" UR                  5       5      Ul        M2     U$ s  snf )Nr  )r  r   r   r   r  )r%  r  r  followgetlogs      r)   r   %basefilectx.annotate.<locals>.parents  sw    
 KKB !#<Avvx1668';a< !QZZ/!'!1AJ  I =s   %BBr  NTr  )skiprevsdiffopts)r   lrucachefuncr  r-  r%   r^  r_  rc   r  r   r  r	   annotate)
r'   r  r  r  r   ri  ro  r  r  r  s
   ``       @r)   r  basefilectx.annotate  s     ""#?@	*   "4+T2: &&(22B xxz! \\&*lln5nUUWn5 "  \\488:,$\?$&!~~H
 	
 6s   C/c              #     #    0 nU nU(       a  SnOS n UR                  5       S U  H%  nXRUR                  5       UR                  5       4'   M'     U(       d  g UR                  [	        U5      5      nUv   Md  7fr   )r   r  r   popmax)r'   followfirstvisitrv  cutparents         r)   r  basefilectx.ancestors  ss     CC))+ds+?Ev~~'):;< ,		#e*%AG s   A6A8c                r    U R                   R                  U R                  5       U R                  5       5      $ )zReturns `data()` after running repository decoding filters.

This is often equivalent to how the data would be expressed on disk.
)r%   
wwritedatar   r_  r/   s    r)   decodeddatabasefilectx.decodeddata  s'    
 zz$$TYY[$))+>>r,   r0  )FNr#   )FNNrF  )Br9   rG  rH  rI  rJ  rM  r  r  r  r  r  r[  r  r0   r
   rK  rL  r;   rX  rD   rH   r"  r   r(  r   r  rc   r  r.   r   rr  rs  r   rt  r>  ru  r   r   r   r   r[   r)  rV  rZ  r(   r`  r   rg  rl  rr  ru  rz  rm   r  r  r  r  r  r  r   r   r   r  r  r  rN  rG   r,   r)   r  r  %  s    + + 8 8 8 8 1 1   H+   +G<# 1 14&%&&'-(''**/*0 $$ J'R8t(	 ":@ N0!Q2
h ?r,   r  c                  r    \ rS rSrSr    SS jr\S 5       rSS jrS r	S r
S	 rS
 r\S 5       rS rSrg)rS   i  zZA filecontext object makes access to data related to a particular
filerevision convenient.Nc                    Xl         X l        Uc  Uc  Uc   SUUU4-  5       eUb  XPl        Ub  X0l        Ub  X`l        Ub  X@l        gg)zXchangeid must be a revision number, if specified.
fileid can be a file revision or node.Ns.   bad args: changeid=%r, fileid=%r, changectx=%r)r%   r  r  r  r  r
  )r'   r(   r   r  r  r  r)  s          r)   r*   filectx.__init__  sw     

  F$6):O	
<@
 
	
O #M%N 'O!L r,   c                     U R                   U R                     $ ! [        R                   a*    U R                   R	                  5       U R                     s $ f = fr#   )r%   r  r   FilteredRepoLookupErrorr^  r/   s    r)   r  filectx._changectx  sM    	;::dnn--,, 	;" ::((*4>>::#	;s    ;AAc                X    [        U R                  U R                  UU R                  US9$ )zEopens an arbitrary revision of the file without
opening a new filelog)r  r  r  )rS   r%   r  r  )r'   r  r  s      r)   rS   filectx.filectx,  s,     JJJJMM
 	
r,   c                L    U R                   R                  U R                  5      $ r#   )r  rawdatar  r/   s    r)   r  filectx.rawdata7  s    }}$$T^^44r,   c                L    U R                   R                  U R                  5      $ )zlow-level revlog flags)r  r   r  r/   s    r)   rawflagsfilectx.rawflags:  s    }}""4==11r,   c                P    U R                   R                  U R                  5      $ ! [        R                   aj    U R
                  R                  R                  SS5      S:X  a   g[        R                  " [        S5      [        U R                  5      -  [        S5      S9ef = f)Ns   censors   policys   ignorer,   s   censored node: %ss"   set censor.policy to ignore errors)hint)r  rc  r  r   CensoredNodeErrorr%   r   r  Abortr   r   r/   s    r)   r_  filectx.data>  s    	==%%dnn55&& 	zz}}##Iy9YF++&'%*??<= 	s   $' >B%'>B%c                L    U R                   R                  U R                  5      $ r#   )r  r`  r  r/   s    r)   r`  filectx.sizeI  s    }}!!$--00r,   c                   U R                   R                  U R                  5      nU(       d  gU R                  5       U R	                  5       :X  a  U$ U R                  5       nU R                  nU R                  R                  5        H  n X4R                  U5      :X  a    gM     U$ ! [        R                   a     M7  f = f)a  check if file was actually renamed in this changeset revision

If rename logged in file revision, we report copy for changeset only
if file revisions linkrev points back to the changeset in question
or both changeset parents contain different file revisions.
N)r  rV  r  rc   r  r   r  r   r   r   r   )r'   rV  namer  r  s        r)   rU  filectx._copiedL  s     --''788:'Nyy{((*AJJt,, - +  $$ s   B((C ?C c           
         U R                   R                  U R                  5      nU Vs/ s H,  n[        U R                  U R
                  X R                   S9PM.     sn$ s  snf )Nr  )r  r  r  rS   r%   r  r  s      r)   r  filectx.childrenf  sV    MM""4>>2 
 DJJ

1mmL
 	
 
s   3A )r  r  r
  r  r  r%   )NNNNr#   )r9   rG  rH  rI  rJ  r*   rM  r  rS   r  r  r_  r`  rU  r  rN  rG   r,   r)   rS   rS     sa      "@ ; ;,	
52	1  2
r,   rS   c                  F  ^  \ rS rSrSr      S#U 4S jjrS rS r\R                  " \5      r
S r\r\S 5       r\S 5       r\S	 5       rS
 rS rS rS rS rS rS rS rS rS r\r\r\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)S  r*S$S! jr+S"r,U =r-$ )%committablectxio  zA committablectx object provides common functionality for a context that
wants the ability to commit, e.g. workingctx or memctx.c                  > [         TU ]  U5        S U l        S U l        X l        U(       a  [
        R                  " U5      U l        U(       a  X0l        U(       a  X`l	        0 U l
        U(       a  UR                  5       U l
        Ub#  [        R                  " U5      U R                  S'   U R                  R                  S5      (       d  SU R                  S'   g g )Nr  s   default)rQ  r*   r@   r   _textr   	parsedate_date_user_status_extrar  r
   	fromlocalr  	r'   r(   textrr  rs  ru  r  r>  r:  s	           r)   r*   committablectx.__init__s  s     		

!++D1DJJ"L**,DK%-%7%7%?DKK	"{{y))%/DKK	" *r,   c                8    [        U R                  S   5      S-   $ )Nr      +)bytesr   r/   s    r)   r0   committablectx.__bytes__  s    T]]1%&--r,   c                D    U R                   R                  R                    g r#   r%   rk   wdirhexr/   s    r)   r   committablectx.hex  s    

  ((r,   c                    gNTrG   r/   s    r)   r[  committablectx.__nonzero__      r,   c                6    U R                   R                  5       $ r#   )r%   r   r/   s    r)   r  committablectx._status  s    zz  ""r,   c                J    U R                   R                  R                  5       $ r#   )r%   r   usernamer/   s    r)   r  committablectx._user  s    zz}}%%''r,   c                    U R                   R                  nUR                  SS5      nUc  [        R                  " 5       nU$ )Ns   devels   default-date)r%   r   
configdater   makedate)r'   r   rs  s      r)   r  committablectx._date  s7    ZZ]]}}X7<$$&Dr,   c                    g r#   rG   r   s     r)   r   committablectx.subrev  r  r,   c                    g r#   rG   r/   s    r)   rz  committablectx.manifestnode  r  r,   c                p    U R                   =(       d$    U R                  R                  R                  5       $ r#   )r  r%   r   r  r/   s    r)   rr  committablectx.user  s"    zz5TZZ]]3355r,   c                    U R                   $ r#   )r  r/   s    r)   rs  committablectx.date  r   r,   c                    U R                   $ r#   )r  r/   s    r)   rt  committablectx.description  r   r,   c                    [        U R                  R                  U R                  R                  -   U R                  R                  -   5      $ r#   )r  r  rt   ru   rv   r/   s    r)   r   committablectx.files  s:    LL!!DLL$6$669M9MM
 	
r,   c                .    U R                   R                  $ r#   )r  rt   r/   s    r)   rt   committablectx.modified  s    ||$$$r,   c                .    U R                   R                  $ r#   )r  ru   r/   s    r)   ru   committablectx.added  s    ||!!!r,   c                .    U R                   R                  $ r#   )r  rv   r/   s    r)   rv   committablectx.removed      ||###r,   c                .    U R                   R                  $ r#   )r  rd   r/   s    r)   rd   committablectx.deleted  r  r,   c                H    [         R                  " U R                  S   5      $ r  )r
   r  r  r/   s    r)   r>  committablectx.branch  s    I 677r,   c                     SU R                   ;   $ r  r  r/   s    r)   r?  committablectx.closesbranch  s    4;;&&r,   c                    U R                   $ r#   r   r/   s    r)   ru  committablectx.extra  r,  r,   c                    gr?   rG   r/   s    r)   r  committablectx.isinmemory  r  r,   c                    / $ r#   rG   r/   s    r)   r  committablectx.tags      	r,   c                v    / nU R                  5        H"  nUR                  UR                  5       5        M$     U$ r#   )r   r.  r  )r'   br  s      r)   r  committablectx.bookmarks  s.    AHHQ[[]#  r,   c                    [         R                  " U R                  R                  5      nU R	                  5        H  n[        XR                  5       5      nM     U$ r#   )r   newcommitphaser%   r   r   r  r   )r'   r   r  s      r)   r   committablectx.phase  s?    %%djjmm4Awwy)E  r,   c                    gr?   rG   r/   s    r)   r  committablectx.hidden  r  r,   c                    / $ r#   rG   r/   s    r)   r  committablectx.children  r(  r,   c                    SU R                   ;   a   U R                  R                  U5      $  U R	                  U5      $ ! [         a     gf = f! [
         a     gf = f)NrM   r,   )r   rM   r   r   	_flagfuncrf  r   s     r)   r   committablectx.flags  sc    $--'~~++D11	>>$''	  
  		s    ? A 
AA
AAc                >    U R                   S   R                  U5      $ )z1return the "best" ancestor context of self and c2r   )r   r  )r'   r  s     r)   r  committablectx.ancestor  s    }}Q((,,r,   c              #    #    U R                    S h  vN   U R                  R                  R                  U R                    Vs/ s H  oR	                  5       PM     sn5       H  nU R                  U   v   M     g  Njs  snf 7fr#   )r   r%   r_  r  rc   )r'   r  r  s      r)   r  committablectx.ancestors  sc     ==  %%//"mm,mUUWm,
A **Q-
 	!,s!   BA=1BA?!B?Bc                    g)a)  Perform post-commit cleanup necessary after committing this ctx

Specifically, this updates backing stores this working context
wraps to reflect the fact that the changes reflected by this
workingctx have been committed.  For example, it marks
modified and added files as normal in the dirstate.

NrG   )r'   r.   s     r)   markcommittedcommittablectx.markcommitted	  s    r,   c                    gr?   rG   )r'   missingmerger>  s       r)   dirtycommittablectx.dirty  r  r,   )r  r  r   r@   r  r  r  )r,   NNNNNFTT).r9   rG  rH  rI  rJ  r*   r0   r   r
   rK  rL  r[  r  rM  r  r  r  r   rz  rr  rs  rt  r   rt   ru   rv   rd   r  r  r  r>  r?  ru  r  r  r  r   r  r  r   r  r  r;  r@  rN  r  r  s   @r)   r  r  o  s   ? 0:.)   +G H# # ( (  6

%"$$ MJL8'
-  r,   r  c                  D  ^  \ rS rSrSr S!U 4S jjrS rS rS r\	S 5       r
S"S jrU 4S	 jrS
 r\	S 5       rS rS"S jrS#S jrS$S jrS$S jrS r       S%S jrS rS rS r S& S'S jjr\	S 5       r\	S 5       rS rU 4S jrS rS rS r S r!S(S jr"S r#U =r$$ ))
workingctxi  a]  A workingctx object makes access to data related to
the current working directory convenient.
date - any valid date string or (unixtime, offset), or None.
user - username string, or None.
extra - a dictionary of extra values, or None.
changes - a list of file lists as returned by localrepo.status()
           or None to use the repository status.
c           
        > S nU(       a  SU;  a   UR                   R                  5       n[        TU ]  XX4XVUS9  g ! [         a     [        R                  " [        S5      5      ef = f)Nr  s   branch name not in UTF-8!r>  )dirstater>  UnicodeDecodeErrorr   r  r   rQ  r*   r  s	           r)   r*   workingctx.__init__!  sl     	.C--/ 	TO & Ckk!$@"ABBCs	   = *A'c              #     #    U R                   R                  nU H)  nUR                  U5      R                  (       d  M%  Uv   M+     g 7fr#   r%   rG  	get_entrytracked)r'   rx   r%  s      r)   rX   workingctx.__iter__,  s7     JJA{{1~%%% s   :A	 	A	c                `    U R                   R                  R                  U5      R                  $ r#   rK  rN   s     r)   rP   workingctx.__contains__2  s#    zz"",,S1999r,   c                B    U R                   R                  R                  $ r#   r  r/   s    r)   r   workingctx.hex5  s    zz''///r,   c           
     `   U R                   R                  R                  5       nUS   U R                   R                  R                  :X  a  US S nU R                   R                  5       nU Vs/ s H2  n[        U R                   UR                  R                  U5      USS9PM4     sn$ s  snf )Nr   r  Frm  )	r%   rG  r   rk   r  r^  r)  r_  rc   )r'   r  unfir  s       r)   r   workingctx._parents8  s    JJ'')Q44::++222#2Azz$$&
 	
  

DNN..q11U 	
 	
 
s   /9B+c                p   Uc   U R                   R                  R                  nU R                   R                  nUR	                  U R                   5         UR                  X5      nU R                   U   nU(       a.  U H(  nXe;  d  M
  XF   U;   d  M  UR                  XF   U5        M*     X R                   R                  R                  :X  aP  [        UR                  5       R                  5       5       H%  u  pgXe;  d  M  Xu;  d  M  UR                  S U5        M'     S S S 5        g ! , (       d  f       g = fr#   )
r%   rk   r  rG  changing_parents
setparentsr  r  copiesri   )r'   p1nodep2noderG  rY  r   r%  rn   s           r)   rX  workingctx.setparentsF  s    >ZZ--44F::&&&&tzz2((8F::f%D  A}d): fi3   11888"8??#4#:#:#<=DA} dA. > 322s%   0D'	D'A*D'D'D''
D5c                :   > U R                     [        TU ]	  U5      $ r#   )rM   rQ  r   )r'   r   r:  s     r)   r   workingctx._fileinfoY  s    w &&r,   c                  ^^^^	^
 U R                   R                  R                  5       R                  mU R	                  5       n[        U5      S:  a  US   R                  5       m
UU
4S jnU$ Uu  p4UR                  U5      nUR                  5       UR                  5       UR                  5       smmm	UUUU	4S jnU$ )Nr   r   c                6   > T" X 5      n TR                  U 5      $ r#   rk  )r%  	copiesgetmans    r)   func'workingctx._buildflagfunc.<locals>.funch  s    aOyy|#r,   c                   > T" X 5      n TR                  U 5      TR                  U 5      TR                  U 5      p2nX:X  a  U$ X:X  a  U$ X#:X  a  U$ gNr,   rk  )r%  fl1fl2flara  m1m2mas       r)   rc  rd  s  sP    aO "RXXa["((1+#:J:J:Jr,   )r%   rG  rY  r  r   r   r[   r  )r'   r   rc  r   r   para  rj  rk  rl  rb  s         @@@@@r)   _buildflagfuncworkingctx._buildflagfunc^  s     JJ''..044	,,.w<!!*%%'C$,  FBRBr{{}JBB	 	 r,   c                `    U R                   R                  R                  U R                  5      $ r#   )r%   rG  flagfuncrn  r/   s    r)   r4  workingctx._flagfunc  s#    zz""++D,?,?@@r,   c                F     U R                  U5      $ ! [         a     gf = frf  )r4  rf  r   s     r)   r   workingctx.flags  s(    	>>$'' 		s    
  c                ,    [        U R                  XUS9$ )z-get a file context from the working directory)rD  r  )workingfilectxr%   r'   r   r  s      r)   rS   workingctx.filectx  s    JJw
 	
r,   c                   [        U R                  5       H(  nU R                  U5      R                  US9(       d  M(    g   U=(       a    U R	                  5       =(       d    U=(       a/    U R                  5       U R                  5       R                  5       :g  =(       d^    U R                  5       =(       dG    U R                  5       =(       d0    U R                  5       =(       d    U=(       a    U R                  5       $ )z-check whether a working directory is modified)r>  T)r  r   r   r@  r   r>  r   rt   ru   rv   rd   )r'   r>  r?  r>  rn   s        r)   r@  workingctx.dirty  s     &Axx{   11 '
  twwy ,>4;;=DGGI,<,<,>>,}}, zz|, ||~	,
 *DLLN	
r,   c           
     t  ^^
 U R                   R                  5          U R                   R                  U R                   R                  snm
U
U4S jn/ nU R                   R                  R
                  nU GH]  n[        R                  " U[        R                  R                  TU5      5         U" U5      nUR                  SS5      n	U	S:w  aF  UR                   U	:  a6  UR                  [        S5      USUR                   -  S-  U" U5      4-  5        ["        R$                  " UR&                  5      (       d\  ["        R(                  " UR&                  5      (       d7  UR                  [        S	5      U" U5      -  5        UR                  U5        GM!  T
R+                  U5      (       a  GM:  UR                  [        S
5      U" U5      -  5        GM`     UsS S S 5        $ ! [         a9    UR                  [        S5      U" U5      -  5        UR                  U5         GM  f = f! , (       d  f       g = f)Nc                P   > TR                  [        R                  " TU 5      5      $ r#   pathtor   r  r%  dsprefixs    r)   r   workingctx.add.<locals>.<lambda>      ryyvq)ABr,      %s does not exist!
s   uis   large-file-limitr   so   %s: up to %d MB of RAM may be required to manage this file
(use 'hg revert %s' to cancel the pending addition)
r  i@B s:   %s not added: only files and symlinks supported currently
s   %s already tracked!
)r%   wlockr   rG  wvfslstatr   checkportableosr   r  rf  r  r   rj   configbytesst_sizestatS_ISREGst_modeS_ISLNKset_tracked)r'   listr  r   uipathrejectedr  r%  stlimitr  s     `       @r)   addworkingctx.add  s   ZZZZ]]DJJ$7$7FBBFHJJOO))E %%b"'',,vq*ABqB
 u.ABA:"**u"4GG3 a"**n7CD RZZ00DLL4L4LGG5 !)	$ OOA&**GGA67&)CDA B M    GGA56BCOOA&  s7   BH)0G#8C3H)0)H)#>H&!H)%H&&H))
H7c                  ^^ U R                   R                  5          U R                   R                  mUU4S jn/ nU Hc  nTR                  U5      (       a  M  U R                   R                  R                  [        S5      U" U5      -  5        UR                  U5        Me     UsS S S 5        $ ! , (       d  f       g = f)Nc                P   > TR                  [        R                  " TU 5      5      $ r#   r}  r  s    r)   r  #workingctx.forget.<locals>.<lambda>  r  r,   s   %s not tracked!
)r%   r  rG  set_untrackedr   r  r   rj   )r'   r   r  r  r  r%  r  s     `   @r)   forgetworkingctx.forget  s    ZZ$$BBFH''**JJMM&&q)='>'JKOOA&    s   9B1AB11
B?c                .    U R                   R                  R                  U5      n[        R                  " UR                  5      (       dz  [        R                  " UR                  5      (       dU  U R                   R                  R                  [        S5      U R                   R                  R                  U5      -  5        g U R                   R                  5          U R                   R                  nUR                  U5        UR                  X5        S S S 5        g ! [         aW    U R                   R                  R                  [        S5      U R                   R                  R                  U5      -  5         g f = f! , (       d  f       g = f)Nr  s1   copy failed: %s is not a file or a symbolic link
)r%   r  r  FileNotFoundErrorr   r  r   rG  r~  r  r  r  r  r  r  r  )r'   r  destr  r  s        r)   r  workingctx.copy  s   	&&t,B RZZ((DLL,D,DJJMMGH**%%,,T23
 !!#ZZ((t$% $# ! 	JJMM)*TZZ-@-@-G-G-MM 		 $#s   %D"  9F"AFF
Fc                    U R                   nU(       d  UR                  5       n[        R                  " UR                  5      (       + n	[
        R                  " UR                  UUUUUUR                  U UUU	S9$ )N)r  r  r  r   icasefs)r%   r  r   fscasesensitiver	  r  r   r  )
r'   r  r  r  r  r  r   r   r  r  s
             r)   r   workingctx.match  sn     JJ((*C **16622~~FFII%
 	
r,   c                   U(       a%  U R                   R                  R                  (       a  U$ / nU H  nU R                  U5      S:X  ar  X   R	                  5       nUS:X  d0  [        U5      S:  d!  SU;   d  [        R                  " U5      (       a*  U R                   R                  R                  SU-  5        M  UR                  U5        M     U$ )Nrq  r,   i      
s*   ignoring suspect symlink placeholder "%s"
)r%   rG  
_checklinkr   r_  r   r   re  r   debugrj   )r'   r   saner%  rx   s        r)   _filtersuspectsymlink workingctx._filtersuspectsymlink  s    

++66L Azz!}$GLLNH1v~z!((++JJMM''FJ KKN  r,   c                n   U(       d  / / / / 4$ / n/ n/ n/ nU R                   S   n[        U5       H  n X;  d>  U R                  U5      UR                  U5      :w  d  Xx   R                  X   5      (       a  UR	                  U5        MZ  Uc  UR	                  U5        Mp  X   R                  5       n	U	R                  n
U	R                  n[        R                  " X5      nUb  XU4nUR	                  X45        M  UR	                  U5        M     X4XV4$ ! [         a    UR	                  U5         GM  f = fr   )r   r  r   rm   rj   r  r  r  r   reliable_mtime_ofrf  )r'   r   mtime_boundaryrt   rd   rb   fixupr   r%  rn   moder`  
file_mtime
cache_infos                 r)   _checklookupworkingctx._checklookup  s   r2r>!}}QA" Mzz!}

15w{{47++OOA&#+LLOA99D99D!*!<!<Q!OJ!-&**%=
a_5Q+ > %..  " q!!"s%   AD
D AD;DD43D4c                  ^ [         R                  " U R                  R                  S5        U R                  R                  mU R                  R                  5       nU(       a7  TR                  (       a  U4S jnOTR                  nU H  u  pVU" XV5        M     U(       d%  U R                  R                  R                  (       a   TR                  nU R                  R                  S5         U R                  R                  TL d   eTR                  nU(       a,  U R                  R                  5       n	TR                  U	5        O.U(       a'  Sn
U R                  R                  R                  U
5        U(       a  U H  nU" X5        M     SSS5        U R                  R!                  5         gg! , (       d  f       N*= f! [        R                   a    TR                  5          NSf = f! U R                  R!                  5         f = f)z1update dirstate for files that are actually cleans   status.pre-dirstate-write-filec                &   > TR                  U SSS9$ )NT
p1_tracked
wc_tracked)update_file)r%  pfdrG  s     r)   r  -workingctx._poststatusfixup.<locals>.<lambda>R  s    (<(<## )= )r,   Fs*   skip updating dirstate: identity mismatch
N)r   wait_on_cfgr%   r   rG  postdsstatusis_changing_parents	set_clean_dirtyr  currenttransactionwriter  r   	LockError
invalidateclearpostdsstatus)r'   r   r  
poststatusnormalr%  pdf	pre_dirty
post_dirtytrr  psrG  s               @r)   _poststatusfixupworkingctx._poststatusfixupK  sw   DJJMM+LM::&&ZZ,,.
++ "++q  ,,33/
 %OO	ZZ%%e,::..(:::!)J!!ZZ::< r*" K

++A.!",Bt, #- -$ 

,,.3 4 -, ?? &##%& 

,,.sI   'G /B!F4G 4
G>G G/ G $G,)G/ +G,,G/ /Hc           	        / nSU ;   a  [        U R                  5      nU R                  R                  nUR	                  U R                  5         UR                  XX#US9u  pxn	/ n
U(       a  U R                  Xy5      u  ppUR                  R                  U5        UR                  R                  U5        U(       a"  U(       a  UR                  R                  U5        U
(       a)  U(       a"  UR                  R                  S U
 5       5        U R                  X5        SSS5        UR                  5       (       a  WR                  (       d"  UR                  (       d  UR                  (       aK  [        R
                  " UR                  UR                   UR"                  UR                  / / / 5      U l        U$ Xl        W$ ! , (       d  f       N= f)z7Gets the status from the dirstate -- internal use only.s   .hgsub)rf   rb   re   c              3  *   #    U  H	  u  pUv   M     g 7fr#   rG   )r$  r%  r   s      r)   r&  -workingctx._dirstatestatus.<locals>.<genexpr>  s     #8%$!A%s   N)r  r   r%   rG  running_statusr   r  rt   r.  rd   rb   r  alwaysre   rf   r   ru   rv   r  )r'   r   rf   rb   re   subreposrG  rm   rn   r  r  	modified2deleted2	clean_sets                 r)   _dirstatestatusworkingctx._dirstatestatusv  sU    dmm,H::&&$$TZZ0%-__w &5 &"CN
 E8<8I8I95	Y 

!!),		  *GGNN9-UGGNN#8%#89!!!+' 1* <<>>yyAII&~~JJAIIr2r    !? 10s   CG
Gc                <   0 n0 nU R                   R                  R                  5       nU R                   US      R                  5       nU R                   US      R                  5       n[	        U R                  5       5      [	        U R                  5       5      -  nU R                   R                  5       nU R                   R                  R                  5       R                  5        H/  u  pX;  d  U" U5      (       d  M  X;   a  XU'   M$  X;   d  M+  XU'   M1     X4$ r  )
r%   rG  r   r[   rg   ru   rt   r*  rY  ri   )
r'   r   r   r   
p1manifest
p2manifest
changedsetr*  dstsrcs
             r)   r   workingctx._copies  s    **%%--/ZZ
+446
ZZ
+446
&T]]_)==
jj,,.

++224::<HC$K,<,<  #" # = !!r,   c                8    U R                  U R                  5      $ )a$  generate a manifest corresponding to the values in self._status

This reuse the file nodeid from parent, but we use special node
identifiers for added and modified files. This is used by manifests
merge to see that files are different and by update logic to avoid
deleting newly added files.
)r\   r  r/   s    r)   rM   workingctx._manifest  s     ((66r,   c                    U R                  5       nUS   R                  5       R                  5       nU R                  nU R                  R
                  R                  UR                  4U R                  R
                  R                  UR                  44 H*  u  pVU H  nXSU'    UR                  Xt" U5      5        M!     M,     UR                  UR                  -    H  nXs;   d  M
  X7	 M     U$ ! [         a     M_  f = f)z9Builds a manifest that includes the given status results.r   )r   r[   r  r4  r%   rk   addednodeidru   modifiednodeidrt   setflagrf  rd   rv   )r'   r   r   rb  ffir  r%  s           r)   r\   workingctx._buildstatusmanifest  s    ,,.aj!!#((*^^ZZ%%116<<@ZZ%%44fooF
DA AKK2a5) 	
 &..0AxF 1 
  s   %C//
C=<C=c                   > U R                  X4XV5      nU R                  UR                  5      UR                  SS& XR                  S   :w  a  [        TU ]  XX4XV5      nU$ )a  build a status with respect to another context

This includes logic for maintaining the fast path of status when
comparing the working directory against its parent, which is to skip
building a new manifest if self (working directory) is not comparing
against its parent (repo['.']).
N   .)r  r  rt   r%   rQ  r   )r'   rC   rn   r   ro   rp   rq   r:  s          r)   r   workingctx._buildstatus  sa       YL 221::>

1JJt$$$%iA r,   c                J   ^ ^ TT R                   S   :w  a  UU 4S jnX2l        U$ )ac  override the match method with a filter for directory patterns

We use inheritance to customize the match.bad method only in cases of
workingctx since it belongs only to the working directory when
comparing against the parent changeset.

If we aren't comparing against the working directory's parent, then we
just use the default match object sent to us.
r  c                   > U T;  ae  TR                  U 5      (       dN  TR                  R                  R                  STR                  R                  R                  U 5      U4-  5        g g g )Ns   %s: %s
)r  r%   r   r  rG  r~  )r%  r  rC   r'   s     r)   r  $workingctx._matchstatus.<locals>.bad  sW     E>%,,q//JJMM&&#tzz':':'A'A!'Dc&JJ +:>r,   )r%   r  )r'   rC   r   r  s   ``  r)   r_   workingctx._matchstatus  s'     DJJt$$ Ir,   c           	         [        U R                  R                  R                  U R                  R	                  U5      [        U R
                  5      SSS95      $ )r  TF)r  re   rf   )r  r%   rG  r  r*  r   r  s     r)   r  workingctx.walk   sP    JJ$$

&&u-.	 % 
 	
r,   c                   ^ U R                   R                  U5      nU R                   R                  m[        U4S jTR	                  U5       5       5      $ )Nc              3  l   >#    U  H)  nTR                  U5      R                  (       d  M%  Uv   M+     g 7fr#   )rL  rM  )r$  r%  r  s     r)   r&  %workingctx.matches.<locals>.<genexpr>  s%     N!2Abll1o6M6Maa!2s   $4	4)r%   r*  rG  r  r  )r'   r   r  s     @r)   r  workingctx.matches  s@    

&&u-ZZ  NE!2NNNr,   c                   U R                   R                  R                  U R                   5         U R                  5       U R	                  5       -    H(  nU R                   R                  R                  USSS9  M*     U R                  5        H(  nU R                   R                  R                  USSS9  M*     U R                   R                  R                  U5        U R                   R                  5         [        R                  " U R                   U5        S S S 5        U R                   R                  R                  U R                   R                  5       5        g ! , (       d  f       NL= f)NTr  F)r%   rG  rW  rt   ru   r  rv   rX  !_quick_access_changeid_invalidater   aftercommitr  r  )r'   r.   r%  s      r)   r;  workingctx.markcommitted  s   ZZ  11$**=]]_tzz|3

##//$4 0  4 \\^

##//%E 0  $ JJ**40JJ88:tzz40 >" 	

!!$**"?"?"AB# >=s   C*E  
E.c                    U(       a)  [         R                  R                  U R                  5      $ [         R                  R	                  U R                  5      $ r#   )mergestatemodr   rb   r%   rc  r;  s     r)   r   workingctx.mergestate$  s;     ++11$**=='',,TZZ88r,   )r  )r,   NNNNr#   rB  r,   rE  FFFrB  rF  )%r9   rG  rH  rI  rJ  r*   rX   rP   r   rM  r   rX  r   rn  r4  r   rS   r@  r  r  r  r   r  r  r  r  r   rM   r\   r   r_   r  r  r;  r   rN  r  r  s   @r)   rD  rD    s    IM	P:0 
 
/&'
 D A A

 'R	&* 
>2*/X)/X :?'	'R " "" 7 70*.	
O
C(9 9r,   rD  c                  D    \ rS rSrSrSS jrS r\rS rS r	S r
S	 rS
rg)committablefilectxi*  zA committablefilectx provides common functionality for a file context
that wants the ability to commit, e.g. workingfilectx or memfilectx.Nc                t    Xl         X l        S U l        S =U l        U l        Ub  X0l        U(       a  X@l        g g r#   )r%   r  r  r  r  r  r  )r'   r(   r   r  r  s        r)   r*   committablefilectx.__init__.  s9    

)--#M!O r,   c                    gr  rG   r/   s    r)   r[  committablefilectx.__nonzero__9  r  r,   c                "    U R                  5       $ r#   )rc   r/   s    r)   r  committablefilectx.linkrev>  s    xxzr,   c                    U R                  5       nU(       d  g UU R                  R                  S   R                  R	                  XR
                  R                  R                  5      4$ r   )rZ  r  r   rM   r  r%   rk   r  r   s     r)   rV  committablefilectx.renamedB  sW     OO$$Q'1155jj..55
 	
r,   c                  ^  U 4S jnT R                   nT R                  nT R                  R                  nT R	                  5       nU(       a  US-   /nOX!" US   U5      U4/nUSS  H  nUR                  X!" Xr5      U45        M     U VV	V
s/ s H<  u  pn
U	T R                  R                  R                  :w  d  M,  T R                  XU
S9PM>     sn
n	n$ s  sn
n	nf )z5return parent filectxs, following copies if necessaryc                x   > U R                   R                  UTR                  R                  R                  5      $ r#   )rM   r  r%   rk   r  )r  r   r'   s     r)   r   ,committablefilectx.parents.<locals>.filenodeP  s*    ==$$T4::+C+C+J+JKKr,   r#   r   r   Nr  )
r  r  r  r   rV  rj   r%   rk   r  r  )r'   r   r   r  pclrV  r  pcr  r  r  s   `          r)   r   committablefilectx.parentsM  s    	L zz]]oo&&,,.G#$B#a&$/45Bab'BIItXb/45 
 
aDJJ,,333 8DQ7
 	
 
s   +C=Cc                    / $ r#   rG   r/   s    r)   r  committablefilectx.childrenf  r(  r,   )r  r  r  r  r  r  r%   r  )r9   rG  rH  rI  rJ  r*   r[  r  r  rV  r   r  rN  rG   r,   r)   r  r  *  s-    L	" H	

2r,   r  c                     ^  \ rS rSrSrSU 4S jjr\S 5       rS 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S rS rSrU =r$ )rv  ij  znA workingfilectx object makes access to data related to a particular
file in the working directory convenient.c                &   > [         TU ]  XX45        g r#   rQ  r*   )r'   r(   r   r  rD  r:  s        r)   r*   workingfilectx.__init__n  s    W9r,   c                ,    [        U R                  5      $ r#   )rD  r%   r/   s    r)   r  workingfilectx._changectxq  s    $**%%r,   c                L    U R                   R                  U R                  5      $ r#   )r%   wreadr  r/   s    r)   r_  workingfilectx.datau  s    zz

++r,   c                `    U R                   R                  R                  U R                  5      $ r#   )r%   rG  copiedr  r/   s    r)   rZ  workingfilectx.copysourcex  s!    zz""))$**55r,   c                t    U R                   R                  R                  U R                  5      R                  $ r#   )r%   r  r  r  r  r/   s    r)   r`  workingfilectx.size{  s%    zz$$TZZ0888r,   c                `    U R                   R                  R                  U R                  5      $ r#   )r%   r  r  r  r/   s    r)   r  workingfilectx.lstat~      zz$$TZZ00r,   c                    U R                   R                  5       u  p U R                  R                  R	                  U R
                  5      [        R                     U4$ ! [         a    X4s $ f = fr#   )	r  rs  r%   r  r  r  r  ST_MTIMEr  )r'   ttzs      r)   rs  workingfilectx.date  s\    $$&	JJOO))$**5dmmDbII  	7N	s   AA   A0/A0c                `    U R                   R                  R                  U R                  5      $ r#   )r%   r  existsr  r/   s    r)   r+  workingfilectx.exists  s    zz%%djj11r,   c                `    U R                   R                  R                  U R                  5      $ r#   )r%   r  lexistsr  r/   s    r)   r.  workingfilectx.lexists  s    zz&&tzz22r,   c                `    U R                   R                  R                  U R                  5      $ r#   )r%   r  auditr  r/   s    r)   r1  workingfilectx.audit  r$  r,   c                $    UR                  U 5      $ )rx  )rm   r}  s     r)   rm   workingfilectx.cmp  s     xx~r,   c                    U R                   R                  R                  SS5      nU R                   R                  R	                  U R
                  XS9  g)+wraps unlink for a repo's working directoryr  s   removeemptydirs)ignoremissingrmdirN)r%   r   
configboolr  
unlinkpathr  )r'   r7  r8  s      r)   removeworkingfilectx.remove  sA    

((:LM

""JJm 	# 	
r,   c                V    U R                   R                  " U R                  X4SU0UD6$ )wraps repo.wwritebackgroundclose)r%   wwriter  r'   r_  r   r?  kwargss        r)   r  workingfilectx.write  s2    zz  JJ
5D
HN
 	
r,   c                b    U R                   R                  R                  XR                  5        g)zmarks this file a copy of `src`N)r%   rG  r  r  )r'   r  s     r)   
markcopiedworkingfilectx.markcopied  s    

  jj1r,   c                h   U R                   R                  nU R                  nUR                  U5        U R                   R                  R                  SS5      (       a  UR                  U5      (       a&  UR                  U5      (       d  UR                  USS9  [        [        [        R                  " U5      5      5       H,  nUR                  U5      (       d  M  UR                  U5          g   gUR                  U5      (       a)  UR                  U5      (       d  UR                  U5        ggg)zcRemoves conflicting items in the working directory so that
``write()`` can be called successfully.
r  s   merge.checkpathconflictsT)forciblyN)r%   r  r  r1  r   r9  isdirrr  rmtreer1  r  r   finddirsisfileorlinkunlink
removedirs)r'   r  r%  r  s       r)   clearunknownworkingfilectx.clearunknown  s     zzJJ

1::==##8
 

 zz!}}T[[^^A-d8#4#4Q#789$$Q''KKN : zz!}}T[[^^" &4}r,   c                d    U R                   R                  R                  U R                  X5        g r#   )r%   r  setflagsr  )r'   r  r  s      r)   rR  workingfilectx.setflags  s    

  Q2r,   rG   r  rF  )r9   rG  rH  rI  rJ  r*   rM  r  r_  rZ  r`  r  rs  r+  r.  r1  rm   r;  r  rE  rO  rR  rN  r  r  s   @r)   rv  rv  j  sl    1: & &,691231

2#.3 3r,   rv  c                  ,  ^  \ rS rSrSrU 4S jrS rS&S jrS r\	S 5       r
\	S 5       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S rS rS'S jrS rS rS rS rS r      S(S jr S r!S r"S  r#S! r$ S)S" jr%S&S# jr&S*S$ jr'S%r(U =r)$ )+overlayworkingctxi  am  Wraps another mutable context with a write-back cache that can be
converted into a commit context.

self._cache[path] maps to a dict with keys: {
    'exists': bool?
    'date': date?
    'data': str?
    'flags': str?
    'copied': str? (path or None)
}
If `exists` is True, `flags` must be non-None and 'date' is non-None. If it
is `False`, the file was deleted.
c                D   > [         TU ]  U5        U R                  5         g r#   )rQ  r*   rb   )r'   r(   r:  s     r)   r*   overlayworkingctx.__init__  s    

r,   c                N    Xl         U/U l        [        R                  " U S5        g )N	   _manifest)_wrappedctxr   r   clearcachedproperty)r'   
wrappedctxs     r)   setbaseoverlayworkingctx.setbase  s#    %# 	  |4r,   c                    Uc   U R                   R                  R                  nXR                  R	                  5       :X  d   eU R                  U R                   R                  5       U   /U l        g r#   )r%   rk   r  rZ  r.   r^  r   )r'   rZ  r[  s      r)   rX  overlayworkingctx.setparents  s[    >ZZ--44F))..0000))4::+@+@+B6+JKr,   c                L   U R                  U5      (       ar  U R                  U   S   (       aB  U R                  U   S   b  U R                  U   S   $ U R                  U   R                  5       $ [        R
                  " SU-  5      eU R                  U   R                  5       $ N   exists   data   No such file or directory: %s)isdirty_cacherZ  r_  r   r{  r   s     r)   r_  overlayworkingctx.data  s    <<{{4 +;;t$W-9;;t,W55  ++D16688,,4t;  ##D)..00r,   c                   U R                  5       nUS   R                  5       R                  5       nU R                  nU R	                  5        H<  nU R
                  R                  R                  X$'   UR                  XC" U5      5        M>     U R                  5        H<  nU R
                  R                  R                  X$'   UR                  XC" U5      5        M>     U R                  5        H  nX$	 M     U$ r   )r   r[   r  r4  ru   r%   rk   r  r  rt   r  rv   )r'   r   rb  r   r   s        r)   rM   overlayworkingctx._manifest  s    ,,.aj!!#((*~~JJLD

00<<CIKKd4j) ! MMOD

00??CIKKd4j) $ LLND	 #
r,   c                   ^  U 4S jnU$ )Nc                (   > TR                   U    S   $ )N   flagsrg  )r   r'   s    r)   r%  &overlayworkingctx._flagfunc.<locals>.f	  s    ;;t$X..r,   rG   r'   r%  s   ` r)   r4  overlayworkingctx._flagfunc	  s    	/ r,   c                x    [        U R                  5       U R                  5       -   U R                  5       -   5      $ r#   )r  ru   rt   rv   r/   s    r)   r   overlayworkingctx.files	  s)    djjlT]]_4t||~EFFr,   c                    U R                   R                  5        Vs/ s H6  nU R                   U   S   (       d  M  U R                  U5      (       d  M4  UPM8     sn$ s  snf Nrc  rg  keys_existsinparentrp  s     r)   rt   overlayworkingctx.modified	  sY     [[%%'
'{{1~i( -1-A-A!-D '
 	
 
   AAAc                    U R                   R                  5        Vs/ s H6  nU R                   U   S   (       d  M  U R                  U5      (       a  M4  UPM8     sn$ s  snf ru  rv  rp  s     r)   ru   overlayworkingctx.added	  sY     [[%%'
'{{1~i( 151E1Ea1H '
 	
 
rz  c                    U R                   R                  5        Vs/ s H6  nU R                   U   S   (       a  M  U R                  U5      (       d  M4  UPM8     sn$ s  snf ru  rv  rp  s     r)   rv   overlayworkingctx.removed	  sY     [[%%'
';;q>), 151E1Ea1H '
 	
 
rz  c                    0 nU R                   R                  5       nU R                  R                  5        HC  nU" U5      (       d  M  UR	                  US 5        U R                  U   S   nU(       d  M?  XAU'   ME     U$ N   copiedr%   r*  rg  rw  r  r'   rY  r*  r%  r  s        r)   r   overlayworkingctx.p1copies%	  o    jj,,.!!#Aq>>JJq$[[^I.Fv"q	 $ r,   c                    0 nU R                   R                  5       nU R                  R                  5        HC  nU" U5      (       d  M  UR	                  US 5        U R                  U   S   nU(       d  M?  XAU'   ME     U$ r  r  r  s        r)   r   overlayworkingctx.p2copies1	  r  r,   c                    gr  rG   r/   s    r)   r  overlayworkingctx.isinmemory=	  r  r,   c                    U R                  U5      (       a  U R                  U   S   $ U R                  U   R                  5       $ )N   date)rf  rg  rZ  rs  r   s     r)   filedateoverlayworkingctx.filedate@	  s?    <<;;t$W--##D)..00r,   c                f    U R                  USU R                  U5      U R                  U5      US9  g )NT)r+  rs  r   r  )
_markdirtyr  r   )r'   r   origins      r)   rE  overlayworkingctx.markcopiedF	  s4    t$**T" 	 	
r,   c                T    U R                  U5      (       a  U R                  U   S   $ g r  )rf  rg  r   s     r)   copydataoverlayworkingctx.copydataO	  s(    <<;;t$Y//r,   c                    U R                  U5      (       aB  U R                  U   S   (       a  U R                  U   S   $ [        R                  " SU-  5      eU R                  U   R                  5       $ )Nrc  rm  re  )rf  rg  r   r{  rZ  r   r   s     r)   r   overlayworkingctx.flagsU	  sm    <<{{4 +{{4(22,,4t;  ##D)//11r,   c                h    XR                   ;   a  U R                   U   S   $ XR                  5       ;   $ ru  )rg  r   rN   s     r)   rP   overlayworkingctx.__contains__`	  s/    ++;;s#I..ggir,   c                X     U R                   U     g! [        R                   a     gf = fr  )rZ  r   r   r   s     r)   rx  !overlayworkingctx._existsinparente	  s2    	 T"(( 		s    ))c           
     b  ^  U 4S jnUR                  S5      n[        [        U5      5       H'  nSR                  USU 5      nUT ;   d  M  U" X5        M)     T R	                  U/SS9n[        T R                  5       R                  5       R                  U5      5      n[        U5      S:  a}  [        U5      S:X  a
  US   U:X  a  gU Vs/ s H  oT ;   d  M
  UPM     nnU(       d  g[        R                  " SXT R                  5       [        U5      S	R                  U5      4-  5      egs  snf )
a  Replicates conflict checks done by wvfs.write().

Since we never write to the filesystem and never call `applyupdates` in
IMM, we'll never check that a path is actually writable -- e.g., because
it adds `a/foo`, but `a` is actually a file in the other commit.
c                *  > STR                  5       U   R                  5       ;   a7  [        R                  " SXTR                  5       R	                  5       4-  5      e[        R                  " SXTR                  5       R	                  5       4-  5      e)Nrq  s*   error: %s conflicts with symlink %s in %d.s+   error: '%s' conflicts with file '%s' in %d.)r   r   r   r  rc   )r   	componentr'   s     r)   fail/overlayworkingctx._auditconflicts.<locals>.failw	  s     twwy+1133kk!%$'')--/ BC 
 kk"twwy}}?@ r,   r  r   s   path)r  r   Nsb   error: file '%s' cannot be written because  '%s/' is a directory in %s (containing %d entries: %s)s   , )splitranger   r  r   r  r   r[   r  r   r  )	r'   r   r  
componentsr  r  r   mfilesr  s	   `        r)   _auditconflicts!overlayworkingctx._auditconflictso	  s   	  ZZ%
s:'A		*Qq/2ID T% ( 

D67
3dggi((*//67v;?6{aF1I$5!'5A9aF5++  twwy#f+uzz&7IJK   6s   	D,D,c                    Uc  [         R                  " S5      eU R                  U5        U R                  USU[        R
                  " 5       US9  g )Ns   data must be non-NoneT)r+  r_  rs  r   )r   r{  r  r  r   r  )r'   r   r_  r   rB  s        r)   r  overlayworkingctx.write	  sL    <(()ABBT"Dx/@/@/B% 	 	
r,   c                x    SnU(       a  SnO	U(       a  SnU R                  US[        R                  " 5       US9  g )Nr,   rq  rj  T)r+  rs  r   )r  r   r  )r'   r   r  r  r   s        r)   rR  overlayworkingctx.setflags	  s4    DDT0A0A0C4Pr,   c                $    U R                  USS9  g )NF)r+  )r  r   s     r)   r;  overlayworkingctx.remove	  s    U+r,   c                ,   U R                  U5      (       an  U R                  U   S   (       aE  SU R                  U   S   ;   a/  U R                  U R                  U   S   R                  5       5      $ U R                  U   S   $ U R	                  U5      $ )zaexists behaves like `lexists`, but needs to follow symlinks and
return False if they are broken.
rc  rq  rm  rd  )rf  rg  r+  striprx  r   s     r)   r+  overlayworkingctx.exists	  s     << D!),DKK-h77{{4;;t#4W#=#C#C#EFF{{4(33##D))r,   c                t    U R                  U5      (       a  U R                  U   S   $ U R                  U5      $ )z'lexists returns True if the path existsrc  )rf  rg  rx  r   s     r)   r.  overlayworkingctx.lexists	  s6    <<;;t$Y//##D))r,   c                    U R                  U5      (       aK  U R                  U   S   (       a  [        U R                  U   S   5      $ [        R                  " SU-  5      eU R
                  U   R                  5       $ rb  )rf  rg  r   r   r{  rZ  r`  r   s     r)   r`  overlayworkingctx.size	  sr    <<{{4 +4;;t,W566,,4t;  %**,,r,   c                r  ^  Uc&  T R                  5       n[        U5      S:X  a  US   S4nUS   c  T R                  US      S4nO$T R                  US      T R                  US      4nT R                  5       nU 4S jn	Uc  T R                  R                  5       n[        T R                  UUUU	UUUUUS9
$ )zConverts this ``overlayworkingctx`` into a ``memctx`` ready to be
committed.

``text`` is the commit message.
``parents`` (optional) are rev numbers.
Nr   r   c           
        > TR                   R                  U5      nUc  TR                  U5      $ US   (       a#  [        U UUUS   SUS   ;   SUS   ;   US   5      $ g )Nrc  rd  rq  rm  rj  r  )rg  r  rS   
memfilectx)r(   memctxr   hitr'   s       r)   getfile+overlayworkingctx.tomemctx.<locals>.getfile	  sq    ++//$'C{||D))Y!LCM)CM)	N  r,   )rs  ru  rr  r>  editor)r   r   r%   r   rZ  r>  r  )
r'   r  r>  ru  rs  r   rr  r  r   r  s
   `         r)   tomemctxoverlayworkingctx.tomemctx	  s    " ?llnG7|q "1:t, 1:zz'!*-t4Gzz'!*-tzz'!*/EFG

	& >%%,,.FJJ
 	
r,   c                    UR                  5       R                  5       nUR                  5       US'   U R                  UR	                  5       UR                  5       UUR                  5       UR                  5       S9$ )Ns   amend_source)r  r>  ru  rs  rr  )ru  r  r   r  rt  r>  rs  rr  )r'   	precursorru  s      r)   tomemctx_for_amend$overlayworkingctx.tomemctx_for_amend
  sl    !&&(!*o}}&&(##%!!  
 	
r,   c                    XR                   ;   $ r#   rn  r   s     r)   rf  overlayworkingctx.isdirty 
  s    {{""r,   c                     S U l         0 U l        g r#   )_mergestaterg  r/   s    r)   rb   overlayworkingctx.clean#
  s    r,   c           	     p   / n[         R                  " U R                  5       U R                  5       R	                  5       [         R
                  " U R                  5       U R                  R                  5       5      4/5        U R                  R                  5        He  nU R                  U   n U R                  U   nUR                  5       US   :X  a,  UR                  5       US   :X  a  UR                  U5        Mc  Me  Mg     U H  nU R                  U	 M     U$ ! [        R                   a     M  f = f)zRemoves keys from the cache that are actually clean, by comparing
them with the underlying context.

This can occur during the merge process, e.g. by passing --tool :local
to resolve a conflict.
rd  rm  )r   prefetchfilesr(   r   rc   
matchfilesrg  rw  rZ  r_  r   rj   r   r   )r'   rw  r   cache
underlyings        r)   _compactoverlayworkingctx._compact'
  s     	IIK GGIMMO&&tyy{DKK4D4D4FG	
 KK$$&DKK%E	!--d3
OO%w7"((*eHo=KK% > 8 ' DD!  ,, s   /ADD54D5c                   U(       aX  UcU  U R                   R                  U5      =(       d    0 nUR                  S5      nUc  U R                  U   R                  5       nUUUUUS.U R                   U'   [        R
                  " U S5        g )Nrd  )rc  rd  r  rm  r  rY  )rg  r  rZ  r_  r   r[  )r'   r   r+  r_  rs  r   r  oldentrys           r)   r  overlayworkingctx._markdirtyL
  s     dl{{t,2H<<(D|''-224 
D 	  |4r,   c                ,    [        U R                  XUS9$ )N)r  r  )overlayworkingfilectxr%   rw  s      r)   rS   overlayworkingctx.filectxa
  s    $JJ7
 	
r,   c                    U(       d  U R                   c%  [        R                  " U R                  5      U l         U R                   $ r#   )r  r  memmergestater%   r;  s     r)   r   overlayworkingctx.mergestatef
  s3    D$$,,::4::FDr,   )rg  r  r   rZ  r#   r   NNNNNN)NNr,   NrF  )*r9   rG  rH  rI  rJ  r*   r]  rX  r_  rM  rM   r4  r   rt   ru   rv   r   r   r  r  rE  r  r   rP   rx  r  r  rR  r;  r+  r.  r`  r  r  rf  rb   r  r  rS   r   rN  r  r  s   @r)   rU  rU    s    5L1    G




1
	2 
.`
Q,*"*- ?
B	
##L EI5*

   r,   rU  c                     ^  \ rS rSrSrSU 4S j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SS jrSS jrS rSrU =r$ )r  il
  zWrap a ``workingfilectx`` but intercepts all writes into an in-memory
cache, which can be flushed through later by calling ``flush()``.c                J   > [         TU ]  XX45        Xl        X@l        X l        g r#   )rQ  r*   r%   _parentr  )r'   r(   r   r  r  r:  s        r)   r*   overlayworkingfilectx.__init__p
  s!    W5

r,   c                D    U R                  5       UR                  5       :g  $ r#   r_  r}  s     r)   rm   overlayworkingfilectx.cmpv
      yy{diik))r,   c                    U R                   $ r#   )r  r/   s    r)   r)  overlayworkingfilectx.changectxy
  rX  r,   c                L    U R                   R                  U R                  5      $ r#   )r  r_  r  r/   s    r)   r_  overlayworkingfilectx.data|
      ||  ,,r,   c                L    U R                   R                  U R                  5      $ r#   )r  r  r  r/   s    r)   rs  overlayworkingfilectx.date
      ||$$TZZ00r,   c                "    U R                  5       $ r#   )r.  r/   s    r)   r+  overlayworkingfilectx.exists
  s    ||~r,   c                L    U R                   R                  U R                  5      $ r#   )r  r+  r  r/   s    r)   r.  overlayworkingfilectx.lexists
      ||""4::..r,   c                L    U R                   R                  U R                  5      $ r#   )r  r  r  r/   s    r)   rZ   overlayworkingfilectx.copysource
  r  r,   c                L    U R                   R                  U R                  5      $ r#   )r  r`  r  r/   s    r)   r`  overlayworkingfilectx.size
  r  r,   c                P    U R                   R                  U R                  U5        g r#   )r  rE  r  )r'   r  s     r)   rE   overlayworkingfilectx.markcopied
  s    

F3r,   c                    g r#   rG   r/   s    r)   r1  overlayworkingfilectx.audit
      r,   c                L    U R                   R                  U R                  5      $ r#   )r  r   r  r/   s    r)   r   overlayworkingfilectx.flags
  s    ||!!$**--r,   c                N    U R                   R                  U R                  X5      $ r#   )r  rR  r  )r'   rr  rl  s      r)   rR  overlayworkingfilectx.setflags
  s    ||$$TZZ@@r,   c                R    U R                   R                  " U R                  X40 UD6$ r#   )r  r  r  rA  s        r)   r  overlayworkingfilectx.write
  s"    ||!!$**dDVDDr,   c                L    U R                   R                  U R                  5      $ r#   )r  r;  r  r'   r7  s     r)   r;  overlayworkingfilectx.remove
  r  r,   c                    g r#   rG   r/   s    r)   rO  "overlayworkingfilectx.clearunknown
  r  r,   )r  r  r%   r  rF  )r9   rG  rH  rI  rJ  r*   rm   r)  r_  rs  r+  r.  rZ  r`  rE  r1  r   rR  r  r;  rO  rN  r  r  s   @r)   r  r  l
  s`    I*-1/1-4.AE/ r,   r  c                  T   ^  \ rS rSrSr SU 4S jjr S S	S jjr\S 5       rSr	U =r
$ )
workingcommitctxi
  zA workingcommitctx object makes access to data related to
the revision being committed convenient.

This hides changes in the working directory, if they aren't
committed in this context.
c                (   > [         TU ]  XXEXb5        g r#   r  )r'   r(   r  r  rr  rs  ru  r:  s          r)   r*   workingcommitctx.__init__
  s     	T@r,   c           
        U(       a.  U R                    Vs/ s H  oUU R                  ;  d  M  UPM     nnO/ n[        R                  " U R                  R
                   Vs/ s H  oQ" U5      (       d  M  UPM     snU R                  R                   Vs/ s H  oQ" U5      (       d  M  UPM     snU R                  R                   Vs/ s H  oQ" U5      (       d  M  UPM     sn/ / / U5      $ s  snf s  snf s  snf s  snf )zReturn matched files only in ``self._status``

Uncommitted files appear "clean" via this context, even if
they aren't actually so in the working directory.
)rM   _changedsetr   r   r  rt   ru   rv   )r'   r   rf   rb   re   r%  s         r)   r   workingcommitctx._dirstatestatus
  s      $L14;K;K2KQELEE~~--:-1qQ-:**7*1eAhQ*7,,9,1aQ,9
 	
 M ;79s.   C-C- C24C2C7
(C7
C<C<c                    [        U R                  R                  5      nUR                  U R                  R                  5        UR                  U R                  R
                  5        U$ )z/Return the set of files changed in this context)rg   r  rt   updateru   rv   )r'   changeds     r)   r  workingcommitctx._changedset
  sI     dll++,t||))*t||++,r,   rG   )r,   NNNr  rB  )r9   rG  rH  rI  rJ  r*   r  rM  r  rN  r  r  s   @r)   r  r  
  s;     DHA :?
	
,  r,   r  c                   ^ ^ 0 mUU 4S jnU$ )zCreate a filectxfn that caches based on the path.

We can't use util.cachefunc because it uses all arguments as the cache
key and this creates a cycle since the arguments include the repo and
memctx.
c                2   > UT;  a  T" XU5      TU'   TU   $ r#   rG   )r(   r  r   r  rc  s      r)   
getfilectx(makecachingfilectxfn.<locals>.getfilectx
  s%    utT2E$KT{r,   rG   )rc  r  r  s   ` @r)   makecachingfilectxfnr  
  s     E
 r,   c                   ^  U 4S jnU$ )zGiven a context return a memfilectx for ctx[path]

This is a convenience method for building a memctx based on another
context.
c           
        > TU   nUR                  5       n[        U UUUR                  5       UR                  5       UR	                  5       US9$ N)rr  rl  rZ  )rZ  r  r_  rr  rl  )r(   r  r   r~  rZ  r  s        r)   r  "memfilefromctx.<locals>.getfilectx
  sL    4y__&
IIK;;=;;=!
 	
r,   rG   )r  r  s   ` r)   memfilefromctxr  
  s    
 r,   c                   ^  U 4S jnU$ )zGiven a patch (e.g. patchstore object) return a memfilectx

This is a convenience method for building a memctx based on a patchstore.
c           
     Z   > TR                  U5      u  p4nUc  g Uu  pg[        U UUUUUUS9$ r  )r  r  )	r(   r  r   r_  r  rZ  rr  rl  
patchstores	           r)   r  $memfilefrompatch.<locals>.getfilectx
  sI    !+!3!3D!9J<!
 	
r,   rG   )r  r  s   ` r)   memfilefrompatchr  
  s    
 r,   c                  x   ^  \ rS rSrSrSr     SU 4S jjrSS jrS r\	S 5       r
\	SS j5       rS	 rS
rU =r$ )r  i  a  Use memctx to perform in-memory commits via localrepo.commitctx().

Revision information is supplied at initialization time while
related files data and is made available through a callback
mechanism.  'repo' is the current localrepo, 'parents' is a
sequence of two parent revisions identifiers (pass None for every
missing parent), 'text' is the commit message and 'files' lists
names of files touched by the revision (normalized and relative to
repository root).

filectxfn(repo, memctx, path) is a callable receiving the
repository, the current memctx object and the normalized path of
requested file, relative to repository root. It is fired by the
commit function for every file in 'files', but calls order is
undefined. If the file is available in the revision being
committed (updated or added), filectxfn returns a memfilectx
object. If the file was removed, filectxfn return None for recent
Mercurial. Moved files are represented by marking the source file
removed and the new file added with copy information (see
memfilectx).

user receives the committer name and defaults to current
repository username, date is the commit date in any format
supported by dateutil.parsedate() and defaults to current date, extra
is a dictionary of metadata or is left empty.
Tc           	       > [         TU ]  XXgXS9  S U l        S U l        U Vs/ s H+  o=(       d     U R                  R
                  R                  PM-     nnUu  pX4 Vs/ s H  oR                  U   PM     snU l        [        [        U5      5      nX@l
        0 U l        [        U[        R                  5      (       a  [        U5      nO[!        U5      (       d  [#        U5      n[%        U5      U l        U
(       a?  U
" U R                  U / 5      U l        U R                  R+                  U R(                  5        g g s  snf s  snf )NrF  )rQ  r*   r@   r   r%   rk   r  r   r  rg   _filesr   r(  r   	filestorer  callabler  r  
_filectxfnr  savecommitmessage)r'   r(   r   r  r   	filectxfnrr  rs  ru  r>  r  r  r   r   r:  s                 r)   r*   memctx.__init__1  s	    	TF	
CJK7a8118887K1391A9s5z"i11(3I)$$&y1I /y9

D"5DJJJ((4 ! L9s   2D> Ec                :    U R                  U R                  X5      $ )zhget a file context from the working directory

Returns None if file doesn't exist and should be removed.)r  r%   rw  s      r)   rS   memctx.filectxU  s     tzz466r,   c                8    U R                   R                  U 5      $ zcommit context to the repor%   	commitctxr/   s    r)   commitmemctx.commit[      zz##D))r,   c                   U R                   S   nUR                  5       R                  5       nU R                  R                   H%  nU R
                  R                  R                  X#'   M'     U R                  R                   H%  nU R
                  R                  R                  X#'   M'     U R                  R                   H  nX2;   d  M
  X#	 M     U$ )z;generate a manifest based on the return values of filectxfnr   )r   r[   r  r  rt   r%   rk   r  ru   r  rv   )r'   r   rb  r%  s       r)   rM   memctx._manifest_  s    
 }}Qmmo""$&&AZZ--<<CF ' ##AZZ--99CF $ %%AxF & 
r,   c           	       ^^ U R                  5       R                  5       mU R                  S   nUR                  5       [        :w  a  UR                  5       mUU4S jnOU4S jn/ / / pTnU R
                   HP  nU" U5      (       d  UR                  U5        M#  X   (       a  UR                  U5        M?  UR                  U5        MR     [        R                  " X4U/ / / / 5      $ )z?Calculate exact status from ``files`` specified at constructionr   c                &   > U T;   =(       d    U T;   $ r#   rG   r%  man1man2s    r)   r   memctx._status.<locals>.<lambda>}      d!7a4i!7r,   c                   > U T;   $ r#   rG   r%  r1  s    r)   r  r3    	    dr,   	r   r[   r   rc   r   r  rj   r   r   	r'   r   managingrt   ru   rv   r%  r1  r2  s	          @@r)   r  memctx._statuss  s     wwy!!#]]1 668w;;=D7H*H#%r2AA;;Q"q!  ~~hwBBGGr,   c                    U R                   S   R                  5       [        :X  a  U R                   S   /$ U R                   $ )Nr   r   )r   rc   r   r/   s    r)   r   memctx.parents  s8    ==!W,MM!$%%}}r,   )r  r  r   r   r@   r  r   )NNNNNr#   rB  )r9   rG  rH  rI  rJ  _returnnoneformissingfilesr*   rS   r)  rM  rM   r  r   rN  r  r  s   @r)   r  r    se    < "& "5H7*  & H H0 r,   r  c                  X   ^  \ rS rSrSr   S
U 4S jjrS rS rS rSS jr	S r
S	rU =r$ )r  i  zhmemfilectx represents an in-memory file to commit.

See memctx and committablefilectx for more details.
c                   > [         TU ]  XSU5        X@l        U(       a  SU l        OU(       a  SU l        OSU l        Xpl        g)a!  
path is the normalized file path relative to repository root.
data is the file content as a string.
islink is True if the file is a symbolic link.
isexec is True if the file is executable.
copied is the source file path if current file was copied in the
revision being committed, or None.Nrq  rj  r,   )rQ  r*   _datar(  _copysource)	r'   r(   r)  r   r_  rr  rl  rZ  r:  s	           r)   r*   memfilectx.__init__  s<    " 	T95
DKDKDK%r,   c                    U R                   $ r#   )rB  r/   s    r)   rZ  memfilectx.copysource  s    r,   c                D    U R                  5       UR                  5       :g  $ r#   r  r}  s     r)   rm   memfilectx.cmp  r  r,   c                    U R                   $ r#   rA  r/   s    r)   r_  memfilectx.data  r   r,   c                2    U R                   U R                  	 g)r6  N)r  r  r  s     r)   r;  memfilectx.remove  s     OODJJ'r,   c                    Xl         g)r>  NrI  r'   r_  r   rB  s       r)   r  memfilectx.write  s    
r,   )rB  rA  r(  )FFNrF  )r9   rG  rH  rI  rJ  r*   rZ  rm   r_  r;  r  rN  r  r  s   @r)   r  r    s6     &6 *(
 r,   r  c                     ^  \ rS rSrSr      SU 4S jjrS r\S 5       rSS jr	S r
\S 5       r\SS	 j5       rS
rU =r$ )metadataonlyctxi  a  Like memctx but it's reusing the manifest of different commit.
Intended to be used by lightweight operations that are creating
metadata-only changes.

Revision information is supplied at initialization time.  'repo' is the
current localrepo, 'ctx' is original revision which manifest we're reuisng
'parents' is a sequence of two parent revisions identifiers (pass None for
every missing parent), 'text' is the commit.

user receives the committer name and defaults to current repository
username, date is the commit date in any format supported by
dateutil.parsedate() and defaults to current date, extra is a dictionary of
metadata or is left empty.
c	                  > Uc  UR                  5       n[        TU ]	  XXVU5        S U l        S U l        X l        UR                  5       U l        Uc  UR                  5       nOU V	s/ s H  oc  M  X   PM     nn	US S  n[        U5      S:  a)  UR                  U[           5        [        U5      S:  a  M)  U=u  pU l        U R                  5       R                  u  pXR                  R                  R                   :w  a  U
R                  5       U:w  a  [#        S5      eXR                  R                  R                   :w  a  UR                  5       U:w  a  [#        S5      eUR%                  5       U l        0 U l        U(       a?  U" U R                  U / 5      U l        U R                  R-                  U R*                  5        g g s  sn	f )Nr   z=can't reuse the manifest: its p1 doesn't match the new ctx p1z=can't reuse the manifest: its p2 doesn't match the new ctx p2)rt  rQ  r*   r@   r   _originalctxrz  _manifestnoder   r   rj   r   r   r   r%   rk   r  RuntimeErrorr   r  r   r  r   )r'   r(   originalctxr   r  rr  rs  ru  r  r  r   r   mp1mp2r:  s                 r)   r*   metadataonlyctx.__init__  s    <**,DT7	
'(557?!))+G(/A1wtwGA!*'lQNN4=) 'lQ!(( ##%--))000R__5F#5M0  ))000R__5F#5M7 
 "'')

D"5DJJJ((4 / Bs   'G1Gc                    U R                   $ r#   )rT  r/   s    r)   rz  metadataonlyctx.manifestnode  s    !!!r,   c                H    U R                   R                  U R                     $ r#   )r%   r   rT  r/   s    r)   r   metadataonlyctx._manifestctx	  s    zz%%d&8&899r,   c                4    U R                   R                  XS9$ )N)r  )rS  rS   rw  s      r)   rS   metadataonlyctx.filectx  s      (((??r,   c                8    U R                   R                  U 5      $ r&  r'  r/   s    r)   r)  metadataonlyctx.commit  r+  r,   c                6    U R                   R                  5       $ r#   )rS  r[   r/   s    r)   rM   metadataonlyctx._manifest  s      ))++r,   c           	       ^^ U R                  5       R                  5       mU R                  S   nUR                  5       [        :w  a  UR                  5       mUU4S jnOU4S jn/ / / pTnU R
                   HL  nU" U5      (       d  UR                  U5        M#  X`;   a  UR                  U5        M;  UR                  U5        MN     [        R                  " X4U/ / / / 5      $ )zZCalculate exact status from ``files`` specified in the ``origctx``
and parents manifests.
r   c                &   > U T;   =(       d    U T;   $ r#   rG   r0  s    r)   r  )metadataonlyctx._status.<locals>.<lambda>$  r4  r,   c                   > U T;   $ r#   rG   r6  s    r)   r  rf  &  r7  r,   r8  r9  s	          @@r)   r  metadataonlyctx._status  s    
 wwy!!#]]1 668w;;=D7H*H#%r2AA;;Q"q!  ~~hwBBGGr,   )r  rT  r   rS  r   r@   r  r   r  r#   rB  )r9   rG  rH  rI  rJ  r*   rz  r  r   rS   r)  rM   rM  r  rN  r  r  s   @r)   rQ  rQ    sp    & .5`" : :@* , , H Hr,   rQ  c                  L    \ rS rSrSrSS jrS rS rS rS r	S	 r
S
 rS rSrg)arbitraryfilectxi4  z|Allows you to use filectx-like functions on a file in an arbitrary
location on disk, possibly not in the working directory.
Nc                    X l         Xl        g r#   )r%   r  )r'   r   r(   s      r)   r*   arbitraryfilectx.__init__9  s    

r,   c                   SU R                  5       ;   =(       d    SUR                  5       ;   nU(       dw  [        U[        5      (       ab  U R                  (       aQ  [        R
                  " U R                  5       U R                  R                  UR                  5       5      5      (       + $ U R                  5       UR                  5       :g  $ rp  )	r   r(  rv  r%   filecmprm   r   wjoinr_  )r'   r~  symlinkss      r)   rm   arbitraryfilectx.cmp>  s     4::<'?44::<+?Jt^<< {{499;

0@0@0MNNNyy{diik))r,   c                    U R                   $ r#   r  r/   s    r)   r   arbitraryfilectx.pathI  r   r,   c                    grf  rG   r/   s    r)   r   arbitraryfilectx.flagsL  s    r,   c                B    [         R                  " U R                  5      $ r#   r   readfiler  r/   s    r)   r_  arbitraryfilectx.dataO      }}TZZ((r,   c                B    [         R                  " U R                  5      $ r#   rw  r/   s    r)   r  arbitraryfilectx.decodeddataR  rz  r,   c                D    [         R                  " U R                  5        g r#   )r   rM  r  r/   s    r)   r;  arbitraryfilectx.removeU  s    DJJr,   c                X    U(       a   e[         R                  " U R                  U5        g r#   )r   	writefiler  rN  s       r)   r  arbitraryfilectx.writeX  s    ytzz4(r,   )r  r%   r#   )r9   rG  rH  rI  rJ  r*   rm   r   r   r_  r  r;  r  rN  rG   r,   r)   rj  rj  4  s/    
	*)) )r,   rj  )<
__future__r   rn  r  r  i18nr   r.   r   r   r    r	   r
   r   r   r   r  r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   
interfacesr   istatusutilsr   r   dirstateutilsr   rM  r    r)  r  rS   r  rD  r  rv  rU  r  r  r  r  r  r  r  rQ  rj  rG   r,   r)   <module>r     s9   #  	   
    ( ""}
 }
@l  l ^	I? I?X{
k {
|eW ePP9 P9f= =@Y3' Y3xc  c L5. 5p)z )X".0^ D1# 1hkHn kH\&) &)r,   