
    	^c                    p   d dl Z d dlZd dlZddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddl m!Z!m"Z" ddl#m$Z$ ej%        Z% G d	 d
          Z& G d de&          Z' G d d          Z( G d de(          Z) G d de&          Z* G d de*          Z+ G d de(          Z, G d de,          Z- G d de*          Z. G d de,          Z/ G d de+          Z0d Z1d  Z2d! Z3 G d" d#e*          Z4 G d$ d%e,          Z5 G d& d'e*          Z6 G d( d)          Z7dS )*    N   )_)hexnullrevshort)getattr)dagopencodingerrorfilesetmatch
mergestatemetadataobsoletepatchpathutilphasesrepoviewscmutilsparsesubreposubrepoutilutil)dateutil
stringutil)	timestampc                      e Zd ZdZd Zd Z ej        e          Zd Z	d Z
d Zd Zd Zd	 Zd
 Zd Zd Zed             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd6dZd Zd Zd Z d Z!d Z"d Z#d Z$d  Z%d! Z&d" Z'd# Z(d$ Z)d% Z*ed&             Z+d' Z,d( Z-d7d*Z.d+ Z/d, Z0	 	 	 	 	 	 	 d8d/Z1	 	 	 	 	 	 	 	 	 d9d0Z2d1 Z3d2 Z4	 	 	 	 	 	 d:d3Z5d;d4Z6d5 Z7dS )<basectxaI  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                     || _         d S N_reposelfrepos     3/usr/lib/python3/dist-packages/mercurial/context.py__init__zbasectx.__init__<   s    


    c                 D    t          |                                           S r    )r   noder$   s    r&   	__bytes__zbasectx.__bytes__?   s    TYY[[!!!r(   c                 R    dt          |           j        dt          |           dS N< >type__name__strr+   s    r&   __repr__zbasectx.__repr__D   (      JJ///T;;r(   c                     	 t          |           t          |          k    o| j        |j        k    S # t          $ r Y dS w xY wNF)r3   _revAttributeErrorr$   others     r&   __eq__zbasectx.__eq__G   sN    	::e,Hej1HH 	 	 	55	s   /2 
A A c                     | |k     S r     r<   s     r&   __ne__zbasectx.__ne__M       EM""r(   c                     || j         v S r    	_manifestr$   keys     r&   __contains__zbasectx.__contains__P   s    dn$$r(   c                 ,    |                      |          S r    )filectxrF   s     r&   __getitem__zbasectx.__getitem__S   s    ||C   r(   c                 *    t          | j                  S r    )iterrE   r+   s    r&   __iter__zbasectx.__iter__V   s    DN###r(   c                 *    |                                  S )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$   statuss     r&   _buildstatusmanifestzbasectx._buildstatusmanifestY   s     }}r(   c                     |S )zfThis internal method provides a way for child objects to override the
        match operator.
        r@   )r$   r=   r   s      r&   _matchstatuszbasectx._matchstatus_   s	     r(   c           	      (   d}|                                  ?|                                  |                                 k     r|                     |          }|                    |          ||                     |          }g g }	}g }
g }|j        |j        |j        }}}t          |                              ||          }|                                D ]\  }}|v r
||                    |           "|\  \  }}\  }}||	                    |           E||
                    |           ]||k    r|                    |           y|| j	        j
        j        vr|                    |           | |                             ||                   r|                    |           |                    |           |
r,fd|D             }fd|D             }fd|
D             }
t          j        ||	|
||||          S )z.build a status with respect to another contextN)r   cleanc                 6    g | ]}|vr |          |S r@   r@   .0fnr   mf1s     r&   
<listcomp>z(basectx._buildstatus.<locals>.<listcomp>   :       S==%=5599=  ==r(   c                 6    g | ]}|vr |          |S r@   r@   rX   s     r&   r\   z(basectx._buildstatus.<locals>.<listcomp>   r]   r(   c                     g | ]}|v|	S r@   r@   )rY   rZ   
deletedsets     r&   r\   z(basectx._buildstatus.<locals>.<listcomp>   s#    DDDbr/C/Cr/C/C/Cr(   )revrR   deletedunknownignoredsetdiffitemsappendr"   nodeconstantswdirfilenodeidscmpr   rQ   )r$   r=   sr   listignored	listcleanlistunknownmf2modifiedaddedremovedrV   rb   rc   rd   drZ   valuenode1flag1node2flag2r`   r[   s      `                  @@r&   _buildstatuszbasectx._buildstatuse   ss    88::!dhhjj599;;&>&>++A..C((++;++A..Cb%$%Iqy!)'\\
HHSYH77 	! 	!IBZ}R   -2*NUENUE}R    r""""%####dj6FFF
 ####beBi(( !####R     	E    !  G
    !  G EDDDGDDDG~eWgw
 
 	
r(   c                 @    t          j        | | j        j                  S r    )r   stater"   uir+   s    r&   substatezbasectx.substate   s     tz}555r(   c                 (    | j         |         d         S Nr   )r~   r$   subpaths     r&   subrevzbasectx.subrev   s    }W%a((r(   c                     | j         S r    )r:   r+   s    r&   ra   zbasectx.rev   s
    yr(   c                     | j         S r    )_noder+   s    r&   r*   zbasectx.node   
    zr(   c                 D    t          |                                           S r    )r   r*   r+   s    r&   r   zbasectx.hex       499;;r(   c                     | j         S r    rD   r+   s    r&   rP   zbasectx.manifest   
    ~r(   c                     | j         S r    )_manifestctxr+   s    r&   manifestctxzbasectx.manifestctx   s      r(   c                     | j         S r    r!   r+   s    r&   r%   zbasectx.repo   r   r(   c                 J    t           j        |                                          S r    )r   
phasenamesphaser+   s    r&   phasestrzbasectx.phasestr   s     ..r(   c                 F    |                                  t          j        k    S r    )r   r   publicr+   s    r&   mutablezbasectx.mutable   s    zz||fm++r(   Nc                 2    t          j        | |||          S )N)badfn)r   r   )r$   cwdexprr   s       r&   matchfilesetzbasectx.matchfileset   s    }T3E::::r(   c                 ^    |                                  t          j        | j        d          v S )z!True if the changeset is obsoletes   obsoletera   obsmodgetrevsr"   r+   s    r&   r   zbasectx.obsolete   s#    xxzzV^DJDDDDr(   c                 ^    |                                  t          j        | j        d          v S )z True if the changeset is extincts   extinctr   r+   s    r&   extinctzbasectx.extinct   s#    xxzzV^DJ
CCCCr(   c                 ^    |                                  t          j        | j        d          v S )z:True if the changeset is not obsolete, but its ancestor is   orphanr   r+   s    r&   orphanzbasectx.orphan   s#    xxzzV^DJ	BBBBr(   c                 ^    |                                  t          j        | j        d          v S )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&   phasedivergentzbasectx.phasedivergent   s&    
 xxzzV^DJ8IJJJJr(   c                 ^    |                                  t          j        | j        d          v S )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&   contentdivergentzbasectx.contentdivergent   s&    
 xxzzV^DJ8KLLLLr(   c                 z    |                                  p'|                                 p|                                 S )zTTrue if the changeset is either orphan, phase-divergent or
        content-divergent)r   r   r   r+   s    r&   
isunstablezbasectx.isunstable   s4     {{}}P 3 3 5 5P9N9N9P9PPr(   c                     g }|                                  r|                    d           |                                 r|                    d           |                                 r|                    d           |S )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   rh   r   r   )r$   instabilitiess     r&   r   zbasectx.instabilities   s     ;;== 	,  +++   	5  !3444  "" 	7  !5666r(   c                     | j         S )z)return contexts for each parent changeset_parentsr+   s    r&   parentszbasectx.parents   s
    }r(   c                     | j         d         S Nr   r   r+   s    r&   p1z
basectx.p1   s    }Qr(   c                 j    | j         }t          |          dk    r|d         S | j        t                   S )N   r   )r   lenr"   r   )r$   r   s     r&   p2z
basectx.p2   s1    -w<<11:z'""r(   c                 <   d| j         v rS	 | j                            |          S # t          $ r+ t	          j        | j        pd|t          d                    w xY wd| j         v s||                                 v r0|| j	        v r'| j	        |         | j	        
                    |          fS | j        j        }	 || j        j                                     |          \  }}n8# t          $ r+ t	          j        | j        pd|t          d                    w xY w||fS )NrE   s   Nones   not found in manifest_manifestdelta)__dict__rE   findKeyErrorr   ManifestLookupErrorr   r   filesr   flagsr"   manifestlog
_changesetrP   )r$   pathmflr*   flags        r&   	_fileinfozbasectx._fileinfo  sP   $-''~**4000   /J)'43K1L1L   t},,

0D0Dt***'-'--d33  j$	T_56;;DAAJD$$ 	 	 	+
%gtQ/G-H-H  	
 Tzs   % 5A9(C" "5Dc                 8    |                      |          d         S r   )r   r$   r   s     r&   filenodezbasectx.filenode  s    ~~d##A&&r(   c                 f    	 |                      |          d         S # t          j        $ r Y dS w xY w)Nr   r(   )r   r   LookupErrorr   s     r&   r   zbasectx.flags!  sC    	>>$''**  	 	 	33	s    00c                 *    t          j        |           S r    )r   computechangesetcopiesr+   s    r&   _copieszbasectx._copies'  s    .t444r(   c                     | j         d         S r   r   r+   s    r&   p1copieszbasectx.p1copies+      |Ar(   c                     | j         d         S r   r   r+   s    r&   p2copieszbasectx.p2copies.  r   r(   Tc                 0    t          j         | ||          S )z>return a subrepo for the stored revision of path, never wdir())allowcreater   )r$   r   r   s      r&   subzbasectx.sub1  s    tT{CCCCr(   c                 .    t          j        | ||          S r    )r   nullsubrepo)r$   r   pctxs      r&   nullsubzbasectx.nullsub5  s    "4t444r(   c                 0    t          j         | |d          S )z]return a subrepo for the stored revision, or wdir if this is a wdir
        context.
        T)	allowwdirr   r   s     r&   
workingsubzbasectx.workingsub8  s     tTT::::r(      globFc                     | j         }|s|                                }t          j        |j        ||||||j        | ||
  
        S )N)auditorctxlistsubreposr   )r"   getcwdmatchmodr   rootnofsauditor)	r$   patsincludeexcludedefaultr   r   r   rs	            r&   r   zbasectx.match>  s[     J 	((**C~FM%
 
 
 	
r(   c
                     ||                                  }|| j        |         }t          j        | j        || ||||||||	          S )z;Returns a diff generator for the given contexts and matcherN)r   changesopts
losedatafnpathfncopycopysourcematchhunksfilterfn)r   r"   r   rf   )
r$   ctx2r   r   r   r   r   r   r   r   s
             r&   rf   zbasectx.diffX  sd     <7799D:d#DzJ!+'
 
 
 	
r(   c                 4    | j                                         S r    )rE   dirsr+   s    r&   r   zbasectx.dirsw  s    ~""$$$r(   c                 6    | j                             |          S r    )rE   hasdir)r$   dirs     r&   r   zbasectx.hasdirz  s    ~$$S)))r(   c           	         | }| j         |         }d}	t          |t                    st          |t                    rd}	||}}| j                             |          }|                    ||          }t          j        g g g g g g g           }
|                    ||
||||          }
|	r.t          j        |
j        |
j	        |
j
        g g g |
j                  }
|rt          j        ||          D ]\  }	 |                              }n# t          $ r d}Y nw xY wt          j        |          }|                    |||||d          }dD ]C}t#          |
|          t#          ||          }}|                    fd|D                        D|
j                                         |
j
                                         |
j	                                         |
j                                         |
j                                         |
j                                         |
j                                         |
S )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   rd   rV   rc   r   )rq   rr   rs   rb   rc   rd   rV   c              3   &   K   | ]}d |fz  V  dS )s   %s/%sNr@   )rY   fr   s     r&   	<genexpr>z!basectx.status.<locals>.<genexpr>  s,      !J!Ja(gq\"9!J!J!J!J!J!Jr(   )r"   
isinstance	changectxnarrowmatchrT   r   rQ   rz   rq   rs   rr   rV   itersubreposr   r   r   subdirmatcherr   extendsortrb   rc   rd   )r$   r=   r   rm   rn   ro   r   ctx1r   reversedr   r   rev2submatchrl   krfilessfilesr   s                     @r&   rQ   zbasectx.status}  so   6 z%  $	** 	$z$	/J/J 	$Ht$D
&&u--!!$..N2r2r2r266!UKK
 
  	 
AIqwBAG A  	K ' 4T4 @ @ K K ;;w//DD        DDD	 
 $1'5AAJJ"'#'!%    
K 
KA &-Q]]GAqMMFFMM!J!J!J!J6!J!J!JJJJJ
K 	

										s   4D

DDc                 0    t          d| j        z            )z)Get a mergestate object for this context.z"%s does not implement mergestate())NotImplementedError	__class__r$   rV   s     r&   r   zbasectx.mergestate  s    !04>A
 
 	
r(   c                    t          |                                           dk    pc|                                 |                                                                 k    p'|                                 p|                                  S r   )r   r   branchr   closesbranchr   r+   s    r&   isemptyzbasectx.isempty  ss    !# {{}}		 0 0 2 22  "" zz||	
 	
r(   r    TNNNr   FNN)	NNNNNNNNN)NNFFFFF)8r4   
__module____qualname____doc__r'   r,   r
   	strmethod__str__r6   r>   rA   rH   rK   rN   rR   rT   rz   propertycacher~   r   ra   r*   r   rP   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   rf   r   r   rQ   r   r  r@   r(   r&   r   r   4   s          " " " !h ++G< < <  # # #% % %! ! !$ $ $    @
 @
 @
D 6 6 ]6) ) )           ! ! !  / / /, , ,; ; ; ;E E ED D DC C CK K KM M MQ Q Q
  "       # # #  0' ' '   5 5 ]5    D D D D5 5 5; ; ; 
 
 
 
8 
 
 
 
>% % %* * *
 c c c cJ
 
 
 

 
 
 
 
r(   r   c                   \    e Zd ZdZd( fd	Zd Zd ZeZed             Z	ed             Z
ed             Zed	             Zed
             Zd Zd Zd Zd Zd Zd Zd Zd Ze fd            Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d  Z$d)d"Z%d*d$Z&d% Z'd& Z(d' Z) xZ*S )+r   zA changecontext object makes access to data related to a particular
    changeset convenient. It represents a read-only context already present in
    the repo.Tc                     t          t          |                               |           || _        || _        || _        d S r    )superr   r'   r:   r   _maybe_filtered)r$   r%   ra   r*   maybe_filteredr  s        r&   r'   zchangectx.__init__  s?    i''---	
  .r(   c                 j    	 t          | j                  S # t          $ r t          |           cY S w xY wr    )hashr:   r;   idr+   s    r&   __hash__zchangectx.__hash__  s?    		??" 	 	 	d88OOO	s    22c                 "    | j         t          k    S r    )r:   r   r+   s    r&   __nonzero__zchangectx.__nonzero__  s    yG##r(   c                     | j         r| j        }n| j                                        }|j                            |                                           S r    )r!  r"   
unfiltered	changelogchangelogrevisionra   r#   s     r&   r   zchangectx._changeset  sG     	+:DD:((**D~//

;;;r(   c                 4    | j                                         S r    )r   readr+   s    r&   rE   zchangectx._manifest  s     %%'''r(   c                 :    | j         j        | j        j                 S r    )r"   r   r   rP   r+   s    r&   r   zchangectx._manifestctx  s    z%do&>??r(   c                 4    | j                                         S r    )r   	readdeltar+   s    r&   r   zchangectx._manifestdelta  s     **,,,r(   c                    | j         }| j        r|j        }n|                                j        }|                    | j                  \  }}|t          k    r't          |||                    |          d          gS t          |||                    |          d          t          |||                    |          d          gS )NFr"  )	r"   r!  r+  r*  
parentrevsr:   r   r   r*   )r$   r%   clr   r   s        r&   r   zchangectx._parents!  s    z 	-BB"",Bty))B==dBEJJJKKdBEBBBdBEBBB
 	
r(   c                 \    | j         }|j        |j        |j        |j        |j        |j        fS r    )r   rP   userdater   descriptionextrar$   cs     r&   	changesetzchangectx.changeset1  s1    OJFFGMG
 	
r(   c                     | j         j        S r    )r   rP   r+   s    r&   manifestnodezchangectx.manifestnode<  s    ''r(   c                     | j         j        S r    )r   r7  r+   s    r&   r7  zchangectx.user?      ##r(   c                     | j         j        S r    )r   r8  r+   s    r&   r8  zchangectx.dateB  rA  r(   c                     | j         j        S r    )r   r   r+   s    r&   r   zchangectx.filesE  s    $$r(   c                     t          |                                           }|                    |                                            |                    |                                            t          |          S r    )re   r   difference_update
filesaddedfilesremovedsorted)r$   rq   s     r&   filesmodifiedzchangectx.filesmodifiedH  sc    tzz||$$""4??#4#4555""4#4#4#6#6777hr(   c                     | j         j        }d}| j        j        dk    rd}n1| j        j                            dd          }|dk    rd}n|dk    rd }||rt          j        |           }ng }|S NTs   changeset-sidedataF   experimentals   copies.read-froms   changeset-onlys   compatibility)r   rF  r"   filecopiesmoder}   configr   computechangesetfilesadded)r$   rF  compute_on_nonesources       r&   rF  zchangectx.filesaddedN  s    _/
:$(===#OOZ]))/;NOOF***"'+++!
  %@FF


r(   c                     | j         j        }d}| j        j        dk    rd}n1| j        j                            dd          }|dk    rd}n|dk    rd }||rt          j        |           }ng }|S rK  )r   rG  r"   rM  r}   rN  r   computechangesetfilesremoved)r$   rG  rP  rQ  s       r&   rG  zchangectx.filesremoveda  s    3:$(===#OOZ]))/;NOOF***"'+++# "'DTJJ!r(   c                     | j         j        }| j         j        }d}| j        j        dk    rd}n3| j        j                            dd          }|dk    rd}n
|dk    rd x}}|$|rt          t          |           j	        \  }}n|i }|i }||fS rK  )
r   r   r   r"   rM  r}   rN  r   r   r   )r$   r   r   rP  rQ  r  s        r&   r   zchangectx._copiest  s    ?+?+:$(===#OOZ]))/;NOOF ***"'+++&**8 "%*9d%;%;%C"((#!HH!!r(   c                     | j         j        S r    )r   r9  r+   s    r&   r9  zchangectx.description  s    **r(   c                 d    t          j        | j        j                            d                    S N   branch)r
   tolocalr   r:  getr+   s    r&   r  zchangectx.branch  s&     5 9 9) D DEEEr(   c                     d| j         j        v S Ns   closer   r:  r+   s    r&   r  zchangectx.closesbranch  s    4?000r(   c                     | j         j        S )z#Return a dict of extra information.r]  r+   s    r&   r:  zchangectx.extra  s    $$r(   c                 @    | j                             | j                  S )zReturn a list of byte tag names)r"   nodetagsr   r+   s    r&   tagszchangectx.tags  s    z""4:...r(   c                 @    | j                             | j                  S )z%Return a list of byte bookmark names.)r"   nodebookmarksr   r+   s    r&   	bookmarkszchangectx.bookmarks  s    z''
333r(   c                     | j         }| j        r|j        }n|                                j        }|                    | j                  S r    )r"   r!  r+  r*  	fast_rankr:   )r$   r%   r5  s      r&   rf  zchangectx.fast_rank  sC    z 	-BB"",B||DI&&&r(   c                 V    | j         j                            | j         | j                  S r    )r"   _phasecacher   r:   r+   s    r&   r   zchangectx.phase  s!    z%++DJ	BBBr(   c                 D    | j         t          j        | j        d          v S )Ns   visible)r:   r   
filterrevsr"   r+   s    r&   hiddenzchangectx.hidden  s    yH/
JGGGGr(   c                     dS r9   r@   r+   s    r&   
isinmemoryzchangectx.isinmemory      ur(   c                 h      j         j                             j                  } fd|D             S )zreturn list of changectx contexts for each child changeset.

        This returns only the immediate child changesets. Use descendants() to
        recursively walk children.
        c                 *    g | ]}j         |         S r@   r!   rY   xr$   s     r&   r\   z&changectx.children.<locals>.<listcomp>  s    )))!
1)))r(   )r"   r+  childrenr   r;  s   ` r&   rs  zchangectx.children  s9     J ))$*55))))q))))r(   c              #   x   K   | j         j                            | j        g          D ]}| j         |         V  d S r    )r"   r+  	ancestorsr:   )r$   as     r&   ru  zchangectx.ancestors  sK      %//<< 	  	 A*Q-	  	 r(   c              #   x   K   | j         j                            | j        g          D ]}| j         |         V  dS )zrRecursively yield all children of the changeset.

        For just the immediate children, use children()
        N)r"   r+  descendantsr:   )r$   rt   s     r&   rx  zchangectx.descendants  sM      
 %1149+>> 	  	 A*Q-	  	 r(   Nc                 b    ||                      |          }t          | j        ||| |          S )z&get a file context from this changesetN)fileidr   filelog)r   rJ   r"   )r$   r   rz  r{  s       r&   rJ   zchangectx.filectx  s<    >]]4((FJVtW
 
 
 	
r(   Fc           	      F   |j         }||j        d         j         }| j        j                            | j         |          }|s| j        j        j        n?t          |          dk    r
|d         n"| j        j        	                    dd          D ]M}	 t          j        | j        |          }n# t          j        $ r Y /w xY w|                                |v r n&N| j        j                            | j         |          |r| j        j                            t#          d          t%                    t%          | j                   t%          |          fz  d                    fdt)          |          D                       z              | j                 S )	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.Nr   r   s   merges   preferancestors(   note: using %s as ancestor of %s and %s
r(   c              3   b   K   | ])}|k    t          d           t          |          z  V  *dS )s:         alternatively, use --config merge.preferancestor=%s
N)r   r   )rY   nancs     r&   r   z%changectx.ancestor.<locals>.<genexpr>  sX         88 9   ((	# $888 r(   )r   r   r"   r+  commonancestorsheadsri   nullidr   r}   
configlistr   	revsymbolr   RepoLookupErrorr*   ancestorrQ   r   r   joinrH  )r$   c2warnn2cahsr   r   r  s          @r&   r  zchangectx.ancestor  s    X:Q%Bz#88RHH 	**1CCYY!^^q'CC Z]--h8IJJ 	D 	D!+DJ::CC,   Hhhjj$;;E  j*33DJCC 
$$FGG ::uTZ'8'8%))DE hh     "(    	   z#s   B22CCc                 V    | j         j                            | j        |j                  S )z.True if this changeset is an ancestor of other)r"   r+  isancestorrevr:   r<   s     r&   isancestorofzchangectx.isancestorof  s!    z#11$)UZHHHr(   c                       fd}t          j         j                                      |          } j                            |          S )Generates matching file names.c                      t           fdj        D                       rd S                      t          d          z             d S )Nc              3   T   K   | ]"}|k    p                     |d z             V  #dS )   /N)
startswith)rY   rl   rZ   s     r&   r   z.changectx.walk.<locals>.bad.<locals>.<genexpr>  s<      MM!275bmmAH55MMMMMMr(   s   no such file in rev %s)anyr~   badr   )rZ   msgr   r$   s   ` r&   r  zchangectx.walk.<locals>.bad  sZ     MMMMt}MMMMM IIb!566=>>>>>r(   )r   badmatchr"   r  rE   walk)r$   r   r  ms   ``  r&   r  zchangectx.walk  s\    	? 	? 	? 	? 	? 	? dj44U;;SAA~""1%%%r(   c                 ,    |                      |          S r    )r  r$   r   s     r&   matcheszchangectx.matches  s    yyr(   r  NNr  )+r4   r  r  r  r'   r&  r(  __bool__r  r   rE   propertyr   r   r   r=  r?  r7  r8  r   rI  rF  rG  r   r9  r  r  r:  ra  rd  rf  r   rk  rm  rs  ru  rx  rJ   r  r  r  r  __classcell__r  s   @r&   r   r     s        
. 
. 
. 
. 
. 
.  $ $ $ H< < ]< ( ( ]( @ @ X@ - - ]- 
 
 ]
	
 	
 	
( ( ($ $ $$ $ $% % %       &  &  "  "  "  " ] "D+ + +F F F1 1 1% % %/ / /4 4 4' ' 'C C CH H H  * * *          
 
 
 
+ + + +ZI I I& & &             r(   r   c                      e Zd ZdZed             Zed             Zed             Zed             Zed             Z	d Z
e
Zd Z ej        e          Zd	 Zd
 Zd Zd Zd Zd Zed             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d  Z'd! Z(d" Z)d# Z*d$ Z+d% Z,d& Z-d' Z.d( Z/d) Z0d* Z1d+Z2d, Z3d:d.Z4d/ Z5d0 Z6d;d1Z7d2 Z8d3 Z9d4 Z:d5 Z;d6 Z<d<d7Z=d=d8Z>d9 Z?d-S )>basefilectxaP  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                 @    | j                             | j                  S r    )r"   file_pathr+   s    r&   _filelogzbasefilectx._filelog&  s    ztz***r(   c                     d| j         v r| j                                        S d| j         v r|                     | j                  S | j                            | j                  S )N
_changectx_descendantrev)r   r  ra   _adjustlinkrevr  r  linkrev_filerevr+   s    r&   	_changeidzbasefilectx._changeid*  sa    4=((?&&(((.. &&t':;;;=((777r(   c                     d| j         v r| j                            | j                  S | j                            | j                  S )N_fileid)r   r  lookupr  r  r   r  r+   s    r&   	_filenodezbasefilectx._filenode5  s?    %%=''555?++DJ777r(   c                 @    | j                             | j                  S r    )r  ra   r  r+   s    r&   r  zbasefilectx._filerev<  s    }  000r(   c                     | j         S r    r  r+   s    r&   	_repopathzbasefilectx._repopath@  s
    zr(   c                 B    	 | j          dS # t          j        $ r Y dS w xY wNTF)r  r   r   r+   s    r&   r(  zbasefilectx.__nonzero__D  s8    	NN4  	 	 	55	s    c                     	 d|                                  | j        fz  S # t          j        $ r d|                                  z  cY S w xY w)Ns   %s@%ss   %s@???)r   r  r   r   r+   s    r&   r,   zbasefilectx.__bytes__N  sX    	+tyy{{DO<<<  	+ 	+ 	+tyy{{****	+s     &A	A	c                 R    dt          |           j        dt          |           dS r.   r2   r+   s    r&   r6   zbasefilectx.__repr__V  r7   r(   c                 x    	 t          | j        | j        f          S # t          $ r t	          |           cY S w xY wr    )r$  r  r  r;   r%  r+   s    r&   r&  zbasefilectx.__hash__Y  sH    	T^4555 	 	 	d88OOO	s    99c                     	 t          |           t          |          k    o| j        |j        k    o| j        |j        k    S # t          $ r Y dS w xY wr9   )r3   r  r  r;   r<   s     r&   r>   zbasefilectx.__eq___  sf    	T

d5kk) 6J%+-6Neo5
  	 	 	55	s   ?A 
AAc                     | |k     S r    r@   r<   s     r&   rA   zbasefilectx.__ne__i  rB   r(   c                     | j         S r    )r  r+   s    r&   filerevzbasefilectx.filerevl  
    }r(   c                     | j         S r    )r  r+   s    r&   r   zbasefilectx.filenodeo  r   r(   c                 @    | j                             | j                  S r    )r  r   r  r+   s    r&   _flagszbasefilectx._flagsr  s    $$TZ000r(   c                     | j         S r    )r  r+   s    r&   r   zbasefilectx.flagsv  
    {r(   c                     | j         S r    )r  r+   s    r&   r{  zbasefilectx.filelogy  r  r(   c                     | j         S r    )r  r+   s    r&   ra   zbasefilectx.rev|  r   r(   c                 @    | j                             | j                  S r    )r  r  r  r+   s    r&   r  zbasefilectx.linkrev  s    }$$T]333r(   c                 4    | j                                         S r    )r  r*   r+   s    r&   r*   zbasefilectx.node      ##%%%r(   c                 4    | j                                         S r    )r  r   r+   s    r&   r   zbasefilectx.hex  s    ""$$$r(   c                 4    | j                                         S r    )r  r7  r+   s    r&   r7  zbasefilectx.user  r  r(   c                 4    | j                                         S r    )r  r8  r+   s    r&   r8  zbasefilectx.date  r  r(   c                 4    | j                                         S r    )r  r   r+   s    r&   r   zbasefilectx.files      $$&&&r(   c                 4    | j                                         S r    )r  r9  r+   s    r&   r9  zbasefilectx.description  s    **,,,r(   c                 4    | j                                         S r    )r  r  r+   s    r&   r  zbasefilectx.branch  s    %%'''r(   c                 4    | j                                         S r    )r  r:  r+   s    r&   r:  zbasefilectx.extra  r  r(   c                 4    | j                                         S r    )r  r   r+   s    r&   r   zbasefilectx.phase  r  r(   c                 4    | j                                         S r    )r  r   r+   s    r&   r   zbasefilectx.phasestr      '')))r(   c                 4    | j                                         S r    )r  r   r+   s    r&   r   zbasefilectx.obsolete  r  r(   c                 4    | j                                         S r    )r  r   r+   s    r&   r   zbasefilectx.instabilities  s    ,,...r(   c                 4    | j                                         S r    )r  rP   r+   s    r&   rP   zbasefilectx.manifest  r  r(   c                     | j         S r    )r  r+   s    r&   r   zbasefilectx.changectx  s
    r(   c                     | j         S r    _copiedr+   s    r&   renamedzbasefilectx.renamed  
    |r(   c                 *    | j         o| j         d         S r   r  r+   s    r&   
copysourcezbasefilectx.copysource  s    |/Q/r(   c                     | j         S r    r!   r+   s    r&   r%   zbasefilectx.repo  r   r(   c                 D    t          |                                           S r    )r   datar+   s    r&   sizezbasefilectx.size  r   r(   c                     | j         S r    r  r+   s    r&   r   zbasefilectx.path  r   r(   c                 r    	 t          j        |                                           S # t          $ r Y dS w xY wr9   )r   binaryr  IOErrorr+   s    r&   isbinaryzbasefilectx.isbinary  sB    	$TYY[[111 	 	 	55	s   %( 
66c                 .    d|                                  v S )N   xr   r+   s    r&   isexeczbasefilectx.isexec      tzz||##r(   c                 .    d|                                  v S N   lr  r+   s    r&   islinkzbasefilectx.islink  r  r(   c                     dS )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.Fr@   r+   s    r&   isabsentzbasefilectx.isabsent  s	    
 ur(   Fc                    |j         r|                    |           S | j        t          j        d          |j        | j        j        r2| j                            | j        |                                          S | 	                                dz
  |	                                k    r2| j                            | j        |                                          S | 	                                |	                                k    s| 
                                dk    r2| j                            | j        |                                          S dS )Vcompare with other file context

        returns True if different than fctx.
        Ns;   filectx.cmp() must be reimplemented if not backed by revlog   r  T)
_customcmprk   r  r   ProgrammingErrorr"   _encodefilterpatsr  r  r  r   r$   fctxs     r&   rk   zbasefilectx.cmp  s   
 ? 	"88D>>!>!(N   >!z+ F}((EEE yy{{Q$))++-- }((EEE99;;$))++%%)=)= =$$T^TYY[[AAA tr(   Nc                 x   | j         }|                                j        }|j        }|                                 }||k    r|S t          | dd          }d}	|,d | j         d                                         D             }
d}n|g}
||                    |
||          x}}	||vr|	|                    |
||          }	| j        }| j	        }|	D ]g}|	||k     r dS |
                    |          }||d         v r;|||d                                                                      |          k    r|c S h|S )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.
        _ancestrycontextNc                 6    g | ]}|                                 S r@   ra   rY   ps     r&   r\   z.basefilectx._adjustlinkrev.<locals>.<listcomp>  s     @@@AEEGG@@@r(   T	inclusive   r   )r"   r*  r+  r   r  r   r   ru  r  r  r.  readfastrZ  )r$   srcrevr  stoprevr%   r5  r   lkr	memberanciterancrevsfnoder   rv  acs                  r&   r  zbasefilectx._adjustlinkrev  sg    z__(llnnS==JD"4d;;	>@@TZ%5%=%=%?%?@@@DII8D"$,,tSI,"N"NNIi,,tSI,FFNE:D ! !&1w;;44WWQZZ2a5== BqE
 3 3 5 5 9 9$ ? ??? 
 
r(   c                 v    |                                  |k    rdS |                     |          }|dS ||k    S )zBTrue if a filectx has been introduced after a given floor revisionTr  NF)r  	_introrev)r$   changelogrevintrorevs      r&   isintroducedafterzbasefilectx.isintroducedafter.  sC    <<>>\))4>>,>775<''r(   c                 *    |                                  S )a  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  zbasefilectx.introrev7  s     ~~r(   c                 (   d}t          |           }d|v r| j        }nd|v r| j                                        }||                     |d|          S d|v r'|                     | j        |          }||| _        |S |                                 S )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  ra   r  r  r  )r$   r  toprevattrsr  s        r&   r  zbasefilectx._introrevB  s     T

%^FFU""_((**F&&vw&OOO&&**4+>*PPH#!)O<<>>!r(   c                     |                                  }|                                 |k    r| S |                     |                                 |          S )zzReturn filectx having identical contents, but pointing to the
        changeset revision where this filectx was introduced)changeid)r  ra   rJ   r   )r$   r  s     r&   introfilectxzbasefilectx.introfilectx_  sG     ==??88::!!K||DMMOOh|???r(   c                 @   t          | j        |||          }dt          |           v sdt          |           v r0|                                 |_        t          | dd          |_        n3dt          |           v r"| j        |_        t          | dd          |_        |S )z@create parent filectx keeping ancestry info for _adjustlinkrev()rz  r{  r  r  r  Nr  )rJ   r"   r  ra   r  r   r  )r$   r   rz  r{  r  s        r&   _parentfilectxzbasefilectx._parentfilectxg  s    tz4HHH$t**$$T

(B(B
 #'((**D$+D2Dd$K$KD!!d++"&"5D$+D2Dd$K$KD!r(   c           	      \     j          j         j                             j                  } fd|D             }                     j                  }|rC|                    d|d         |d          j                            |d                   f            fd|D             S )Nc                 D    g | ]}|j         j        j        k    |fS r@   r"   ri   r  )rY   r*   r  flr$   s     r&   r\   z'basefilectx.parents.<locals>.<listcomp>{  s=     
 
 
tz/666 D"666r(   r   r   c                 F    g | ]\  }}}                     |||          S r@   )r  )rY   r   r  lr$   s       r&   r\   z'basefilectx.parents.<locals>.<listcomp>  s1    MMMeQ##D%33MMMr(   )r  r  r   r  r  insertr"   r  )r$   r   plr   r  r#  s   `   @@r&   r   zbasefilectx.parentsw  s    
]-''77
 
 
 
 
 

 
 
 JJt~&& 		> IIa!A$!djooad&;&;<===MMMM"MMMMr(   c                 6    |                                  d         S r   )r   r+   s    r&   r   zbasefilectx.p1  s    ||~~a  r(   c                     |                                  }t          |          dk    r|d         S t          | j        | j        d| j                  S )Nr   r   r  )r   r   rJ   r"   r  r  )r$   r  s     r&   r   zbasefilectx.p2  sD    LLNNq66Q;;Q4Ktz4:b$-PPPPr(   c                     t          j         fd          fd}                                 }t          |dd           j                                        j        }|                                4|                    d |	                                D             d          }n*|                    |                                gd          }||_
        t          j        ||||          S )	aD  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                 8    j                             |           S r    )r"   r  )rr  r$   s    r&   <lambda>z&basefilectx.annotate.<locals>.<lambda>  s    TZ__Q-?-? r(   c                       j                                           }s fd|D             }|D ]-}d|j        vr" |                                          |_        .|S )Nc                 h    g | ].}|                                                                  k    ,|/S r@   )r   )rY   r  r   s     r&   r\   z9basefilectx.annotate.<locals>.parents.<locals>.<listcomp>  s3    <<<Aqvvxx16688';';a';';';r(   r  )r  r   r   r   r  )r   r'  r  followgetlogs   `  r&   r   z%basefilectx.annotate.<locals>.parents  sz    
 KKB  =<<<<<<<  2 2!QZ//!'!1!1AJIr(   r  Nc                 6    g | ]}|                                 S r@   r   r  s     r&   r\   z(basefilectx.annotate.<locals>.<listcomp>  s     555QUUWW555r(   Tr  )skiprevsdiffopts)r   lrucachefuncr  r   r"   r*  r+  ra   ru  r   r  r	   annotate)	r$   r0  r3  r4  r   baser5  r  r1  s	   ``      @r&   r6  zbasefilectx.annotate  s    "#?#?#?#?@@	 	 	 	 	 	*   ""4+T22: &&((2Bxxzz! \\55dllnn555 "   \\488::,$\??$&D!~'Hx
 
 
 	
r(   c              #     K   i }| }|rd}nd }	 |                                 d |         D ]-}|||                                |                                f<   .|sd S |                    t	          |                    }|V  ur   )r   r  r   popmax)r$   followfirstvisitr<  cutparents         r&   ru  zbasefilectx.ancestors  s       	CCC	))++dsd+ F F?Ev~~''):):;<< 		#e**%%AGGG	r(   c                     | j                             |                                 |                                           S )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&   decodeddatazbasefilectx.decodeddata  s,    
 z$$TYY[[$))++>>>r(   )FNr    )FNNr  )@r4   r  r  r  r  r  r  r  r  r  r(  r  r,   r
   r  r  r6   r&  r>   rA   r  r   r  r   r{  ra   r  r*   r   r7  r8  r   r9  r  r:  r   r   r   r   rP   r   r  r  r%   r  r   r  r  r  r  r  rk   r  r  r  r  r  r  r   r   r   r6  ru  rA  r@   r(   r&   r  r    s         + + ]+ 8 8 ]8 8 8 ]8 1 1 ]1   ]   H+ + + !h ++G< < <    # # #     1 1 ]1      4 4 4& & &% % %& & && & &' ' '- - -( ( (' ' '' ' '* * ** * */ / /* * *    0 0 0           $ $ $$ $ $   J' ' 'R3 3 3 3j( ( (	  	  	 " " " ":@ @ @   N N N0! ! !Q Q Q0
 0
 0
 0
d    ? ? ? ? ?r(   r  c                   t    e Zd ZdZ	 	 	 	 ddZed             ZddZd Zd Z	d Z
d	 Zed
             Zd ZdS )rJ   z^A filecontext object makes access to data related to a particular
    filerevision convenient.Nc                     || _         || _        |||J d|||fz              ||| _        ||| _        ||| _        |	|| _        dS dS )z`changeid 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  rz  r{  r   s          r&   r'   zfilectx.__init__  s     

  F$6):O:O<@
 
 ;P:O:O #DM%DN 'DO!DLLL r(   c                     	 | j         | j                 S # t          j        $ r' | j                                         | j                 cY S w xY wr    )r"   r  r   FilteredRepoLookupErrorr*  r+   s    r&   r  zfilectx._changectx  sW    	;:dn--, 	; 	; 	;" :((**4>::::#	;s    3A
	A
c                 H    t          | j        | j        || j        |          S )zMopens an arbitrary revision of the file without
        opening a new filelog)rz  r{  r  rJ   r"   r  r  )r$   rz  r  s      r&   rJ   zfilectx.filectx  s0     JJM
 
 
 	
r(   c                 @    | j                             | j                  S r    )r  rawdatar  r+   s    r&   rI  zfilectx.rawdata(  s    }$$T^444r(   c                 @    | j                             | j                  S )zlow-level revlog flags)r  r   r  r+   s    r&   rawflagszfilectx.rawflags+  s    }""4=111r(   c                 @   	 | j                             | j                  S # t          j        $ rm | j        j                            dd          dk    rY dS t          j        t          d          t          | j                  z  t          d                    w xY w)Ns   censors   policys   ignorer(   s   censored node: %ss"   set censor.policy to ignore errors)hint)r  r.  r  r   CensoredNodeErrorr"   r}   rN  Abortr   r   r+   s    r&   r  zfilectx.data/  s    	=%%dn555& 	 	 	z}##Iy99YFFss+&''%*?*??<==   	s   ! 3BABc                 @    | j                             | j                  S r    )r  r  r  r+   s    r&   r  zfilectx.size:  s    }!!$-000r(   c                 v   | j                             | j                  }|sdS |                                 |                                 k    r|S |                                 }| j        }| j                                        D ]4}	 ||                    |          k    r dS  # t          j
        $ r Y 1w xY w|S )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  r  r  ra   r  r   r  r   r   r   r   )r$   r  namer  r  s        r&   r  zfilectx._copied=  s     -''77 	488::''Nyy{{((** 	 	AAJJt,,,,44 -$   s   B$$B65B6c                 ^      j                              j                  } fd|D             S )Nc                 T    g | ]$}t          j        j        |j                   %S r  rG  rq  s     r&   r\   z$filectx.children.<locals>.<listcomp>Z  s@     
 
 
 DJ
1dmLLL
 
 
r(   )r  rs  r  r;  s   ` r&   rs  zfilectx.childrenW  sE    M""4>22
 
 
 

 
 
 	
r(   )NNNNr    )r4   r  r  r  r'   r  r  rJ   rI  rK  r  r  r  rs  r@   r(   r&   rJ   rJ     s            " " " "@ ; ; ];,	
 	
 	
 	
5 5 52 2 2	 	 	1 1 1   ]2
 
 
 
 
r(   rJ   c                   F    e Zd ZdZ	 	 	 	 	 	 d% fd	Zd Zd Z ej        e          Z	d Z
e
Zed             Zed	             Zed
             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZeZeZeZd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd  Z(d! Z)d&d$Z* xZ+S )'committablectxzA committablectx object provides common functionality for a context that
    wants the ability to commit, e.g. workingctx or memctx.r(   Nc                    t          t          |                               |           d | _        d | _        || _        |rt          j        |          | _        |r|| _	        |r|| _
        i | _        |r|                                | _        |t          j        |          | j        d<   | j                            d          sd| j        d<   d S d S )NrX  s   default)r   rW  r'   r:   r   _textr   	parsedate_date_user_status_extrar   r
   	fromlocalrZ  	r$   r%   textr7  r8  r:  r   r  r  s	           r&   r'   zcommittablectx.__init__d  s     	nd##,,T222	

 	2!+D11DJ 	DJ 	#"DL 	'**,,DK%-%7%?%?DK	"{y)) 	0%/DK	"""	0 	0r(   c                 <    t          | j        d                   dz   S )Nr      +)bytesr   r+   s    r&   r,   zcommittablectx.__bytes__  s    T]1%&&--r(   c                 (    | j         j        j         d S r    r"   ri   wdirhexr+   s    r&   r   zcommittablectx.hex  s    
 ((((r(   c                     dS NTr@   r+   s    r&   r(  zcommittablectx.__nonzero__      tr(   c                 4    | j                                         S r    )r"   rQ   r+   s    r&   r]  zcommittablectx._status  s    z  """r(   c                 >    | j         j                                        S r    )r"   r}   usernamer+   s    r&   r\  zcommittablectx._user  s    z}%%'''r(   c                 t    | j         j        }|                    dd          }|t          j                    }|S )Ns   devels   default-date)r"   r}   
configdater   makedate)r$   r}   r8  s      r&   r[  zcommittablectx._date  s6    Z]}}X77<$&&Dr(   c                     d S r    r@   r   s     r&   r   zcommittablectx.subrev  rj  r(   c                     d S r    r@   r+   s    r&   r?  zcommittablectx.manifestnode  rj  r(   c                 L    | j         p| j        j                                        S r    )r\  r"   r}   rm  r+   s    r&   r7  zcommittablectx.user  s    z5TZ]33555r(   c                     | j         S r    )r[  r+   s    r&   r8  zcommittablectx.date  r   r(   c                     | j         S r    )rY  r+   s    r&   r9  zcommittablectx.description  r   r(   c                 h    t          | j        j        | j        j        z   | j        j        z             S r    )rH  r]  rq   rr   rs   r+   s    r&   r   zcommittablectx.files  s0    L!DL$669MM
 
 	
r(   c                     | j         j        S r    )r]  rq   r+   s    r&   rq   zcommittablectx.modified  s    |$$r(   c                     | j         j        S r    )r]  rr   r+   s    r&   rr   zcommittablectx.added  s    |!!r(   c                     | j         j        S r    )r]  rs   r+   s    r&   rs   zcommittablectx.removed      |##r(   c                     | j         j        S r    )r]  rb   r+   s    r&   rb   zcommittablectx.deleted  rz  r(   c                 @    t          j        | j        d                   S rW  )r
   rY  r^  r+   s    r&   r  zcommittablectx.branch  s    I 6777r(   c                     d| j         v S r\  r^  r+   s    r&   r  zcommittablectx.closesbranch  s    4;&&r(   c                     | j         S r    r~  r+   s    r&   r:  zcommittablectx.extra  r  r(   c                     dS r9   r@   r+   s    r&   rm  zcommittablectx.isinmemory  rn  r(   c                     g S r    r@   r+   s    r&   ra  zcommittablectx.tags      	r(   c                     g }|                                  D ])}|                    |                                           *|S r    )r   r  rd  )r$   br  s      r&   rd  zcommittablectx.bookmarks  s@     	$ 	$AHHQ[[]]####r(   c                     t          j        | j        j                  }|                                 D ]$}t          ||                                          }%|S r    )r   newcommitphaser"   r}   r   r:  r   )r$   r   r  s      r&   r   zcommittablectx.phase  sK    %djm44 	* 	*Aqwwyy))EEr(   c                     dS r9   r@   r+   s    r&   rk  zcommittablectx.hidden  rn  r(   c                     g S r    r@   r+   s    r&   rs  zcommittablectx.children  r  r(   c                     d| j         v r,	 | j                            |          S # t          $ r Y dS w xY w	 |                     |          S # t
          $ r Y dS w xY w)NrE   r(   )r   rE   r   r   	_flagfuncOSErrorr   s     r&   r   zcommittablectx.flags  s    $-''~++D111   ss	>>$''' 	 	 	33	s   % 
33A 
AAc                 B    | j         d                             |          S )z1return the "best" ancestor context of self and c2r   )r   r  )r$   r  s     r&   r  zcommittablectx.ancestor  s    }Q((,,,r(   c              #      K   | j         D ]}|V  | j        j                            d | j         D                       D ]}| j        |         V  d S )Nc                 6    g | ]}|                                 S r@   r   r  s     r&   r\   z,committablectx.ancestors.<locals>.<listcomp>  s     ,,,QUUWW,,,r(   )r   r"   r+  ru  )r$   r  rv  s      r&   ru  zcommittablectx.ancestors  sz       	 	AGGGG%//,,dm,,,
 
 	  	 A *Q-	  	 r(   c                     dS )aQ  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.

        Nr@   )r$   r*   s     r&   markcommittedzcommittablectx.markcommitted  s      r(   FTc                     dS r9   r@   )r$   missingmerger  s       r&   dirtyzcommittablectx.dirty  rn  r(   )r(   NNNNNFTT),r4   r  r  r  r'   r,   r   r
   r  r  r(  r  r  r]  r\  r[  r   r?  r7  r8  r9  r   rq   rr   rs   rb   rI  rF  rG  r  r  r:  rm  ra  rd  r   rk  rs  r   r  ru  r  r  r  r  s   @r&   rW  rW  `  sp       ? ? 0 0 0 0 0 0:. . .) ) ) !h ++G   H# # ]# ( ( ](   ]    6 6 6    
 
 

% % %" " "$ $ $$ $ $ MJL8 8 8' ' '              
 
 
- - -              r(   rW  c                   4    e Zd ZdZ	 d$ fd	Zd Zd Zd Zed             Z	d%d	Z
 fd
Zd Zed             Zd Zd%dZd&dZd'dZd'dZd Z	 	 	 	 	 	 	 d(dZd Zd Zd Zd)dZed             Zed             Zd Z fdZd Zd  Zd! Zd" Z d*d#Z! xZ"S )+
workingctxay  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.
    r(   Nc           	      
   d }|rd|vrJ	 |j                                         }n/# t          $ r" t          j        t          d                    w xY wt          t          |                               |||||||           d S )NrX  s   branch name not in UTF-8!r  )	dirstater  UnicodeDecodeErrorr   rO  r   r   r  r'   r`  s	           r&   r'   zworkingctx.__init__  s      	C	..C--//% C C Ck!$@"A"ABBBCj$(($dE76 	) 	
 	
 	
 	
 	
s	   % ,Ac              #   h   K   | j         j        }|D ] }|                    |          j        r|V  !d S r    r"   r  	get_entrytracked)r$   rt   r   s      r&   rN   zworkingctx.__iter__   sH      J 	 	A{{1~~% 	 	r(   c                 J    | j         j                            |          j        S r    r  rF   s     r&   rH   zworkingctx.__contains__&  s    z",,S1199r(   c                 $    | j         j        j        S r    rf  r+   s    r&   r   zworkingctx.hex)  s    z'//r(   c                       j         j                                        }|d          j         j        j        k    r
|d d         } j                                          fd|D             S )Nr   r*  c                 p    g | ]2}t          j        j                            |          |d           3S )Fr3  )r   r"   r+  ra   )rY   r~  r$   unfis     r&   r\   z'workingctx._parents.<locals>.<listcomp>3  sU     
 
 
  
DN..q111U  
 
 
r(   )r"   r  r   ri   r  r*  )r$   r  r  s   ` @r&   r   zworkingctx._parents,  s    J''))Q44:+222#2#Az$$&&
 
 
 
 
 	
 
 
 	
r(   c                    || j         j        j        }| j         j        }|                                5  |                    ||          }| j         |         }|r/|D ],}||vr&||         |v r|                    ||         |           -|| j         j        j        k    rWt          |                                	                                          D ]#\  }}||vr||vr|                    d |           $d d d            d S # 1 swxY w Y   d S r    )
r"   ri   r  r  parentchange
setparentsr   rH  copiesrg   )r$   p1nodep2noder  r  r   r   rl   s           r&   r  zworkingctx.setparents:  sh   >Z-4F:&""$$ 	/ 	/((88F:f%D 4   4 4A}}d):): fQi3331888"8??#4#4#:#:#<#<== / /DAq}}$ dA...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   CDD	Dc                 b    | j          t          t          |                               |          S r    )rE   r   r  r   )r$   r   r  s     r&   r   zworkingctx._fileinfoM  s(    Z&&00666r(   c                   	
 | j         j                                        j        |                                 }t          |          dk     r!|d                                         

fd}n_|\  }}|                    |          }|                                |                                |                                c		fd}|S )Nr   r   c                 F     | |           }                      |           S r    r  )r   	copiesgetmans    r&   funcz'workingctx._buildflagfunc.<locals>.func\  s"    IaOOyy||#r(   c                      | |           }                      |                                |                                |           }}}||k    r|S ||k    r|S ||k    r|S dS Nr(   r  )r   fl1fl2flar  m1m2mas       r&   r  z'workingctx._buildflagfunc.<locals>.funcg  sl    IaOO "RXXa[["((1++#S#::J#::J#::Jsr(   )r"   r  r  rZ  r   r   rP   r  )r$   r   r  r   r   par  r  r  r  r  s         @@@@@r&   _buildflagfunczworkingctx._buildflagfuncR  s     J'..004	,,..w<<!!*%%''C$ $ $ $ $ $ $ FBRBr{{}}JBB	 	 	 	 	 	 	 	 r(   c                 J    | j         j                            | j                  S r    )r"   r  flagfuncr  r+   s    r&   r  zworkingctx._flagfunct  s    z"++D,?@@@r(   c                 P    	 |                      |          S # t          $ r Y dS w xY wr  )r  r  r   s     r&   r   zworkingctx.flagsx  s;    	>>$''' 	 	 	33	s    
%%c                 2    t          | j        || |          S )z-get a file context from the working directory)r  r{  )workingfilectxr"   r$   r   r{  s      r&   rJ   zworkingctx.filectx~  s$    Jw
 
 
 	
r(   FTc                    t          | j                  D ].}|                     |                              |          r dS /|r|                                 p|o;|                                 |                                                                 k    pQ|                                 p=|                                 p)| 	                                p|o| 
                                S )z-check whether a working directory is modified)r  T)rH  r~   r   r  r   r  r   rq   rr   rs   rb   )r$   r  r  r  rl   s        r&   r  zworkingctx.dirty  s     && 	 	Axx{{   11 tt  twwyy ,>4;;==DGGII,<,<,>,>>,}}, zz||, ||~~	,
 *DLLNN	
r(   c           
      B  
 | j                                         5  | j         j        | j         j        c}

fd}g }| j         j        j        }|D ]}t          j        |t          j	        
                    |                     	  ||          }nS# t          $ rF |                    t          d           ||          z             |                    |           Y w xY w|                    dd          }	|	dk    rG|j        |	k    r<|                    t          d          |d|j        z  dz   ||          fz             t#          j        |j                  s^t#          j        |j                  sE|                    t          d	           ||          z             |                    |           p
                    |          s.|                    t          d
           ||          z             |cd d d            S # 1 swxY w Y   d S )Nc                 T                         t          j        |                     S r    pathtor   r  r   dsprefixs    r&   r-  z workingctx.add.<locals>.<lambda>      ryyvq)A)ABB r(      %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}   r  wvfslstatr   checkportableosr   r  r  r  r   rh   configbytesst_sizestatS_ISREGst_modeS_ISLNKset_tracked)r$   listr  r}   uipathrejectedr  r   stlimitr  s     `       @r&   addzworkingctx.add  s   Z &	 &	Z]DJ$7FBBBBBBFHJO)E  E  E %b"',,vq*A*ABBBqBB   GGA566BCCCOOA&&&H u.ABBA::"*u"4"4GG3  a"*n7CD   RZ00 
EDL4L4L 
EGG5  !&))	$   OOA&&&&** EGGA677&&))CDDDM&	 &	 &	 &	 &	 &	 &	 &	 &	 &	 &	 &	 &	 &	 &	 &	 &	 &	s8   A+HBHAC$!H#C$$D#HHHc                 f   | j                                         5  | j         j        fd}g }|D ]d}                    |          sM| j         j                            t          d           ||          z             |                    |           e|cd d d            S # 1 swxY w Y   d S )Nc                 T                         t          j        |                     S r    r  r  s    r&   r-  z#workingctx.forget.<locals>.<lambda>  r  r(   s   %s not tracked!
)r"   r  r  set_untrackedr}   r  r   rh   )r$   r   r  r  r  r   r  s     `   @r&   forgetzworkingctx.forget  s   Z 	 	$BBBBBBFH ' '''** 'JM&&q)='>'>'JKKKOOA&&&	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A=B&&B*-B*c                    	 | j         j                            |          }n]# t          $ rP | j         j                            t          d          | j         j                            |          z             Y d S w xY wt          j
        |j                  sgt          j        |j                  sN| j         j                            t          d          | j         j                            |          z             d S | j                                         5  | j         j        }|                    |           |                    ||           d d d            d S # 1 swxY w Y   d S )Nr  s1   copy failed: %s is not a file or a symbolic link
)r"   r  r  FileNotFoundErrorr}   r  r   r  r  r  r  r  r  r  r  r   )r$   rQ  destr  r  s        r&   r   zworkingctx.copy  s   	&&t,,BB  	 	 	JM)**TZ-@-G-G-M-MM   FF		
 RZ(( 		&DL,D,D 		&JMGHH*%,,T223    
 !!## & &Z(t$$$%%%& & & & & & & & & & & & & & & & & &s"   " AA<;A<8EE!$E!r   c                     | j         }|s|                                }t          j        |j                   }	t          j        |j        ||||||j        | |||	          S )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   zworkingctx.match  su     J 	((**C *16222~FI%
 
 
 	
r(   c                 v   |r| j         j        j        r|S g }|D ]}|                     |          dk    rn| |                                         }|dk    s+t          |          dk    sd|v st          j        |          r#| j         j        	                    d|z             |
                    |           |S )Nr  r(   i      
s*   ignoring suspect symlink placeholder "%s"
)r"   r  
_checklinkr   r  r   r   r  r}   debugrh   )r$   r   saner   rt   s        r&   _filtersuspectsymlinkz workingctx._filtersuspectsymlink  s     	
+6 	L  	 	Azz!}}$$GLLNNHH1vv~~zz!(++ " JM''FJ   KKNNNNr(   c                    |sg g g g fS g }g }g }g }| j         d         }t          |          D ] }	 ||vsM|                     |          |                    |          k    s!||                             | |                   r|                    |           n||                    |           nq| |                                         }	|	j        }
|	j        }t          j	        |	|          }||
||f}|                    ||f           n|                    |           # t          t          f$ r |                    |           Y w xY w||||fS r   )r   rH  r   rk   rh   r  r  r  r   reliable_mtime_ofr  r  )r$   r   mtime_boundaryrq   rb   rV   fixupr   r   rl   moder  
file_mtime
cache_infos                 r&   _checklookupzworkingctx._checklookup  s}    	"r2r>!}Q 	" 	"A" TMMzz!}}

155Aw{{47++ 6 OOA&&&&#+LLOOOOQA9D9D!*!<Q!O!OJ!-&*D*%=
a_5555QW% " " " q!!!!!" %..s   C0D""&EEc                 2  
 | j                                         }|s|s| j         j        j        rf	 | j         j                                        }| j                             d          5  | j         j        

                                |k    r|rm
                                r
fd}n
j        }|D ]\  }} |||           | j                                         }| j         j        	                    |           |r|D ]}	 |	| |           n| j         j
                            d           ddd           n# 1 swxY w Y   n# t          j        $ r Y nw xY w| j                                          dS # | j                                          w xY wdS )z1update dirstate for files that are actually cleanFc                 4                         | dd          S )NT
p1_tracked
wc_tracked)update_file)r   pfdr  s     r&   r-  z-workingctx._poststatusfixup.<locals>.<lambda>O  s$    8L8L$%$4 9M 9" 9" r(   s*   skip updating dirstate: identity mismatch
N)r"   postdsstatusr  _dirtyidentityr  pendingparentchange	set_cleancurrenttransactionwriter}   r  r   	LockErrorclearpostdsstatus)r$   rQ   r  
poststatusoldidnormalr   pdftrpsr  s             @r&   _poststatusfixupzworkingctx._poststatusfixup?  s!   Z,,..
 *	/J *	/$*"5"< *	/)/
+4466 Z%%e,,  #z2H((**e33  :';;== <*" *" *" *" *2);*/ / /3 &q#
 "&!>!>!@!@B J/55b999% 1&0 1 1 "4 0 0 0 0 
++J  7              < ?    
,,.....
,,....U*	/ *	/sN   8E	 *CD=1E	 =EE	 EE	 E9 	EE9 EE9 9Fc           	         g }d| v rt          | j                  }| j        j                            |||||          \  }}}g }	|r|                     ||          \  }
}}}	|j                            |
           |j                            |           |r|r|j	                            |           |	r&|r$|j	                            d |	D                        | 
                    ||	           |                                rP|j        s|j        s|j	        r4t          j        |j        |j        |j        |j        g g g           | _        n|| _        |S )z7Gets the status from the dirstate -- internal use only.s   .hgsub)rd   rV   rc   c              3       K   | ]	\  }}|V  
d S r    r@   )rY   r   r   s      r&   r   z-workingctx._dirstatestatus.<locals>.<genexpr>  s&      44da444444r(   )rH  r~   r"   r  rQ   r  rq   r  rb   rV   r  alwaysrc   rd   r   rr   rs   r]  )r$   r   rd   rV   rc   subreposrk   rl   r  r  	modified2deleted2	clean_sets                r&   _dirstatestatuszworkingctx._dirstatestatusn  s   dm,,H!%!4!;!;8WE7 "< "
 "
Q
  
	6484E4E^5 51IxE Ji(((IX&&& *U *y))) 6 644e444555a'''<<>> 	!y !AI ! !&~JAIr2r     !r(   c                 L   i }i }| j         j                                        }| j         |d                                                  }| j         |d                                                  }t	          |                                           t	          |                                           z  }| j                                         }| j         j                                        	                                D ](\  }}	||vs ||          s|	|v r|	||<   |	|v r|	||<   )||fS )Nr   r   )
r"   r  r   rP   re   rr   rq   r  r  rg   )
r$   r   r   r   
p1manifest
p2manifest
changedsetr  dstsrcs
             r&   r   zworkingctx._copies  s   *%--//Z
+4466
Z
+4466
&&T]]__)=)==
j,,..
+2244::<< 	$ 	$HC*$$KK,<,<$j   #
"" #!!r(   c                 6    |                      | j                  S )aL  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.
        )rR   r]  r+   s    r&   rE   zworkingctx._manifest  s     ((666r(   c                    |                                  }|d                                                                         }| j        }| j        j        j        |j        f| j        j        j        |j	        ffD ]?\  }}|D ]7}|||<   	 |
                    | ||                     (# t          $ r Y 4w xY w@|j        |j        z   D ]	}||v r||= 
|S )z9Builds a manifest that includes the given status results.r   )r   rP   r   r  r"   ri   addednodeidrr   modifiednodeidrq   setflagr  rb   rs   )r$   rQ   r   r  ffir%  r   s           r&   rR   zworkingctx._buildstatusmanifest  s   ,,..aj!!##((**^Z%16<@Z%4foF
 		 		DAq   AKK22a55))))   D	 &.0 	 	ACxxF
s   B''
B43B4c                     |                      ||||          }|                     |j                  |j        dd<   || j        d         k    r-t	          t
          |                               ||||||          }|S )aC  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  rq   r"   r   r  rz   )r$   r=   rl   r   rm   rn   ro   r  s          r&   rz   zworkingctx._buildstatus  s       YLL 221:>>
111DJt$$$j$''44q%i A r(   c                 F      j         d         k    r fd}||_        |S )a  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                     | vrX                     |           sEj        j                            dj        j                            |           |fz             d S d S d S )Ns   %s: %s
)r   r"   r}   r  r  r  )r   r  r=   r$   s     r&   r  z$workingctx._matchstatus.<locals>.bad  sm     E>>%,,q//>JM&&#tz':'A'A!'D'Dc&JJ     ">>>r(   )r"   r  )r$   r=   r   r  s   ``  r&   rT   zworkingctx._matchstatus  sD     DJt$$$      EIr(   c                     t          | j        j                            | j                            |          t          | j                  dd                    S )r  TF)r  rc   rd   )rH  r"   r  r  r  r~   r  s     r&   r  zworkingctx.walk  sW    J$$
&&u--..	 %  
 
 	
r(   c                     | j                             |          }| j         j        t          fd                    |          D                       S )Nc              3   P   K   | ] }                     |          j        |V  !d S r    )r  r  )rY   r   r  s     r&   r   z%workingctx.matches.<locals>.<genexpr>  s5      NNAbll1oo6MNaNNNNNNr(   )r"   r  r  rH  r  )r$   r   r  s     @r&   r  zworkingctx.matches  sQ    
&&u--Z NNNNE!2!2NNNNNNr(   c                    | j         j                                        5  |                                 |                                 z   D ]$}| j         j                            |dd           %|                                 D ]$}| j         j                            |dd           %| j         j                            |           | j                                          t          j
        | j         |           d d d            n# 1 swxY w Y   | j         j                            | j                                                    d S )NTr  F)r"   r  r  rq   rr   r  rs   r  !_quick_access_changeid_invalidater   aftercommitr  r  )r$   r*   r   s      r&   r  zworkingctx.markcommitted  sz   Z --// 	1 	1]]__tzz||3  
#//$4 0     \\^^  
#//%E 0     J**4000J88:::tz4000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1" 	
!!$*"?"?"A"ABBBBBs   CDD	D	c                     |r$t           j                            | j                  S t           j                            | j                  S r    )mergestatemodr   rV   r"   r.  r  s     r&   r   zworkingctx.mergestate  s<     	> +11$*===',,TZ888r(   )r(   NNNNr    r  r(   r  FFFr  )#r4   r  r  r  r'   rN   rH   r   r  r   r  r   r  r  r   rJ   r  r  r  r   r   r  r  r  r  r   rE   rR   rz   rT   r  r  r  r   r  r  s   @r&   r  r  	  s         IM
 
 
 
 
 
  : : :0 0 0 
 
 ]
/ / / /&7 7 7 7 7
     D A A ]A  
 
 
 

 
 
 
 ' ' ' 'R	 	 	 	& & &* 
 
 
 
>  2*/ */ */X-/ -/ -/^# # # #J " " ]"" 7 7 ]7  0    *  .	
 	
 	
O O O
C C C(9 9 9 9 9 9 9 9r(   r  c                   <    e Zd ZdZd	dZd ZeZd Zd Zd Z	d Z
dS )
committablefilectxzA committablefilectx provides common functionality for a file context
    that wants the ability to commit, e.g. workingfilectx or memfilectx.Nc                 t    || _         || _        d | _        d x| _        | _        ||| _        |r	|| _        d S d S r    )r"   r  r  r  r  r  r  )r$   r%   r   r{  r   s        r&   r'   zcommittablefilectx.__init__"  sO    

)--#DM 	"!DOOO	" 	"r(   c                     dS ri  r@   r+   s    r&   r(  zcommittablefilectx.__nonzero__-  rj  r(   c                 *    |                                  S r    r   r+   s    r&   r  zcommittablefilectx.linkrev2  s    xxzzr(   c                     |                                  }|sd S || j        j        d         j                            || j        j        j                  fS r   )r  r  r   rE   rZ  r"   ri   r  r   s     r&   r  zcommittablefilectx.renamed6  sX       	4O$Q'155dj.5 
 	
r(   c                 "     fd} j         } j        } j        j        }                                 }|r|dz   g}n| ||d         |          |fg}|dd         D ]$}|                    | |||          |f           % fd|D             S )z5return parent filectxs, following copies if necessaryc                 X    | j                             |j        j        j                  S r    )rE   rZ  r"   ri   r  )r   r   r$   s     r&   r   z,committablefilectx.parents.<locals>.filenodeD  s#    =$$T4:+C+JKKKr(   r    r   r   Nc                 r    g | ]3\  }}}|j         j        j        k                        |||           4S rU  )r"   ri   r  r  )rY   r  r~  r%  r$   s       r&   r\   z.committablefilectx.parents.<locals>.<listcomp>T  sQ     
 
 
1aDJ,333 !Q77333r(   )r  r  r  r   r  rh   )r$   r   r   r#  pclr  r'  pcs   `       r&   r   zcommittablefilectx.parentsA  s    	L 	L 	L 	L 	L z]o&,,.. 	6G#$BB#a&$//45Babb' 	6 	6BIItXXb$//45555
 
 
 

 
 
 	
r(   c                     g S r    r@   r+   s    r&   rs  zcommittablefilectx.childrenZ  r  r(   r  )r4   r  r  r  r'   r(  r  r  r  r   rs  r@   r(   r&   r0  r0    s        L L	" 	" 	" 	"   H  	
 	
 	

 
 
2    r(   r0  c                        e Zd ZdZd fd	Zed             Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZddZddZd Zd Zd Z xZS )r  zrA workingfilectx object makes access to data related to a particular
    file in the working directory convenient.Nc                 ^    t          t          |                               ||||           d S r    )r   r  r'   )r$   r%   r   r{  r  r  s        r&   r'   zworkingfilectx.__init__b  s-    nd##,,T4*MMMMMr(   c                 *    t          | j                  S r    )r  r"   r+   s    r&   r  zworkingfilectx._changectxe  s    $*%%%r(   c                 @    | j                             | j                  S r    )r"   wreadr  r+   s    r&   r  zworkingfilectx.datai  s    z
+++r(   c                 J    | j         j                            | j                  S r    )r"   r  copiedr  r+   s    r&   r  zworkingfilectx.copysourcel  s    z"))$*555r(   c                 T    | j         j                            | j                  j        S r    )r"   r  r  r  r  r+   s    r&   r  zworkingfilectx.sizeo  s    z$$TZ0088r(   c                 J    | j         j                            | j                  S r    )r"   r  r  r  r+   s    r&   r  zworkingfilectx.lstatr      z$$TZ000r(   c                     | j                                         \  }}	 | j        j                            | j                  t          j                 |fS # t          $ r ||fcY S w xY wr    )	r  r8  r"   r  r  r  r  ST_MTIMEr  )r$   ttzs      r&   r8  zworkingfilectx.dateu  sl    $$&&2	JO))$*55dmDbII  	 	 	r7NNN	s   5A A%$A%c                 J    | j         j                            | j                  S r    )r"   r  existsr  r+   s    r&   rJ  zworkingfilectx.exists|  s    z%%dj111r(   c                 J    | j         j                            | j                  S r    )r"   r  lexistsr  r+   s    r&   rL  zworkingfilectx.lexists  s    z&&tz222r(   c                 J    | j         j                            | j                  S r    )r"   r  auditr  r+   s    r&   rN  zworkingfilectx.audit  rD  r(   c                 ,    |                     |           S )r  )rk   r  s     r&   rk   zworkingfilectx.cmp  s     xx~~r(   Fc                     | j         j                            dd          }| j         j                            | j        ||           dS )+wraps unlink for a repo's working directoryrL  s   removeemptydirs)ignoremissingrmdirN)r"   r}   
configboolr  
unlinkpathr  )r$   rR  rS  s      r&   removezworkingfilectx.remove  sP    
((:LMM
""Jm5 	# 	
 	
 	
 	
 	
r(   c                 :     | j         j        | j        ||fd|i|S )wraps repo.wwritebackgroundclose)r"   wwriter  r$   r  r   rY  kwargss        r&   r  zworkingfilectx.write  s9     tz Je
 
5D
HN
 
 	
r(   c                 P    | j         j                            || j                   dS )zmarks this file a copy of `src`N)r"   r  r   r  )r$   r  s     r&   
markcopiedzworkingfilectx.markcopied  s%    
  dj11111r(   c                 ^   | j         j        }| j        }|                    |           | j         j                            dd          r|                    |          r,|                    |          s|                    |d           t          t          t          j        |                              D ]/}|                    |          r|                    |            dS 0dS |                    |          r,|                    |          s|                    |           dS dS dS )zsRemoves conflicting items in the working directory so that
        ``write()`` can be called successfully.
        rL  s   merge.checkpathconflictsT)forciblyN)r"   r  r  rN  r}   rT  isdirr  rmtreer  r  r   finddirsisfileorlinkunlink
removedirs)r$   r  r   r  s       r&   clearunknownzworkingfilectx.clearunknown  s6    zJ

1:=##8
 
 	#
 zz!}} .T[[^^ .A---d8#4Q#7#78899  $$Q'' KKNNNEE  zz!}} #T[[^^ #"""""# # # #r(   c                 R    | j         j                            | j        ||           d S r    )r"   r  setflagsr  )r$   r%  rr  s      r&   ri  zworkingfilectx.setflags  s&    
  Q22222r(   r  r  )r4   r  r  r  r'   r  r  r  r  r  r  r8  rJ  rL  rN  rk   rV  r  r^  rg  ri  r  r  s   @r&   r  r  ^  sD       1 1N N N N N N & & ]&, , ,6 6 69 9 91 1 1  2 2 23 3 31 1 1  
 
 
 

 
 
 
2 2 2# # #.3 3 3 3 3 3 3r(   r  c                   "    e Zd ZdZ fdZd Zd'dZd Zed             Z	ed             Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd(dZd Zd Zd Zd Zd Z	 	 	 	 	 	 d)dZd Z d  Z!d! Z"d" Z#	 d*d#Z$d'd$Z%d+d&Z& xZ'S ),overlayworkingctxa  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                     t          t          |                               |           |                                  d S r    )r   rk  r'   rV   )r$   r%   r  s     r&   r'   zoverlayworkingctx.__init__  s3    &&//555

r(   c                 N    || _         |g| _        t          j        | d           d S )N	   _manifest)_wrappedctxr   r   clearcachedproperty)r$   
wrappedctxs     r&   setbasezoverlayworkingctx.setbase  s.    %# 	 |44444r(   Nc                     || j         j        j        }|| j                                        k    sJ | j        | j                                         |         g| _        d S r    )r"   ri   r  ro  r*   r*  r   )r$   r  r  s      r&   r  zoverlayworkingctx.setparents  sZ    >Z-4F)..000000)4:+@+@+B+B6+JKr(   c                 H   |                      |          ro| j        |         d         rE| j        |         d         | j        |         d         S | j        |                                         S t	          j        d|z            | j        |                                         S N   exists   data   No such file or directory: %s)isdirty_cachero  r  r   r  r   s     r&   r  zoverlayworkingctx.data  s    << 	1{4 + 	;t$W-9;t,W55  +D166888,4t;   #D)..000r(   c                    |                                  }|d                                                                         }| j        }|                                 D ]5}| j        j        j        ||<   |                    | ||                     6| 	                                D ]5}| j        j        j
        ||<   |                    | ||                     6|                                 D ]}||= |S r   )r   rP   r   r  rr   r"   ri   r  r  rq   r  rs   )r$   r   r  r   r   s        r&   rE   zoverlayworkingctx._manifest  s    ,,..aj!!##((**~JJLL 	* 	*D
0<CIKKdd4jj))))MMOO 	* 	*D
0?CIKKdd4jj))))LLNN 	 	DD		
r(   c                       fd}|S )Nc                 *    j         |          d         S )N   flagsrz  )r   r$   s    r&   r   z&overlayworkingctx._flagfunc.<locals>.f  s    ;t$X..r(   r@   )r$   r   s   ` r&   r  zoverlayworkingctx._flagfunc  s#    	/ 	/ 	/ 	/ 	/ r(   c                     t          |                                 |                                 z   |                                 z             S r    )rH  rr   rq   rs   r+   s    r&   r   zoverlayworkingctx.files	  s2    djjllT]]__4t||~~EFFFr(   c                 N      fd j                                         D             S )Nc                 d    g | ],}j         |         d                              |          *|-S rv  rz  _existsinparentrY   r   r$   s     r&   r\   z.overlayworkingctx.modified.<locals>.<listcomp>	  sR     
 
 
{1~i(
 .2-A-A!-D-D

 
 
r(   rz  keysr+   s   `r&   rq   zoverlayworkingctx.modified	  <    
 
 
 
[%%''
 
 
 	
r(   c                 N      fd j                                         D             S )Nc                 d    g | ],}j         |         d                              |          *|-S r  r  r  s     r&   r\   z+overlayworkingctx.added.<locals>.<listcomp>	  sR     
 
 
{1~i(
 261E1Ea1H1H

 
 
r(   r  r+   s   `r&   rr   zoverlayworkingctx.added	  r  r(   c                 N      fd j                                         D             S )Nc                 d    g | ],}j         |         d                              |          *|-S r  r  r  s     r&   r\   z-overlayworkingctx.removed.<locals>.<listcomp>	  sR     
 
 
;q>),
 261E1Ea1H1H

 
 
r(   r  r+   s   `r&   rs   zoverlayworkingctx.removed	  r  r(   c                     i }| j                                         }| j                                        D ]>} ||          s|                    |d            | j        |         d         }|r|||<   ?|S N   copiedr"   r  rz  r  r9  r$   r  r  r   rQ  s        r&   r   zoverlayworkingctx.p1copies	      j,,..!!## 	# 	#A;q>> JJq$[^I.F #"q	r(   c                     i }| j                                         }| j                                        D ]>} ||          s|                    |d            | j        |         d         }|r|||<   ?|S r  r  r  s        r&   r   zoverlayworkingctx.p2copies%	  r  r(   c                     dS ri  r@   r+   s    r&   rm  zoverlayworkingctx.isinmemory1	  rj  r(   c                     |                      |          r| j        |         d         S | j        |                                         S )N   date)ry  rz  ro  r8  r   s     r&   filedatezoverlayworkingctx.filedate4	  sB    << 	1;t$W--#D)..000r(   c                     |                      |d|                     |          |                     |          |           d S )NT)rJ  r8  r   rA  )
_markdirtyr  r   )r$   r   origins      r&   r^  zoverlayworkingctx.markcopied:	  sN    t$$**T"" 	 	
 	
 	
 	
 	
r(   c                 V    |                      |          r| j        |         d         S d S r  )ry  rz  r   s     r&   copydatazoverlayworkingctx.copydataC	  s-    << 	;t$Y//4r(   c                     |                      |          r=| j        |         d         r| j        |         d         S t          j        d|z            | j        |                                         S )Nrv  r~  rx  )ry  rz  r   r  ro  r   r   s     r&   r   zoverlayworkingctx.flagsI	  su    << 	2{4 + {4(22,4t;   #D)//111r(   c                 f    || j         v r| j         |         d         S ||                                 v S )Nrv  )rz  r   rF   s     r&   rH   zoverlayworkingctx.__contains__T	  s4    $+;s#I..dggiir(   c                 N    	 | j         |          dS # t          j        $ r Y dS w xY wr  )ro  r   r   r   s     r&   r  z!overlayworkingctx._existsinparentY	  sA    	 T""4( 	 	 	55	s    $$c           
           fd}|                     d          }t          t          |                    D ]/}d                    |d|                   }| v r |||           0                     |gd          }t                                                                                               |                    }t          |          dk    rt          |          dk    r|d         |k    rdS  fd|D             }|sdS t          j
        d	||                                 t          |          d
                    |          fz            dS )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                 X   d                                 |                                         v r>t          j        d| |                                                                 fz            t          j        d| |                                                                 fz            )Nr  s*   error: %s conflicts with symlink %s in %d.s+   error: '%s' conflicts with file '%s' in %d.)r   r   r   rO  ra   )r   	componentr$   s     r&   failz/overlayworkingctx._auditconflicts.<locals>.failk	  s     twwyy+113333k!%y$''))--// BC  
 k"Itwwyy}}?@  r(   r  r   s   path)r   r   Nc                     g | ]}|v |	S r@   r@   )rY   r  r$   s     r&   r\   z5overlayworkingctx._auditconflicts.<locals>.<listcomp>	  s    555A199a999r(   sb   error: file '%s' cannot be written because  '%s/' is a directory in %s (containing %d entries: %s)s   , )splitranger   r  r   r  r   rP   r  r   rO  )r$   r   r  
componentsr   r  r   mfiless   `       r&   _auditconflictsz!overlayworkingctx._auditconflictsc	  st   	 	 	 	 	  ZZ%%
s:'' 	& 	&A		*QqS/22ID  T9%%% 

D67
33dggii((**//6677v;;??6{{aF1I$5$55555555F +  twwyy#f++uzz&7I7IJK   ?r(   r(   c                     |t          j        d          |                     |           |                     |d|t	          j                    |           d S )Ns   data must be non-NoneT)rJ  r  r8  r   )r   r  r  r  r   rp  )r$   r   r  r   r\  s        r&   r  zoverlayworkingctx.write	  sf    <()ABBBT"""Dx/@/B/B% 	 	
 	
 	
 	
 	
r(   c                 p    d}|rd}n|rd}|                      |dt          j                    |           d S )Nr(   r  r  T)rJ  r8  r   )r  r   rp  )r$   r   r%  rr  r   s        r&   ri  zoverlayworkingctx.setflags	  sL     	DD 	DT0A0C0C4PPPPPr(   c                 4    |                      |d           d S )NF)rJ  )r  r   s     r&   rV  zoverlayworkingctx.remove	  s    U+++++r(   c                 <   |                      |          rs| j        |         d         rMd| j        |         d         v r8|                     | j        |         d                                                   S | j        |         d         S |                     |          S )zqexists behaves like `lexists`, but needs to follow symlinks and
        return False if they are broken.
        rv  r  r~  rw  )ry  rz  rJ  stripr  r   s     r&   rJ  zoverlayworkingctx.exists	  s     << 		4 D!),4DK-h777{{4;t#4W#=#C#C#E#EFFF{4(33##D)))r(   c                 |    |                      |          r| j        |         d         S |                     |          S )z'lexists returns True if the path existsrv  )ry  rz  r  r   s     r&   rL  zoverlayworkingctx.lexists	  s<    << 	0;t$Y//##D)))r(   c                     |                      |          rJ| j        |         d         r t          | j        |         d                   S t          j        d|z            | j        |                                         S ru  )ry  rz  r   r   r  ro  r  r   s     r&   r  zoverlayworkingctx.size	  s}    << 	{4 + 4;t,W5666,4t;   %**,,,r(   c                     |1                                  }t          |          dk    r
|d         df}|d          j        |d                  df}n& j        |d                   j        |d                  f}                                 } fd}	| j                                        }t           j        ||||	|||||
  
        S )zConverts this ``overlayworkingctx`` into a ``memctx`` ready to be
        committed.

        ``text`` is the commit message.
        ``parents`` (optional) are rev numbers.
        Nr   r   c           
          j         |         d         r]t          | ||j         |         d         dj         |         d         v dj         |         d         v j         |         d                   S d S )Nrv  rw  r  r~  r  r  )rz  
memfilectx)r%   memctxr   r$   s      r&   getfilez+overlayworkingctx.tomemctx.<locals>.getfile	  s    {4 + !K%g.DK-h77DK-h77K%i0   tr(   )r8  r:  r7  r  editor)r   r   r"   r   ro  r  r  )
r$   ra  r  r:  r8  r   r7  r  r   r  s
   `         r&   tomemctxzoverlayworkingctx.tomemctx	  s    " ?llnnG7||q  "1:t, 1:z'!*-t4GGz'!*-tz'!*/EFG

	 	 	 	 	  >%,,..FJ
 
 
 	
r(   c                 @   |                                                                 }|                                |d<   |                     |                                |                                ||                                |                                          S )Ns   amend_source)ra  r  r:  r8  r7  )r:  r   r   r  r9  r  r8  r7  )r$   	precursorr:  s      r&   tomemctx_for_amendz$overlayworkingctx.tomemctx_for_amend
  s    !!&&((!*o}}&&((##%%!!!!  
 
 	
r(   c                     || j         v S r    r  r   s     r&   ry  zoverlayworkingctx.isdirty
  s    t{""r(   c                 "    d | _         i | _        d S r    )_mergestaterz  r+   s    r&   rV   zoverlayworkingctx.clean
  s    r(   c           	      r   g }t          j        |                                 |                                                                 t          j        |                                 | j                                                  fg           | j                                        D ]}| j        |         }	 | j        |         }|	                                |d         k    r3|
                                |d         k    r|                    |           o# t          j        $ r Y w xY w|D ]
}| j        |= |S )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.
        rw  r~  )r   prefetchfilesr%   r   ra   
matchfilesrz  r  ro  r  r   rh   r   r   )r$   r  r   cache
underlyings        r&   _compactzoverlayworkingctx._compact
  s:     	IIKK GGIIMMOO&tyy{{DK4D4D4F4FGG	
 	
 	
 K$$&& 	 	DK%E	!-d3
OO%%w77"((**eHo==KK%%%,     	" 	"DD!!s   6ADD'&D'c                     |rT|R| j                             |          pi }|                    d          }|| j        |                                         }|||||d| j         |<   t	          j        | d           d S )Nrw  )rv  rw  r  r~  r  rn  )rz  rZ  ro  r  r   rp  )r$   r   rJ  r  r8  r   rA  oldentrys           r&   r  zoverlayworkingctx._markdirty=
  s      	5dl{t,,2H<<((D|'-2244 
 
D 	 |44444r(   c                 2    t          | j        || |          S )N)r>  r{  )overlayworkingfilectxr"   r  s      r&   rJ   zoverlayworkingctx.filectxR
  s$    $JT7
 
 
 	
r(   Fc                 ^    |s| j         t          j        | j                  | _         | j         S r    )r  r,  memmergestater"   r  s     r&   r   zoverlayworkingctx.mergestateW
  s1     	GD$,,:4:FFDr(   r    r-  NNNNNN)NNr(   Nr  )(r4   r  r  r  r'   rr  r  r  r  rE   r  r   rq   rr   rs   r   r   rm  r  r^  r  r   rH   r  r  r  ri  rV  rJ  rL  r  r  r  ry  rV   r  r  rJ   r   r  r  s   @r&   rk  rk    s            5 5 5L L L L1 1 1   ]   ]G G G
 
 

 
 

 
 

 
 

 
 
  1 1 1
 
 
  	2 	2 	2     
  . . .`
 
 
 
Q Q Q, , ,* * *"* * *- - - <
 <
 <
 <
|	
 	
 	
# # #  # # #L EI5 5 5 5*
 
 
 

               r(   rk  c                        e Zd ZdZd fd	Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd ZddZddZd Z xZS )r  zWrap a ``workingfilectx`` but intercepts all writes into an in-memory
    cache, which can be flushed through later by calling ``flush()``.Nc                     t          t          |                               ||||           || _        || _        || _        d S r    )r   r  r'   r"   _parentr  )r$   r%   r   r{  r>  r  s        r&   r'   zoverlayworkingfilectx.__init__a
  sA    #T**33D$PPP



r(   c                 V    |                                  |                                 k    S r    r  r  s     r&   rk   zoverlayworkingfilectx.cmpg
      yy{{diikk))r(   c                     | j         S r    )r  r+   s    r&   r   zoverlayworkingfilectx.changectxj
  r  r(   c                 @    | j                             | j                  S r    )r  r  r  r+   s    r&   r  zoverlayworkingfilectx.datam
      |  ,,,r(   c                 @    | j                             | j                  S r    )r  r  r  r+   s    r&   r8  zoverlayworkingfilectx.datep
      |$$TZ000r(   c                 *    |                                  S r    )rL  r+   s    r&   rJ  zoverlayworkingfilectx.existss
  s    ||~~r(   c                 @    | j                             | j                  S r    )r  rJ  r  r+   s    r&   rL  zoverlayworkingfilectx.lexistsv
      |""4:...r(   c                 @    | j                             | j                  S r    )r  r  r  r+   s    r&   r  z overlayworkingfilectx.copysourcey
  r  r(   c                 @    | j                             | j                  S r    )r  r  r  r+   s    r&   r  zoverlayworkingfilectx.size|
  r  r(   c                 F    | j                             | j        |           d S r    )r  r^  r  )r$   r  s     r&   r^  z overlayworkingfilectx.markcopied
  s"    
F33333r(   c                     d S r    r@   r+   s    r&   rN  zoverlayworkingfilectx.audit
      r(   c                 @    | j                             | j                  S r    )r  r   r  r+   s    r&   r   zoverlayworkingfilectx.flags
  s    |!!$*---r(   c                 D    | j                             | j        ||          S r    )r  ri  r  )r$   r  r  s      r&   ri  zoverlayworkingfilectx.setflags
  s    |$$TZ@@@r(   Fc                 6     | j         j        | j        ||fi |S r    )r  r  r  r[  s        r&   r  zoverlayworkingfilectx.write
  s%    !t|!$*dEDDVDDDr(   c                 @    | j                             | j                  S r    )r  rV  r  r$   rR  s     r&   rV  zoverlayworkingfilectx.remove
  r  r(   c                     d S r    r@   r+   s    r&   rg  z"overlayworkingfilectx.clearunknown
  r  r(   r  r  )r4   r  r  r  r'   rk   r   r  r8  rJ  rL  r  r  r^  rN  r   ri  r  rV  rg  r  r  s   @r&   r  r  ]
  s;       I I     * * *  - - -1 1 1  / / /1 1 1- - -4 4 4  . . .A A AE E E E/ / / /      r(   r  c                   D     e Zd ZdZ	 d fd	Zd	dZed             Z xZS )
workingcommitctxzA 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.
    r(   Nc                 b    t          t          |                               ||||||           d S r    )r   r  r'   )r$   r%   r   ra  r7  r8  r:  r  s          r&   r'   zworkingcommitctx.__init__
  s?     	%%..$dE7	
 	
 	
 	
 	
r(   Fc           	           |r fd j         D             }ng }t          j        fd j        j        D             fd j        j        D             fd j        j        D             g g g |          S )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.
        c                 &    g | ]}|j         v|S r@   )_changedsetr  s     r&   r\   z4workingcommitctx._dirstatestatus.<locals>.<listcomp>
  s&    LLL1!4;K2K2KQ2K2K2Kr(   c                 *    g | ]} |          |S r@   r@   rY   r   r   s     r&   r\   z4workingcommitctx._dirstatestatus.<locals>.<listcomp>
  s&    :::1q:Q:::r(   c                 *    g | ]} |          |S r@   r@   r  s     r&   r\   z4workingcommitctx._dirstatestatus.<locals>.<listcomp>
  s&    7771eeAhh7Q777r(   c                 *    g | ]} |          |S r@   r@   r  s     r&   r\   z4workingcommitctx._dirstatestatus.<locals>.<listcomp>
  s&    9991a9Q999r(   )rE   r   rQ   r]  rq   rr   rs   )r$   r   rd   rV   rc   s   ``   r&   r  z workingcommitctx._dirstatestatus
  s      	LLLLLLLEEE~::::-:::7777*7779999,999
 
 	
r(   c                     t          | j        j                  }|                    | j        j                   |                    | j        j                   |S )z/Return the set of files changed in this context)re   r]  rq   updaterr   rs   )r$   changeds     r&   r  zworkingcommitctx._changedset
  sI     dl+,,t|)***t|+,,,r(   )r(   NNNr.  )	r4   r  r  r  r'   r  r  r  r  r  s   @r&   r  r  
  s}          DH
 
 
 
 
 

 
 
 
(   ]    r(   r  c                      i  fd}|S )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                 <    |vr | ||          |<   |         S r    r@   )r%   r  r   r  r  s      r&   
getfilectxz(makecachingfilectxfn.<locals>.getfilectx
  s/    u$tVT22E$KT{r(   r@   )r  r  r  s   ` @r&   makecachingfilectxfnr  
  s1     E     
 r(   c                       fd}|S )zGiven a context return a memfilectx for ctx[path]

    This is a convenience method for building a memctx based on another
    context.
    c           	          |         }|                                 }t          | |||                                |                                |                                |          S N)r  r  r  )r  r  r  r  r  )r%   r  r   r  r  r   s        r&   r  z"memfilefromctx.<locals>.getfilectx
  s_    4y__&&
IIKK;;==;;==!
 
 
 	
r(   r@   )r   r  s   ` r&   memfilefromctxr  
  s$    
 
 
 
 
 r(   c                       fd}|S )zGiven a patch (e.g. patchstore object) return a memfilectx

    This is a convenience method for building a memctx based on a patchstore.
    c           	      t                         |          \  }}}|d S |\  }}t          | ||||||          S r  )r  r  )	r%   r  r   r  r  r  r  r  
patchstores	           r&   r  z$memfilefrompatch.<locals>.getfilectx
  s\    !+!3!3D!9!9dJ<4!
 
 
 	
r(   r@   )r  r  s   ` r&   memfilefrompatchr  
  s$    
 
 
 
 
 r(   c                   r     e Zd ZdZdZ	 	 	 	 	 d
 fd	ZddZd Zed             Z	ed             Z
d	 Z xZS )r  aN  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.
    TNc                 R    t          t                                         ||||||	           d  _        d  _         fd|D             }|\  }} fd||fD              _        t          t          |                    }| _        i  _	        t          |t          j                  rt          |          }nt          |          st          |          }t!          |           _        |
r8 |
 j         g            _         j                             j                   d S d S )Nr  c                 6    g | ]}|pj         j        j        S r@   r"  rY   r  r$   s     r&   r\   z#memctx.__init__.<locals>.<listcomp>4  s&    KKKaA818KKKr(   c                 *    g | ]}j         |         S r@   r!   r  s     r&   r\   z#memctx.__init__.<locals>.<listcomp>6  s    9991A999r(   )r   r  r'   r:   r   r   rH  re   _filesr~   r   r   	filestorer  callabler  r  
_filectxfnr"   rY  savecommitmessage)r$   r%   r   ra  r   	filectxfnr7  r8  r:  r  r  r   r   r  s   `            r&   r'   zmemctx.__init__"  sD    	fd$$$dE& 	% 	
 	
 	
 	
KKKK7KKKB9999R999s5zz""i11 	2(33II)$$ 	2&y11I /y99 	5
D"55DJJ((44444	5 	5r(   c                 :    |                      | j        | |          S )zpget a file context from the working directory

        Returns None if file doesn't exist and should be removed.)r  r"   r  s      r&   rJ   zmemctx.filectxH  s     tz4666r(   c                 6    | j                             |           S zcommit context to the repor"   	commitctxr+   s    r&   commitzmemctx.commitN      z##D)))r(   c                 $   | j         d         }|                                                                }| j        j        D ]}| j        j        j        ||<   | j        j        D ]}| j        j        j	        ||<   | j        j
        D ]	}||v r||= 
|S )z;generate a manifest based on the return values of filectxfnr   )r   rP   r   r]  rq   r"   ri   r  rr   r  rs   )r$   r   r  r   s       r&   rE   zmemctx._manifestR  s    
 }Qmmoo""$$& 	= 	=AZ-<CFF# 	: 	:AZ-9CFF% 	 	ACxxF
r(   c           	         |                                                                  | j        d         }|                                t          k    r|                                fd}nfd}g g g }}}| j        D ]V} ||          s|                    |           #| |         r|                    |           A|                    |           Wt          j        |||g g g g           S )z?Calculate exact status from ``files`` specified at constructionr   c                     | v p| v S r    r@   r   man1man2s    r&   r-  z memctx._status.<locals>.<lambda>p      d!7a4i r(   c                     | v S r    r@   r   r  s    r&   r-  z memctx._status.<locals>.<lambda>r      d r(   	r   rP   r   ra   r   r  rh   r   rQ   	r$   r   managingrq   rr   rs   r   r  r  s	          @@r&   r]  zmemctx._statusf  s     wwyy!!##]1 6688w;;==D77777HH****H#%r2% 	" 	"A8A;; "Qa """""q!!!!~hwBBGGGr(   c                 |    | j         d                                         t          k    r| j         d         gS | j         S )Nr   r   )r   ra   r   r+   s    r&   r   zmemctx.parents  s8    =!!W,,M!$%%}r(   )NNNNNr    )r4   r  r  r  _returnnoneformissingfilesr'   rJ   r  r  rE   r]  r   r  r  s   @r&   r  r    s         < "& $5 $5 $5 $5 $5 $5L7 7 7 7* * *   ]& H H ]H0      r(   r  c                   J     e Zd ZdZ	 	 	 d
 fd	Zd Zd Zd ZddZd	 Z	 xZ
S )r  zpmemfilectx represents an in-memory file to commit.

    See memctx and committablefilectx for more details.
    FNc                     t          t          |                               ||d|           || _        |rd| _        n|rd| _        nd| _        || _        dS )aQ  
        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.Nr  r  r(   )r   r  r'   _datar  _copysource)	r$   r%   r   r   r  r  r  r  r  s	           r&   r'   zmemfilectx.__init__  sg    " 	j$((tT9EEE
 	DKK 	DKKDK%r(   c                     | j         S r    )r"  r+   s    r&   r  zmemfilectx.copysource  s    r(   c                 V    |                                  |                                 k    S r    r  r  s     r&   rk   zmemfilectx.cmp  r  r(   c                     | j         S r    r!  r+   s    r&   r  zmemfilectx.data  r   r(   c                      | j         | j        = dS )rQ  N)r  r  r  s     r&   rV  zmemfilectx.remove  s     ODJ'''r(   c                     || _         dS )rX  Nr&  r$   r  r   r\  s       r&   r  zmemfilectx.write  s    


r(   )FFNr  )r4   r  r  r  r'   r  rk   r  rV  r  r  r  s   @r&   r  r    s          & & & & & &6     * * *  ( ( ( (
      r(   r  c                        e Zd ZdZ	 	 	 	 	 	 d
 fd	Zd Zed             ZddZd Z	ed             Z
ed	             Z xZS )metadataonlyctxa  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.
    Nc	                    ||                                 }t          t          |                               ||||           d | _        d | _        || _        |                                | _        ||	                                }nfd|D             }|d d          }t          |          dk     r3|                    t                              t          |          dk     3|x\  }	}
| _        |                                 j	        \  }}|	| j        j        j        k    r'|	                                |k    rt%          d          |
| j        j        j        k    r'|
                                |k    rt%          d          |                                | _        i | _        |r8 || j        | g           | _        | j                            | j                   d S d S )Nc                 $    g | ]}||         S r    r@   )rY   r  r%   s     r&   r\   z,metadataonlyctx.__init__.<locals>.<listcomp>  s    AAA11=tAw===r(   r   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)r9  r   r+  r'   r:   r   _originalctxr?  _manifestnoder   r   rh   r   r   r   r"   ri   r  RuntimeErrorr   r  r~   rY  r  )r$   r%   originalctxr   ra  r7  r8  r:  r  r   r   mp1mp2r  s    `           r&   r'   zmetadataonlyctx.__init__  s    <**,,Dot$$--dD$eLLL	
'(5577?!))++GGAAAAAAAG!!!*'llQNN4=))) 'llQ!((B ##%%-S)000R__5F5F#5M5M0   )000R__5F5F#5M5M7  
 "'')) 	5
D"55DJJ((44444	5 	5r(   c                     | j         S r    )r/  r+   s    r&   r?  zmetadataonlyctx.manifestnode  s    !!r(   c                 0    | j         j        | j                 S r    )r"   r   r/  r+   s    r&   r   zmetadataonlyctx._manifestctx  s    z%d&899r(   c                 :    | j                             ||          S )N)r{  )r.  rJ   r  s      r&   rJ   zmetadataonlyctx.filectx   s     ((w(???r(   c                 6    | j                             |           S r  r  r+   s    r&   r  zmetadataonlyctx.commit  r  r(   c                 4    | j                                         S r    )r.  rP   r+   s    r&   rE   zmetadataonlyctx._manifest  s     ))+++r(   c           	         |                                                                  | j        d         }|                                t          k    r|                                fd}nfd}g g g }}}| j        D ]R} ||          s|                    |           #|| v r|                    |           =|                    |           St          j        |||g g g g           S )zjCalculate exact status from ``files`` specified in the ``origctx``
        and parents manifests.
        r   c                     | v p| v S r    r@   r  s    r&   r-  z)metadataonlyctx._status.<locals>.<lambda>  r  r(   c                     | v S r    r@   r  s    r&   r-  z)metadataonlyctx._status.<locals>.<lambda>  r  r(   r  r  s	          @@r&   r]  zmetadataonlyctx._status  s    
 wwyy!!##]1 6688w;;==D77777HH****H#%r2% 	" 	"A8A;; "Qd""""q!!!!~hwBBGGGr(   r  r    )r4   r  r  r  r'   r?  r  r   rJ   r  rE   r  r]  r  r  s   @r&   r+  r+    s         & .5 .5 .5 .5 .5 .5`" " " : : X:@ @ @ @* * * , , X, H H ]H H H H Hr(   r+  c                   D    e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 ZdS )arbitraryfilectxzAllows you to use filectx-like functions on a file in an arbitrary
    location on disk, possibly not in the working directory.
    Nc                 "    || _         || _        d S r    )r"   r  )r$   r   r%   s      r&   r'   zarbitraryfilectx.__init__,  s    



r(   c                    d|                                  v pd|                                 v }|snt          |t                    rY| j        rRt	          j        |                                 | j                            |                                                     S |                                 |                                k    S r  )	r   r   r  r"   filecmprk   r   wjoinr  )r$   r  symlinkss      r&   rk   zarbitraryfilectx.cmp1  s     4::<<'?44::<<+? 	OJt^<< 	O 	O {499;;
0@0@0M0MNNNNyy{{diikk))r(   c                     | j         S r    r  r+   s    r&   r   zarbitraryfilectx.path<  r   r(   c                     dS r  r@   r+   s    r&   r   zarbitraryfilectx.flags?  s    sr(   c                 4    t          j        | j                  S r    r   readfiler  r+   s    r&   r  zarbitraryfilectx.dataB      }TZ(((r(   c                 4    t          j        | j                  S r    rF  r+   s    r&   rA  zarbitraryfilectx.decodeddataE  rH  r(   c                 8    t          j        | j                   d S r    )r   re  r  r+   s    r&   rV  zarbitraryfilectx.removeH  s    DJr(   c                 B    |rJ t          j        | j        |           d S r    )r   	writefiler  r)  s       r&   r  zarbitraryfilectx.writeK  s(    tz4(((((r(   r    )r4   r  r  r  r'   rk   r   r   r  rA  rV  r  r@   r(   r&   r=  r=  '  s            
	* 	* 	*    ) ) )) ) )     ) ) ) ) )r(   r=  )8r@  r  r  i18nr   r*   r   r   r   pycompatr    r	   r
   r   r   r   r   r   r,  r   r   r   r   r   r   r   r   r   r   r   r   utilsr   r   dirstateutilsr   r  r   r   r  rJ   rW  r  r0  r  rk  r  r  r  r  r  r  r  r+  r=  r@   r(   r&   <module>rR     s    				                
                                          &             "z
 z
 z
 z
 z
 z
 z
 z
zi  i  i  i  i  i  i  i X	B? B? B? B? B? B? B? B?J{
 {
 {
 {
 {
k {
 {
 {
|f f f f fW f f fRR9 R9 R9 R9 R9 R9 R9 R9j= = = = = = = =@Y3 Y3 Y3 Y3 Y3' Y3 Y3 Y3x`  `  `  `  `  `  `  ` F5 5 5 5 5. 5 5 5p) ) ) ) )z ) ) )X  "  .  0A A A A A^ A A AH1 1 1 1 1# 1 1 1hkH kH kH kH kHn kH kH kH\&) &) &) &) &) &) &) &) &) &)r(   