403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /usr/lib64/python3.9/site-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/lib64/python3.9/site-packages/mercurial/__pycache__/context.cpython-39.pyc
a

�+�b��@s�ddlmZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZddlm
Z
ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"ddl#m$Z$m%Z%dd	l&m'Z'e"j(Z(Gd
d�de)�Z*Gdd
�d
e*�Z+Gdd�de)�Z,Gdd�de,�Z-Gdd�de*�Z.Gdd�de.�Z/Gdd�de,�Z0Gdd�de0�Z1Gdd�de.�Z2Gdd�de0�Z3Gdd�de/�Z4d d!�Z5d"d#�Z6d$d%�Z7Gd&d'�d'e.�Z8Gd(d)�d)e0�Z9Gd*d+�d+e.�Z:Gd,d-�d-e)�Z;dS).�)�absolute_importN�)�_)�hex�nullrev�short)�getattr)�dagop�encoding�error�fileset�match�
mergestate�metadata�obsolete�patch�pathutil�phases�pycompat�repoview�scmutil�sparse�subrepo�subrepoutil�util)�dateutil�
stringutil)�	timestampc	@s�eZdZdZdd�Zdd�Ze�e�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zedd��Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zdfd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%d?d@�Z&dAdB�Z'dCdD�Z(dEdF�Z)dGdH�Z*edIdJ��Z+dKdL�Z,dMdN�Z-dgdPdQ�Z.dRdS�Z/dTdU�Z0dhdXdY�Z1didZd[�Z2d\d]�Z3d^d_�Z4djd`da�Z5dkdbdc�Z6ddde�Z7d,S)l�basectxaIA 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.cCs
||_dS�N��_repo��self�repo�r%�7/usr/lib64/python3.9/site-packages/mercurial/context.py�__init__?szbasectx.__init__cCst|���Sr)r�node�r#r%r%r&�	__bytes__Bszbasectx.__bytes__cCsdt|�jt|�fS�Nz<%s %s>��type�__name__�strr)r%r%r&�__repr__Gszbasectx.__repr__cCs8zt|�t|�ko|j|jkWSty2YdS0dS�NF)r-�_rev�AttributeError�r#�otherr%r%r&�__eq__Jszbasectx.__eq__cCs
||kSrr%r4r%r%r&�__ne__Pszbasectx.__ne__cCs
||jvSr��	_manifest�r#�keyr%r%r&�__contains__Sszbasectx.__contains__cCs
|�|�Sr)�filectxr:r%r%r&�__getitem__Vszbasectx.__getitem__cCs
t|j�Sr)�iterr9r)r%r%r&�__iter__Yszbasectx.__iter__cCs|��S)z�Builds 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#�statusr%r%r&�_buildstatusmanifest\szbasectx._buildstatusmanifestcCs|S)zfThis internal method provides a way for child objects to override the
        match operator.
        r%)r#r5r
r%r%r&�_matchstatusbszbasectx._matchstatusc	s�d}|��dur*|��|��kr*|�|�}|�|��|durF|�|�}gg}}	g}
g}|j|j|j}}
}t|���j|�|d�}t�|�D]�\}}|�vr�q�|dur�|�	|�q�|\\}}\}}|dur�|	�	|�q�|dur�|
�	|�q�||k�r|�	|�q�||j
jjv�r |�	|�q�||�
||��r@|�	|�q�|�	|�q�|
�r���fdd�|
D�}
��fdd�|D�}�fdd�|
D�}
t�||	|
||
||�S)z.build a status with respect to another contextN)r
�cleancs$g|]}|�vr�r�|�r|�qSr%r%��.0�fn�r
�mf1r%r&�
<listcomp>�s�z(basectx._buildstatus.<locals>.<listcomp>cs$g|]}|�vr�r�|�r|�qSr%r%rFrIr%r&rK�s�csg|]}|�vr|�qSr%r%rF)�
deletedsetr%r&rK��)�revrC�deleted�unknown�ignored�set�diffrZ	iteritems�appendr!�
nodeconstantsZwdirfilenodeids�cmprrB)r#r5�sr
�listignored�	listclean�listunknownZmf2�modified�added�removedrErOrPrQ�drH�valueZnode1Zflag1Znode2Zflag2r%)rLr
rJr&�_buildstatushsR






���zbasectx._buildstatuscCst�||jj�Sr)r�stater!�uir)r%r%r&�substate�szbasectx.substatecCs|j|dS�Nr)rc�r#�subpathr%r%r&�subrev�szbasectx.subrevcCs|jSr)r2r)r%r%r&rN�szbasectx.revcCs|jSr)�_noder)r%r%r&r(�szbasectx.nodecCst|���Sr)rr(r)r%r%r&r�szbasectx.hexcCs|jSrr8r)r%r%r&rA�szbasectx.manifestcCs|jSr)�_manifestctxr)r%r%r&�manifestctx�szbasectx.manifestctxcCs|jSrr r)r%r%r&r$�szbasectx.repocCstj|��Sr)rZ
phasenames�phaser)r%r%r&�phasestr�szbasectx.phasestrcCs|��tjkSr)rkrZpublicr)r%r%r&�mutable�szbasectx.mutableNcCstj||||d�S)N)�badfn)rr
)r#�cwd�exprrnr%r%r&�matchfileset�szbasectx.matchfilesetcCs|��t�|jd�vS)z!True if the changeset is obsoletesobsolete�rN�obsmodZgetrevsr!r)r%r%r&r�szbasectx.obsoletecCs|��t�|jd�vS)z True if the changeset is extinctsextinctrrr)r%r%r&�extinct�szbasectx.extinctcCs|��t�|jd�vS)z:True if the changeset is not obsolete, but its ancestor is�orphanrrr)r%r%r&�orphan�szbasectx.orphancCs|��t�|jd�vS)z�True if the changeset tries to be a successor of a public changeset

        Only non-public and non-obsolete changesets may be phase-divergent.
        sphasedivergentrrr)r%r%r&�phasedivergent�szbasectx.phasedivergentcCs|��t�|jd�vS)z�Is a successor of a changeset with multiple possible successor sets

        Only non-public and non-obsolete changesets may be content-divergent.
        scontentdivergentrrr)r%r%r&�contentdivergent�szbasectx.contentdivergentcCs|��p|��p|��S)zTTrue if the changeset is either orphan, phase-divergent or
        content-divergent)rvrwrxr)r%r%r&�
isunstable�szbasectx.isunstablecCs>g}|��r|�d�|��r(|�d�|��r:|�d�|S)z�return the list of instabilities affecting this changeset.

        Instabilities are returned as strings. possible values are:
        - orphan,
        - phase-divergent,
        - content-divergent.
        rusphase-divergentscontent-divergent)rvrTrwrx)r#�
instabilitiesr%r%r&rz�s


zbasectx.instabilitiescCs|jS)z)return contexts for each parent changeset��_parentsr)r%r%r&�parents�szbasectx.parentscCs
|jdS�Nrr{r)r%r%r&�p1sz
basectx.p1cCs$|j}t|�dkr|dS|jtS)N�r)r|�lenr!r)r#r}r%r%r&�p2sz
basectx.p2c	Cs�d|jvrDz|j�|�WStyBt�|jp2d|td���Yn0d|jvsZ||��vrz||j	vrz|j	||j	�
|�fS|jj}z||j
j�|�\}}Wn*ty�t�|jp�d|td���Yn0||fS)Nr9sNonesnot found in manifest�_manifestdelta)�__dict__r9�find�KeyErrorr�ManifestLookupErrorrhr�filesr��flagsr!�manifestlog�
_changesetrA)r#�path�mflr(�flagr%r%r&�	_fileinfo	s(
�


��
zbasectx._fileinfocCs|�|�dSr~)r��r#r�r%r%r&�filenode!szbasectx.filenodecCs,z|�|�dWStjy&YdS0dS)NrrM)r�r�LookupErrorr�r%r%r&r�$sz
basectx.flagscCs
t�|�Sr)rZcomputechangesetcopiesr)r%r%r&�_copies*szbasectx._copiescCs
|jdSr~�r�r)r%r%r&�p1copies.szbasectx.p1copiescCs
|jdSrdr�r)r%r%r&�p2copies1szbasectx.p2copiesTcCstj|||d�S)z>return a subrepo for the stored revision of path, never wdir())�allowcreate�r)r#r�r�r%r%r&�sub4szbasectx.subcCst�|||�Sr)rZnullsubrepo)r#r��pctxr%r%r&�nullsub8szbasectx.nullsubcCstj||dd�S)z]return a subrepo for the stored revision, or wdir if this is a wdir
        context.
        T)Z	allowwdirr�r�r%r%r&�
workingsub;szbasectx.workingsub�globFc	Cs4|j}|s|��}tj|j||||||j|||d�
S)N)�auditor�ctx�listsubreposrn)r!�getcwd�matchmodr
�rootZnofsauditor)	r#�pats�include�exclude�defaultr�rnro�rr%r%r&r
As
�z
basectx.matchc


CsD|dur|��}|dur"|j|}tj|j||||||||||	d�S)z;Returns a diff generator for the given contexts and matcherN)r
�changes�opts�
losedatafn�pathfn�copy�copysourcematch�
hunksfilterfn)rr!rrS)
r#�ctx2r
r�r�r�r�r�r�r�r%r%r&rS[s"

�zbasectx.diffcCs
|j��Sr)r9�dirsr)r%r%r&r�zszbasectx.dirscCs|j�|�Sr)r9�hasdir)r#�dirr%r%r&r�}szbasectx.hasdirc	s�|}|j|}d}	t|t�s4t|t�r4d}	||}}|j�|�}|�||�}t�ggggggg�}
|�||
||||�}
|	r�t�|
j|
j	|
j
ggg|
j�}
|�r6t�||�D]�\�}z|�
��}Wnty�d}Yn0t��|�}
|j||
|||dd�}dD]4}t|
|�t||�}}|��fdd�|D���q�q�|
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
rQrErPr�)r[r\r]rOrPrQrEc3s|]}d�|fVqdS)s%s/%sNr%�rG�f�rfr%r&�	<genexpr>�rMz!basectx.status.<locals>.<genexpr>)r!�
isinstance�	changectx�narrowmatchrDrrBr`r[r]r\rEZitersubreposrgr�r�Z
subdirmatcherr�extend�sortrOrPrQ)r#r5r
rXrYrZr�Zctx1r��reversedr�r�Zrev2ZsubmatchrW�kZrfilesZsfilesr%r�r&rB�sT

��
�	






zbasectx.statuscCstd|j��dS)z)Get a mergestate object for this context.z"%s does not implement mergestate()N)�NotImplementedError�	__class__�r#rEr%r%r&r�s�zbasectx.mergestatecCs6t|���dkp2|��|����kp2|��p2|��Srd)r�r}�branchr�closesbranchr�r)r%r%r&�isempty�s���zbasectx.isempty)N)T)NNNr�FNN)	NNNNNNNNN)NNFFFF)F)8r.�
__module__�__qualname__�__doc__r'r*r
�	strmethod�__str__r0r6r7r<r>r@rCrDr`�
propertycachercrgrNr(rrArjr$rlrmrqrrtrvrwrxryrzr}rr�r�r�r�r�r�r�r�r�r�r
rSr�r�rBrr�r%r%r%r&r7s�
B



�
�
�
e
rcsVeZdZdZdK�fdd�	Zdd�Zdd�ZeZed	d
��Z	edd��Z
ed
d��Zedd��Z
edd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Ze�fd#d$��Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Z d7d8�Z!d9d:�Z"d;d<�Z#d=d>�Z$dLd@dA�Z%dMdCdD�Z&dEdF�Z'dGdH�Z(dIdJ�Z)�Z*S)Nr�z�A changecontext object makes access to data related to a particular
    changeset convenient. It represents a read-only context already present in
    the repo.Tcs&tt|��|�||_||_||_dSr)�superr�r'r2rh�_maybe_filtered)r#r$rNr(�maybe_filtered�r�r%r&r'�szchangectx.__init__cCs,zt|j�WSty&t|�YS0dSr)�hashr2r3�idr)r%r%r&�__hash__szchangectx.__hash__cCs
|jtkSr)r2rr)r%r%r&�__nonzero__szchangectx.__nonzero__cCs(|jr|j}n
|j��}|j�|���Sr)r�r!�
unfiltered�	changelogZchangelogrevisionrNr"r%r%r&r�s
zchangectx._changesetcCs
|j��Sr)ri�readr)r%r%r&r9szchangectx._manifestcCs|jj|jjSr)r!r�r�rAr)r%r%r&riszchangectx._manifestctxcCs
|j��Sr)riZ	readdeltar)r%r%r&r� szchangectx._manifestdeltacCsz|j}|jr|j}n
|��j}|�|j�\}}|tkrNt|||�|�dd�gSt|||�|�dd�t|||�|�dd�gS)NF�r�)	r!r�r�r�Z
parentrevsr2rr�r()r#r$�clrr�r%r%r&r|$s
�zchangectx._parentscCs"|j}|j|j|j|j|j|jfSr)r�rA�user�dater��description�extra�r#�cr%r%r&�	changeset4s�zchangectx.changesetcCs|jjSr)r�rAr)r%r%r&�manifestnode?szchangectx.manifestnodecCs|jjSr)r�r�r)r%r%r&r�Bszchangectx.usercCs|jjSr)r�r�r)r%r%r&r�Eszchangectx.datecCs|jjSr)r�r�r)r%r%r&r�Hszchangectx.filescCs0t|���}|�|���|�|���t|�Sr)rRr��difference_update�
filesadded�filesremoved�sorted)r#r[r%r%r&�
filesmodifiedKszchangectx.filesmodifiedcCsh|jj}d}|jjdkrd}n*|jj�dd�}|dkr<d}n|dkrHd}|durd|r`t�|�}ng}|S�NTschangeset-sidedataF�experimentalscopies.read-fromschangeset-onlys
compatibility)r�r�r!�filecopiesmoderb�configrZcomputechangesetfilesadded)r#r��compute_on_none�sourcer%r%r&r�Qszchangectx.filesaddedcCsh|jj}d}|jjdkrd}n*|jj�dd�}|dkr<d}n|dkrHd}|durd|r`t�|�}ng}|Sr�)r�r�r!r�rbr�rZcomputechangesetfilesremoved)r#r�r�r�r%r%r&r�dszchangectx.filesremovedcs�|jj}|jj}d}|jjdkr&d}n.|jj�dd�}|dkrDd}n|dkrTd}}|dur~|rrtt|�j	\}}n|dur~i}|dur�i}||fSr�)
r�r�r�r!r�rbr�r�r�r�)r#r�r�r�r�r�r%r&r�ws$zchangectx._copiescCs|jjSr)r�r�r)r%r%r&r��szchangectx.descriptioncCst�|jj�d��S�N�branch)r
�tolocalr�r��getr)r%r%r&r��szchangectx.branchcCsd|jjvS�Nsclose�r�r�r)r%r%r&r��szchangectx.closesbranchcCs|jjS)z#Return a dict of extra information.r�r)r%r%r&r��szchangectx.extracCs|j�|j�S)zReturn a list of byte tag names)r!Znodetagsrhr)r%r%r&�tags�szchangectx.tagscCs|j�|j�S)z%Return a list of byte bookmark names.)r!Z
nodebookmarksrhr)r%r%r&�	bookmarks�szchangectx.bookmarkscCs*|j}|jr|j}n
|��j}|�|j�Sr)r!r�r�r��	fast_rankr2)r#r$r�r%r%r&r��s

zchangectx.fast_rankcCs|jj�|j|j�Sr)r!Z_phasecacherkr2r)r%r%r&rk�szchangectx.phasecCs|jt�|jd�vS)Nsvisible)r2rZ
filterrevsr!r)r%r%r&�hidden�szchangectx.hiddencCsdSr1r%r)r%r%r&�
isinmemory�szchangectx.isinmemorycs"�jj��j�}�fdd�|D�S)z�return list of changectx contexts for each child changeset.

        This returns only the immediate child changesets. Use descendants() to
        recursively walk children.
        csg|]}�j|�qSr%r �rG�xr)r%r&rK�rMz&changectx.children.<locals>.<listcomp>)r!r��childrenrhr�r%r)r&r��szchangectx.childrenccs(|jj�|jg�D]}|j|VqdSr)r!r��	ancestorsr2)r#�ar%r%r&r��szchangectx.ancestorsccs(|jj�|jg�D]}|j|VqdS)zrRecursively yield all children of the changeset.

        For just the immediate children, use children()
        N)r!r��descendantsr2)r#r^r%r%r&r��szchangectx.descendantsNcCs&|dur|�|�}t|j||||d�S)z&get a file context from this changesetN)�fileidr��filelog)r�r=r!)r#r�r�r�r%r%r&r=�s

�zchangectx.filectxFc	s|j}|dur|jdj}|jj�|j|�}|s<|jjj�n�t|�dkrR|d�n�|jj�	dd�D]D}zt
�|j|�}Wntj
y�YqbYn0|����|vrbq�qb|jj�|j|��|�r|jj�td�t��t|j�t|�fd��fdd	�t|�D���|j�S)
z�return 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.Nrrsmergespreferancestors(note: using %s as ancestor of %s and %s
rMc3s&|]}|�krtd�t|�VqdS)s:      alternatively, use --config merge.preferancestor=%s
N)rr�rG�n�Zancr%r&r��s���z%changectx.ancestor.<locals>.<genexpr>)rhr|r!r�ZcommonancestorsheadsrU�nullidr�rbZ
configlistrZ	revsymbolrZRepoLookupErrorr(�ancestorrBrr�joinr�)r#�c2�warnZn2Zcahsr�r�r%rr&r�s8

����zchangectx.ancestorcCs|jj�|j|j�S)z.True if this changeset is an ancestor of other)r!r�Z
isancestorrevr2r4r%r%r&�isancestorof
szchangectx.isancestorofcs.��fdd�}t��j���|�}�j�|�S)�Generates matching file names.cs4t�fdd��jD��rdS���td���dS)Nc3s$|]}�|kp��|d�VqdS)�/N)�
startswith)rGrW�rHr%r&r�rMz.changectx.walk.<locals>.bad.<locals>.<genexpr>sno such file in rev %s)�anyrc�badr)rH�msg�r
r#r
r&rszchangectx.walk.<locals>.bad)r�Zbadmatchr!r�r9�walk)r#r
r�mr%rr&rszchangectx.walkcCs
|�|�Sr)r�r#r
r%r%r&�matchesszchangectx.matches)T)NN)F)+r.r�r�r�r'r�r��__bool__r�r�r9�propertyrir�r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rkr�r�r�r�r�r=rrrr�
__classcell__r%r%r�r&r��sV




"	

-r�c@s�eZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dd
�Z
e
Zdd�Ze
�e�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zedd��Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z d2d3�Z!d4d5�Z"d6d7�Z#d8d9�Z$d:d;�Z%d<d=�Z&d>d?�Z'd@dA�Z(dBdC�Z)dDdE�Z*dFdG�Z+dHdI�Z,dJdK�Z-dLdM�Z.dNdO�Z/dPdQ�Z0dRdS�Z1dTZ2dUdV�Z3dpdXdY�Z4dZd[�Z5d\d]�Z6dqd^d_�Z7d`da�Z8dbdc�Z9ddde�Z:dfdg�Z;dhdi�Z<drdjdk�Z=dsdldm�Z>dndo�Z?dWS)t�basefilectxaPA 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,
    cCs|j�|j�Sr)r!�file�_pathr)r%r%r&�_filelog)szbasefilectx._filelogcCs<d|jvr|j��Sd|jvr*|�|j�S|j�|j�SdS)N�
_changectx�_descendantrev)r�rrN�_adjustlinkrevrr�linkrev�_filerevr)r%r%r&�	_changeid-s



zbasefilectx._changeidcCs*d|jvr|j�|j�S|j�|j�SdS)N�_fileid)r�r�lookupr rr�rr)r%r%r&�	_filenode8s
zbasefilectx._filenodecCs|j�|j�Sr)rrNr"r)r%r%r&r?szbasefilectx._filerevcCs|jSr�rr)r%r%r&�	_repopathCszbasefilectx._repopathcCs(z|jWdStjy"YdS0dS�NTF)r"rr�r)r%r%r&r�Gs
zbasefilectx.__nonzero__cCs:zd|��|jfWStjy4d|��YS0dS)Ns%s@%ss%s@???)r�rrr�r)r%r%r&r*Qszbasefilectx.__bytes__cCsdt|�jt|�fSr+r,r)r%r%r&r0Yszbasefilectx.__repr__cCs2zt|j|jf�WSty,t|�YS0dSr)r�rr"r3r�r)r%r%r&r�\szbasefilectx.__hash__cCsDz*t|�t|�ko(|j|jko(|j|jkWSty>YdS0dSr1)r-rr"r3r4r%r%r&r6bs
�
�zbasefilectx.__eq__cCs
||kSrr%r4r%r%r&r7lszbasefilectx.__ne__cCs|jSr)rr)r%r%r&�filerevoszbasefilectx.filerevcCs|jSr)r"r)r%r%r&r�rszbasefilectx.filenodecCs|j�|j�Sr)rr�rr)r%r%r&�_flagsuszbasefilectx._flagscCs|jSr)r'r)r%r%r&r�yszbasefilectx.flagscCs|jSr)rr)r%r%r&r�|szbasefilectx.filelogcCs|jSr)rr)r%r%r&rNszbasefilectx.revcCs|j�|j�Sr)rrrr)r%r%r&r�szbasefilectx.linkrevcCs
|j��Sr)rr(r)r%r%r&r(�szbasefilectx.nodecCs
|j��Sr)rrr)r%r%r&r�szbasefilectx.hexcCs
|j��Sr)rr�r)r%r%r&r��szbasefilectx.usercCs
|j��Sr)rr�r)r%r%r&r��szbasefilectx.datecCs
|j��Sr)rr�r)r%r%r&r��szbasefilectx.filescCs
|j��Sr)rr�r)r%r%r&r��szbasefilectx.descriptioncCs
|j��Sr)rr�r)r%r%r&r��szbasefilectx.branchcCs
|j��Sr)rr�r)r%r%r&r��szbasefilectx.extracCs
|j��Sr)rrkr)r%r%r&rk�szbasefilectx.phasecCs
|j��Sr)rrlr)r%r%r&rl�szbasefilectx.phasestrcCs
|j��Sr)rrr)r%r%r&r�szbasefilectx.obsoletecCs
|j��Sr)rrzr)r%r%r&rz�szbasefilectx.instabilitiescCs
|j��Sr)rrAr)r%r%r&rA�szbasefilectx.manifestcCs|jSr)rr)r%r%r&r��szbasefilectx.changectxcCs|jSr��_copiedr)r%r%r&�renamed�szbasefilectx.renamedcCs|jo|jdSr~r(r)r%r%r&�
copysource�szbasefilectx.copysourcecCs|jSrr r)r%r%r&r$�szbasefilectx.repocCst|���Sr)r��datar)r%r%r&�size�szbasefilectx.sizecCs|jSrr#r)r%r%r&r��szbasefilectx.pathcCs*zt�|���WSty$YdS0dSr1)r�binaryr,�IOErrorr)r%r%r&�isbinary�szbasefilectx.isbinarycCsd|��vS)N�x�r�r)r%r%r&�isexec�szbasefilectx.isexeccCsd|��vS�N�lr2r)r%r%r&�islink�szbasefilectx.islinkcCsdS)z�whether 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)r%r%r&�isabsent�szbasefilectx.isabsentFcCs�|jr|�|�S|jdur$t�d��|jdurr|jjrJ|j�|j|���S|�	�d|�	�krr|j�|j|���S|�	�|�	�ks�|�
�dkr�|j�|j|���SdS)�Vcompare with other file context

        returns True if different than fctx.
        Ns;filectx.cmp() must be reimplemented if not backed by revlog�r5T)�
_customcmprVr"r�ProgrammingErrorr!Z_encodefilterpatsrr,r-r��r#�fctxr%r%r&rV�s

�
zbasefilectx.cmpNcCs|j}|��j}|j}|��}||kr*|St|dd�}d}	|dur`dd�|jd��D�}
d}n|g}
|dur�|j|
||d�}}	||v�r|	dur�|j|
||d�}	|j}|j	}|	D]R}
|dur�|
|kr�dS|�
|
�}||dvr�|||d���|�kr�|
Sq�|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.
        �_ancestrycontextNcSsg|]}|���qSr%�rN�rG�pr%r%r&rKrMz.basefilectx._adjustlinkrev.<locals>.<listcomp>T��	inclusive�r)
r!r�r�r�rrr}r�r"rr�Zreadfastr�)r#ZsrcrevrC�stoprevr$r�r�ZlkrZ	memberancZiterancZrevs�fnoder�r��acr%r%r&r�s6



zbasefilectx._adjustlinkrevcCs0|��|krdS|j|d�}|dur(dS||kS)zBTrue if a filectx has been introduced after a given floor revisionT�rENF)r�	_introrev)r#Zchangelogrev�introrevr%r%r&�isintroducedafter'szbasefilectx.isintroducedaftercCs|��S)areturn 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.
        )rIr)r%r%r&rJ0s	zbasefilectx.introrevcCs|d}t|�}d|vr|j}nd|vr.|j��}|durF|j|d|d�Sd|vrp|j|j|d�}|durl||_|S|��SdS)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.
        NrrT)rCrErrH)�varsrrrNrrr)r#rEZtoprev�attrsrJr%r%r&rI;s	
zbasefilectx._introrevcCs*|��}|��|kr|S|j|��|d�S)zzReturn filectx having identical contents, but pointing to the
        changeset revision where this filectx was introduced)�changeid)rJrNr=r�)r#rJr%r%r&�introfilectxXszbasefilectx.introfilectxcCsjt|j|||d�}dt|�vs*dt|�vrD|��|_t|dd�|_n"dt|�vrf|j|_t|dd�|_|S)z@create parent filectx keeping ancestry info for _adjustlinkrev()�r�r�rrr>Nr)r=r!rLrNrrr>)r#r�r�r�r=r%r%r&�_parentfilectx`s
zbasefilectx._parentfilectxc	sx�j��j��j��j�}���fdd�|D�}���j�}|rf|�d|d|d�j�|d�f��fdd�|D�S)Ncs$g|]}|�jjjkr�|�f�qSr%�r!rUr)rGr(�r�flr#r%r&rKts�z'basefilectx.parents.<locals>.<listcomp>rrcs g|]\}}}��|||��qSr%)rQ)rGr�rF�lr)r%r&rK�rM)rrr}r"r*�insertr!r)r#r}�plr�r%rSr&r}ps�	&zbasefilectx.parentscCs|��dSr~)r}r)r%r%r&r�szbasefilectx.p1cCs2|��}t|�dkr|dSt|j|jd|jd�S)Nr�r���rP)r}r�r=r!rr�r#rAr%r%r&r��szbasefilectx.p2cs�t��fdd�����fdd�}���}t|dd�dur��j��j}|��durn|jdd�|�	�D�d	d
�}n|j|��gd	d
�}||_
tj||||d�S)aDReturns 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)
        cs�j�|�Sr)r!r)r�r)r%r&�<lambda>�rMz&basefilectx.annotate.<locals>.<lambda>csJ�j���}�s$�fdd�|D�}|D]}d|jvr(�|���|_q(|S)Ncs g|]}|�����kr|�qSr%�r�r@�r�r%r&rK�rMz9basefilectx.annotate.<locals>.parents.<locals>.<listcomp>r)rr}r�r�r)r�rWrA)�follow�getlogr\r&r}�s
z%basefilectx.annotate.<locals>.parentsr>NcSsg|]}|���qSr%r?r@r%r%r&rK�rMz(basefilectx.annotate.<locals>.<listcomp>TrB)�skiprevs�diffopts)
rZlrucachefuncrOrr!r�r�rNr�r}r>r	�annotate)r#r]r_r`r}�baser�rGr%)r]r^r#r&ra�s��zbasefilectx.annotateccs`i}|}|rd}nd}|��d|�D]}|||��|��f<q&|sFq\|�t|��}|VqdSrd)r}rr��pop�max)r#ZfollowfirstZvisitr�Zcut�parentr%r%r&r��szbasefilectx.ancestorscCs|j�|��|���S)z�Returns `data()` after running repository decoding filters.

        This is often equivalent to how the data would be expressed on disk.
        )r!Z
wwritedatar�r,r)r%r%r&�decodeddata�szbasefilectx.decodeddata)FN)N)FNN)F)@r.r�r�r�r�rrr"rr$r�rr*r
r�r�r0r�r6r7r&r�r'r�r�rNrr(rr�r�r�r�r�r�rkrlrrzrAr�r*r+r$r-r�r0r3r6r7r:rVrrKrJrIrOrQr}rr�rar�rfr%r%r%r&r s�









5	

2
rc@sdeZdZdZddd�Zedd��Zddd�Zd	d
�Zdd�Z	d
d�Z
dd�Zedd��Zdd�Z
dS)r=z^A filecontext object makes access to data related to a particular
    filerevision convenient.NcCsr||_||_|dus6|dus6|dus6Jd|||f��|durD||_|durR||_|dur`||_|durn||_dS)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!rrrrr )r#r$r�rNr�r�r�r%r%r&r'�s,�����zfilectx.__init__cCs8z|j|jWStjy2|j��|jYS0dSr)r!rrZFilteredRepoLookupErrorr�r)r%r%r&r�szfilectx._changectxcCst|j|j||j|d�S)zMopens an arbitrary revision of the file without
        opening a new filelog)r�r�rN�r=r!rr)r#r�rNr%r%r&r=s�zfilectx.filectxcCs|j�|j�Sr)r�rawdatar"r)r%r%r&rh!szfilectx.rawdatacCs|j�|j�S)zlow-level revlog flags)rr�rr)r%r%r&�rawflags$szfilectx.rawflagscCsdz|j�|j�WStjy^|jj�dd�dkr:YdStjt	d�t
|j�t	d�d��Yn0dS)NscensorspolicysignorerMscensored node: %ss"set censor.policy to ignore errors)�hint)rr�r"rZCensoredNodeErrorr!rbr��Abortrrr)r%r%r&r,(s�zfilectx.datacCs|j�|j�Sr)rr-rr)r%r%r&r-3szfilectx.sizec	Cs||j�|j�}|sdS|��|��kr*|S|��}|j}|j��D]4}z||�|�kr^WdSWqBt	j
ytYqB0qB|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)rr*r"rNrr�rr}r�rr�)r#r*�namerFrAr%r%r&r)6s	zfilectx._copiedcs �j��j�}�fdd�|D�S)Ncs"g|]}t�j�j|�jd��qS�rPrgr�r)r%r&rKSs�z$filectx.children.<locals>.<listcomp>)rr�r"r�r%r)r&r�Ps
�zfilectx.children)NNNN)N)r.r�r�r�r'r�rr=rhrir,r-r)r�r%r%r%r&r=�s �
 


r=cs:eZdZdZdD�fdd�	Zdd�Zdd	�Ze�e�Z	d
d�Z
e
Zedd
��Z
edd��Zedd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZeZeZeZd&d'�Zd(d)�Zd*d+�Zd,d-�Z d.d/�Z!d0d1�Z"d2d3�Z#d4d5�Z$d6d7�Z%d8d9�Z&d:d;�Z'd<d=�Z(d>d?�Z)dEdBdC�Z*�Z+S)F�committablectxz�A committablectx object provides common functionality for a context that
    wants the ability to commit, e.g. workingctx or memctx.rMNcs�tt|��|�d|_d|_||_|r2t�|�|_|r<||_	|rF||_
i|_|rZ|��|_|durrt
�|�|jd<|j�d�s�d|jd<dS)Nr�sdefault)r�rnr'r2rh�_textrZ	parsedate�_date�_user�_status�_extrar�r
Z	fromlocalr��r#r$�textr�r�r�r�r�r�r%r&r']s"

zcommittablectx.__init__cCst|jd�dS)Nr�+)�bytesr|r)r%r%r&r*zszcommittablectx.__bytes__cCs|jjjdSr�r!rUZwdirhexr)r%r%r&r}szcommittablectx.hexcCsdS�NTr%r)r%r%r&r��szcommittablectx.__nonzero__cCs
|j��Sr)r!rBr)r%r%r&rr�szcommittablectx._statuscCs|jj��Sr)r!rb�usernamer)r%r%r&rq�szcommittablectx._usercCs(|jj}|�dd�}|dur$t��}|S)Nsdevelsdefault-date)r!rbZ
configdater�makedate)r#rbr�r%r%r&rp�s
zcommittablectx._datecCsdSrr%rer%r%r&rg�szcommittablectx.subrevcCsdSrr%r)r%r%r&r��szcommittablectx.manifestnodecCs|jp|jj��Sr)rqr!rbrzr)r%r%r&r��szcommittablectx.usercCs|jSr)rpr)r%r%r&r��szcommittablectx.datecCs|jSr)ror)r%r%r&r��szcommittablectx.descriptioncCst|jj|jj|jj�Sr)r�rrr[r\r]r)r%r%r&r��s�zcommittablectx.filescCs|jjSr)rrr[r)r%r%r&r[�szcommittablectx.modifiedcCs|jjSr)rrr\r)r%r%r&r\�szcommittablectx.addedcCs|jjSr)rrr]r)r%r%r&r]�szcommittablectx.removedcCs|jjSr)rrrOr)r%r%r&rO�szcommittablectx.deletedcCst�|jd�Sr�)r
r�rsr)r%r%r&r��szcommittablectx.branchcCs
d|jvSr��rsr)r%r%r&r��szcommittablectx.closesbranchcCs|jSrr|r)r%r%r&r��szcommittablectx.extracCsdSr1r%r)r%r%r&r��szcommittablectx.isinmemorycCsgSrr%r)r%r%r&r��szcommittablectx.tagscCs$g}|��D]}|�|���q|Sr)r}r�r�)r#�brAr%r%r&r��szcommittablectx.bookmarkscCs.t�|jj�}|��D]}t||���}q|Sr)rZnewcommitphaser!rbr}rdrk)r#rkrAr%r%r&rk�szcommittablectx.phasecCsdSr1r%r)r%r%r&r��szcommittablectx.hiddencCsgSrr%r)r%r%r&r��szcommittablectx.childrencCsTd|jvr.z|j�|�WSty,YdS0z|�|�WStyNYdS0dS)Nr9rM)r�r9r�r��	_flagfunc�OSErrorr�r%r%r&r��s
zcommittablectx.flagscCs|jd�|�S)z1return the "best" ancestor context of self and c2r)r|r)r#rr%r%r&r�szcommittablectx.ancestorccsB|jD]
}|Vq|jj�dd�|jD��D]}|j|Vq,dS)NcSsg|]}|���qSr%r?r@r%r%r&rK�rMz,committablectx.ancestors.<locals>.<listcomp>)r|r!r�r�)r#rAr�r%r%r&r��s
�zcommittablectx.ancestorscCsdS)aQPerform 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(r%r%r&�
markcommitted�szcommittablectx.markcommittedFTcCsdSr1r%)r#�missing�merger�r%r%r&�dirty�szcommittablectx.dirty)rMNNNNN)FTT),r.r�r�r�r'r*rr
r�r�r�rr�rrrqrprgr�r�r�r�r�r[r\r]rOr�r�r�r�r�r�r�r�r�rkr�r�r�rr�r�r�rr%r%r�r&rnYs\�




rncs*eZdZdZdA�fdd�	Zdd�Zdd	�Zd
d�Zedd
��Z	dBdd�Z
�fdd�Zdd�Zedd��Z
dd�ZdCdd�ZdDdd�ZdEdd�ZdFd d!�Zd"d#�ZdGd%d&�Zd'd(�Zd)d*�Zd+d,�ZdHd-d.�Zed/d0��Zed1d2��Zd3d4�Z�fd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z dId?d@�Z!�Z"S)J�
workingctxayA 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.
    rMNc	sbd}|rd|vr@z|j��}Wn ty>t�td���Yn0tt|�j|||||||d�dS)Nr�sbranch name not in UTF-8!�r�)	�dirstater��UnicodeDecodeErrorrrkrr�r�r'rtr�r%r&r's
�zworkingctx.__init__ccs(|jj}|D]}|�|�jr|VqdSr�r!r��	get_entry�tracked)r#r^r�r%r%r&r@szworkingctx.__iter__cCs|jj�|�jSrr�r:r%r%r&r<szworkingctx.__contains__cCs
|jjjSrrxr)r%r%r&r"szworkingctx.hexcsH�jj��}|d�jjjkr*|dd�}�j�����fdd�|D�S)NrrXcs&g|]}t�j�j�|�|dd��qS)Fr�)r�r!r�rNr��r#Zunfir%r&rK,s��z'workingctx._parents.<locals>.<listcomp>)r!r�r}rUrr�rYr%r�r&r|%s
�zworkingctx._parentscCs�|dur|jjj}|jj}|����|�||�}|j|}|rl|D](}||vrB|||vrB|�|||�qB||jjjkr�t|���	��D]$\}}||vr�||vr�|�d|�q�Wd�n1s�0YdSr)
r!rUrr��parentchange�
setparentsr�r��copies�items)r#�p1node�p2noder�r�r�r�rWr%r%r&r�3s


zworkingctx.setparentscs|jtt|��|�Sr)r9r�r�r�r�r�r%r&r�Fszworkingctx._fileinfocs�|jj��j�|��}t|�dkr>|d�����fdd�}n@|\}}|�|�}|��|��|���������fdd�}|S)Nr�rcs�||�}��|�Srr2r\)�	copiesget�manr%r&�funcUs
z'workingctx._buildflagfunc.<locals>.funccsT�||�}��|���|���|�}}}||kr8|S||krD|S||krP|SdS�NrMr2)r�Zfl1Zfl2Zfla)r��m1�m2�mar%r&r�`s
")r!r�r�r�r}r�rAr)r#r}r�rr��par%)r�r�r�r�r�r&�_buildflagfuncKs
zworkingctx._buildflagfunccCs|jj�|j�Sr)r!r�Zflagfuncr�r)r%r%r&r~mszworkingctx._flagfunccCs&z|�|�WSty YdS0dSr�)r~rr�r%r%r&r�qszworkingctx.flagscCst|j|||d�S)z-get a file context from the working directory)r�r�)�workingfilectxr!�r#r�r�r%r%r&r=ws
�zworkingctx.filectxFTcCspt|j�D]}|�|�j|d�r
dSq
|r4|��pn|rL|��|����kpn|��pn|��pn|�	�pn|on|�
�S)z-check whether a working directory is modified)r�T)r�rcr�r�r�r�rr[r\r]rO)r#r�r�r�rWr%r%r&r�}s����
�zworkingctx.dirtyc

sl|j����J|jj|jj}���fdd�}g}|jjj}|D�]}t�|tj	�
�|��z||�}Wn6ty�|�t
d�||��|�|�Yq@Yn0|�dd�}	|	dkr�|j|	kr�|�t
d�|d|jd	||�f�t�|j��s"t�|j��s"|�t
d
�||��|�|�q@��|�s@|�t
d�||��q@|Wd�S1�s^0YdS)Ncs��t��|��Sr��pathtorrr\��ds�prefixr%r&rZ�rMz workingctx.add.<locals>.<lambda>�%s does not exist!
suislarge-file-limitrso%s: up to %d MB of RAM may be required to manage this file
(use 'hg revert %s' to cancel the pending addition)
rDi@Bs:%s not added: only files and symlinks supported currently
s%s already tracked!
)r!�wlockrbr��wvfs�lstatrZ
checkportable�osr�rrrrrTZconfigbytes�st_size�stat�S_ISREG�st_mode�S_ISLNK�set_tracked)
r#�listr�rb�uipath�rejectedr�r��st�limitr%r�r&�add�sD



���	���
zworkingctx.addcs�|j���f|jj���fdd�}g}|D]2}��|�s*|jj�td�||��|�|�q*|Wd�S1sv0YdS)Ncs��t��|��Srr�r\r�r%r&rZ�rMz#workingctx.forget.<locals>.<lambda>s%s not tracked!
)r!r�r�Z
set_untrackedrbrrrT)r#r�r�r�r�r�r%r�r&�forget�s
zworkingctx.forgetc
Cs�z|jj�|�}WnTtyf}z<|jtjkr0�|jj�td�|jj	�
|��WYd}~dSd}~00t�|j
�s�t�|j
�s�|jj�td�|jj	�
|��nH|j���.|jj	}|�|�|�||�Wd�n1s�0YdS)Nr�s1copy failed: %s is not a file or a symbolic link
)r!r�r�r�errno�ENOENTrbrrr�r�r�r�r�r�r�r�r�)r#r��destr��errr�r%r%r&r��s&���
zworkingctx.copyr�c

CsD|j}|s|��}t�|j�}	tj|j||||||j||||	d�S)N)r�r�r�rn�icasefs)r!r�rZfscasesensitiver�r�r
r�)
r#r�r�r�r�r�rnror�r�r%r%r&r
�s"
�zworkingctx.matchcCs�|r|jjjr|Sg}|D]b}|�|�dkrr||��}|dks^t|�dks^d|vs^t�|�rr|jj�	d|�q|�
|�q|S)Nr5rMi�
s*ignoring suspect symlink placeholder "%s"
)r!r�Z
_checklinkr�r,r�rr.rb�debugrT)r#r�Zsaner�r^r%r%r&�_filtersuspectsymlink�s(�
����z workingctx._filtersuspectsymlinkc
Cs|sggggfSg}g}g}g}|jd}t|�D]�}z�||vsf|�|�|�|�ksf||�||�rr|�|�nd|dur�|�|�nP||��}	|	j}
|	j}t�	|	|�}|dur�|
||f}
|�||
f�n
|�|�Wq2t
tfy�|�|�Yq20q2||||fSr~)r|r�r�rVrTr�r�r�rZreliable_mtime_ofr/r)r#r��mtime_boundaryr[rOrE�fixupr�r�rW�moder-Z
file_mtime�
cache_infor%r%r&�_checklookups:
���
zworkingctx._checklookupc
s|j��}|s|s|jjj�rz�z�|jj��}|j�d���|jj����|kr�|r����rj�fdd�}n�j}|D]\}}|||�qt|j��}|jj�	|�|r�|D]}	|	||�q�n|jj
�d�Wd�n1s�0YWntj
y�Yn0W|j��n|j��0dS)z1update dirstate for files that are actually cleanFcs�j|ddd�S)NT�Z
p1_trackedZ
wc_tracked)�update_file)r�Zpfd�r�r%r&rZJs�z-workingctx._poststatusfixup.<locals>.<lambda>s*skip updating dirstate: identity mismatch
N)r!Zpostdsstatusr��_dirty�identityr�ZpendingparentchangeZ	set_clean�currenttransaction�writerbr�rZ	LockErrorZclearpostdsstatus)
r#rBr�Z
poststatusZoldidZnormalr�Zpdf�trZpsr%r�r&�_poststatusfixup:s0

�&zworkingctx._poststatusfixupc
	Cs�g}d|vrt|j�}|jjj|||||d�\}}}g}	|r�|�||�\}
}}}	|j�|
�|j�|�|r||r||j	�|�|	r�|r�|j	�dd�|	D��|�
||	�|��r�|js�|j
s�|j	r�t�|j|j|j|jggg�|_n||_|S)z7Gets the status from the dirstate -- internal use only.s.hgsub)rQrErPcss|]\}}|VqdSrr%)rGr�rr%r%r&r�~rMz-workingctx._dirstatestatus.<locals>.<genexpr>)r�rcr!r�rBr�r[r�rOrEr��alwaysrPrQrr\r]rr)
r#r
rQrErP�subreposrVrWr�r�Z	modified2Zdeleted2Z	clean_setr%r%r&�_dirstatestatusis2

���zworkingctx._dirstatestatusc
Cs�i}i}|jj��}|j|d��}|j|d��}t|���t|���B}|j��}|jj���	�D]<\}}	||vsj||�s�qj|	|vr�|	||<qj|	|vrj|	||<qj||fS)Nrr)
r!r�r}rArRr\r[r�r�r�)
r#r�r�r}Z
p1manifestZ
p2manifestZ
changedsetr��dst�srcr%r%r&r��s


zworkingctx._copiescCs|�|j�S)aLgenerate 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.
        )rCrrr)r%r%r&r9�s	zworkingctx._manifestc
Cs�|��}|d����}|j}|jjj|jf|jjj|j	ffD]B\}}|D]4}|||<z|�
|||��WqJty|YqJ0qJq>|j|j
D]}||vr�||=q�|S)z9Builds a manifest that includes the given status results.r)r}rAr�r~r!rU�addednodeidr\�modifiednodeidr[�setflagrrOr])r#rBr}r�Zff�irUr�r%r%r&rC�s �
zworkingctx._buildstatusmanifestcsR|�||||�}|�|j�|jdd�<||jdkrNtt|��||||||�}|S)aCbuild 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�r[r!r�r�r`)r#r5rWr
rXrYrZr�r%r&r`�s

�zworkingctx._buildstatuscs&��jdkr"��fdd�}||_|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�cs6|�vr2��|�s2�jj�d�jj�|�|f�dS)Ns%s: %s
)r�r!rbrr�r�)r�r
�r5r#r%r&r�s�z$workingctx._matchstatus.<locals>.bad)r!r)r#r5r
rr%r�r&rD�s
zworkingctx._matchstatuscCs(t|jjj|j�|�t|j�ddd��S)rTF)r�rPrQ)r�r!r�rr�rcrr%r%r&r�s
��zworkingctx.walkcs0|j�|�}|jj�t�fdd���|�D��S)Nc3s|]}��|�jr|VqdSr)r�r�r��r�r%r&r��rMz%workingctx.matches.<locals>.<genexpr>)r!r�r�r�rrr%r�r&r�szworkingctx.matchescCs�|jj����|��|��D]}|jjj|ddd�q|��D]}|jjj|ddd�q@|jj�|�|j��t	�
|j|�Wd�n1s�0Y|jj�|j���dS)NTr�F)
r!r�r�r[r\r�r]r�Z!_quick_access_changeid_invalidaterZaftercommitr�r�)r#r(r�r%r%r&r��s��
,zworkingctx.markcommittedcCs |rtj�|j�Stj�|j�Sr)�
mergestatemodrrEr!r�r�r%r%r&rszworkingctx.mergestate)rMNNNN)N)N)FTT)rM)rM)NNNr�FNN)FFF)F)#r.r�r�r�r'r@r<rr�r|r�r�r�r~r�r=r�r�r�r�r
r�r�r�r�r�r9rCr`rDrrr�rrr%r%r�r&r�sT
�


"



)
�
,/
%


r�c@sFeZdZdZddd�Zdd�ZeZdd�Zd	d
�Zdd�Z	d
d�Z
dS)�committablefilectxz�A committablefilectx provides common functionality for a file context
    that wants the ability to commit, e.g. workingfilectx or memfilectx.NcCs:||_||_d|_d|_|_|dur,||_|r6||_dSr)r!rrrr"rr)r#r$r�r�r�r%r%r&r'szcommittablefilectx.__init__cCsdSryr%r)r%r%r&r�(szcommittablefilectx.__nonzero__cCs|��Srr?r)r%r%r&r-szcommittablefilectx.linkrevcCs0|��}|sdS||jjdj�||jjj�fSr~)r+rr|r9r�r!rUrr�r%r%r&r*1s
��zcommittablefilectx.renamedcs��fdd�}�j}�j}�jj}���}|r8|dg}n|||d|�|fg}|dd�D]}|�||||�|f�qZ�fdd�|D�S)	z5return parent filectxs, following copies if necessarycs|j�|�jjj�Sr)r9r�r!rUr)r�r�r)r%r&r�?sz,committablefilectx.parents.<locals>.filenoderrrNcs0g|](\}}}|�jjjkr�j|||d��qSrm)r!rUrrQ)rGrAr�rUr)r%r&rKOs�z.committablefilectx.parents.<locals>.<listcomp>)rrrr|r*rT)r#r�r�rTZpclr*rWZpcr%r)r&r}<s
�zcommittablefilectx.parentscCsgSrr%r)r%r%r&r�Uszcommittablefilectx.children)NN)r.r�r�r�r'r�rrr*r}r�r%r%r%r&r�s
r�cs�eZdZdZd$�fdd�	Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd%dd�Zd&dd�Zdd�Zd d!�Zd"d#�Z�ZS)'r�zrA workingfilectx object makes access to data related to a particular
    file in the working directory convenient.Ncstt|��||||�dSr)r�r�r')r#r$r�r�r�r�r%r&r']szworkingfilectx.__init__cCs
t|j�Sr)r�r!r)r%r%r&r`szworkingfilectx._changectxcCs|j�|j�Sr)r!Zwreadrr)r%r%r&r,dszworkingfilectx.datacCs|jj�|j�Sr)r!r��copiedrr)r%r%r&r+gszworkingfilectx.copysourcecCs|jj�|j�jSr)r!r�r�rr�r)r%r%r&r-jszworkingfilectx.sizecCs|jj�|j�Sr)r!r�r�rr)r%r%r&r�mszworkingfilectx.lstatc
Csj|j��\}}z|jj�|j�tj|fWStyd}z"|j	t	j
krH�||fWYd}~Sd}~00dSr)rr�r!r�r�rr��ST_MTIMErr�r�)r#�tZtzr�r%r%r&r�pszworkingfilectx.datecCs|jj�|j�Sr)r!r��existsrr)r%r%r&r�yszworkingfilectx.existscCs|jj�|j�Sr)r!r��lexistsrr)r%r%r&r�|szworkingfilectx.lexistscCs|jj�|j�Sr)r!r��auditrr)r%r%r&r�szworkingfilectx.auditcCs
|�|�S)r8)rVr<r%r%r&rV�szworkingfilectx.cmpFcCs*|jj�dd�}|jjj|j||d�dS)�+wraps unlink for a repo's working directoryr�sremoveemptydirs)�
ignoremissing�rmdirN)r!rb�
configboolr�Z
unlinkpathr)r#r�r�r%r%r&�remove�s�zworkingfilectx.removecKs|jj|j||fd|i|��S)�wraps repo.wwrite�backgroundclose)r!Zwwriter�r#r,r�r��kwargsr%r%r&r��s���zworkingfilectx.writecCs|jj�||j�dS)zmarks this file a copy of `src`N)r!r�r�r)r#r�r%r%r&�
markcopied�szworkingfilectx.markcopiedcCs�|jj}|j}|�|�|jj�dd�r||�|�rJ|�|�sJ|j|dd�t	t
t�|���D]}|�
|�r\|�|�q�q\n|�|�r�|�|�s�|�|�dS)zsRemoves conflicting items in the working directory so that
        ``write()`` can be called successfully.
        r�smerge.checkpathconflictsT)ZforciblyN)r!r�rr�rbr��isdirr6�rmtreer�r�rZfinddirsZisfileorlink�unlink�
removedirs)r#r�r�rAr%r%r&�clearunknown�s
�

zworkingfilectx.clearunknowncCs|jj�|j||�dSr)r!r��setflagsr)r#rUr�r%r%r&r��szworkingfilectx.setflags)NN)F)F)r.r�r�r�r'r�rr,r+r-r�r�r�r�r�rVr�r�r�r�r�rr%r%r�r&r�Ys$
		

r�cs<eZdZdZ�fdd�Zdd�ZdIdd�Zd	d
�Zedd��Z	ed
d��Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�ZdJd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�ZdKd8d9�Zd:d;�Z d<d=�Z!d>d?�Z"d@dA�Z#dLdBdC�Z$dMdDdE�Z%dNdGdH�Z&�Z'S)O�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.
    cstt|��|�|��dSr)r�r�r'rEr"r�r%r&r'�szoverlayworkingctx.__init__cCs||_|g|_t�|d�dS)N�	_manifest)�_wrappedctxr|r�clearcachedproperty)r#Z
wrappedctxr%r%r&�setbase�szoverlayworkingctx.setbaseNcCs>|dur|jjj}||j��ks$J�|j|j��|g|_dSr)r!rUrr�r(r�r|)r#r�r�r%r%r&r��s
zoverlayworkingctx.setparentscCsj|�|�rX|j|drH|j|ddur8|j|dS|j|��Sqft�d|��n|j|��SdS�N�exists�data�No such file or directory: %s)�isdirty�_cacher�r,rr;r�r%r%r&r,�s
�zoverlayworkingctx.datacCs�|��}|d����}|j}|��D]"}|jjj||<|�|||��q&|�	�D]"}|jjj
||<|�|||��qR|��D]
}||=q~|Sr~)r}rAr�r~r\r!rUr�r�r[r�r])r#r}r�r�r�r%r%r&r9�szoverlayworkingctx._manifestcs�fdd�}|S)Ncs�j|dS)N�flags�r�r[r)r%r&r��sz&overlayworkingctx._flagfunc.<locals>.fr%)r#r�r%r)r&r~�szoverlayworkingctx._flagfunccCst|��|��|���Sr)r�r\r[r]r)r%r%r&r��szoverlayworkingctx.filescs�fdd��j��D�S)Ncs(g|] }�j|dr��|�r|�qS�r��r��_existsinparentr�r)r%r&rK	s�z.overlayworkingctx.modified.<locals>.<listcomp>�r��keysr)r%r)r&r[	s
�zoverlayworkingctx.modifiedcs�fdd��j��D�S)Ncs(g|] }�j|dr��|�s|�qSr�r�r�r)r%r&rK		s�z+overlayworkingctx.added.<locals>.<listcomp>r�r)r%r)r&r\	s
�zoverlayworkingctx.addedcs�fdd��j��D�S)Ncs(g|] }�j|ds��|�r|�qSr�r�r�r)r%r&rK	s�z-overlayworkingctx.removed.<locals>.<listcomp>r�r)r%r)r&r]	s
�zoverlayworkingctx.removedcCsRi}|j��}|j��D]4}||�s&q|�|d�|j|d}|r|||<q|S�N�copied�r!r�r�r�rc�r#r�r�r�r�r%r%r&r�	s

zoverlayworkingctx.p1copiescCsRi}|j��}|j��D]4}||�s&q|�|d�|j|d}|r|||<q|Srrrr%r%r&r�"	s

zoverlayworkingctx.p2copiescCsdSryr%r)r%r%r&r�.	szoverlayworkingctx.isinmemorycCs*|�|�r|j|dS|j|��SdS)N�date)r�r�r�r�r�r%r%r&�filedate1	s
zoverlayworkingctx.filedatecCs$|j|d|�|�|�|�|d�dS)NT)r�r�r�r�)�
_markdirtyrr�)r#r��originr%r%r&r�7	s�zoverlayworkingctx.markcopiedcCs |�|�r|j|dSdSdSr)r�r�r�r%r%r&�copydata@	s
zoverlayworkingctx.copydatacCsH|�|�r6|j|dr&|j|dSt�d|��n|j|��SdS)Nr�r�r�)r�r�rr;r�r�r�r%r%r&r�F	s
�zoverlayworkingctx.flagscCs$||jvr|j|dS||��vS)Nr�)r�rr:r%r%r&r<Q	s
zoverlayworkingctx.__contains__cCs,z|j|WdStjy&YdS0dSr%)r�rr�r�r%r%r&r�V	s

z!overlayworkingctx._existsinparentc
s��fdd�}|�d�}t�t|��D](}d�|d|��}|�vr$|||�q$�j|gdd�}t������	|��}t|�dkr�t|�dkr�|d|kr�dS�fd	d
�|D�}|s�dSt
�d||���t|�d�|�f��dS)
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.
        csRd���|��vr2t�d||�����f��nt�d||�����f��dS)Nr5s*error: %s conflicts with symlink %s in %d.s+error: '%s' conflicts with file '%s' in %d.)rr�rrkrN)r��	componentr)r%r&�failh	s����z/overlayworkingctx._auditconflicts.<locals>.failrrspath)r�rNcsg|]}|�vr|�qSr%r%)rGrr)r%r&rK�	rMz5overlayworkingctx._auditconflicts.<locals>.<listcomp>sberror: file '%s' cannot be written because  '%s/' is a directory in %s (containing %d entries: %s)s, )�splitrZxranger�rr
r�rrArrrk)r#r�r
�
componentsr�r	r
Zmfilesr%r)r&�_auditconflicts`	s&
��z!overlayworkingctx._auditconflictsrMcKs8|durt�d��|�|�|j|d|t��|d�dS)Nsdata must be non-NoneT)r�r,r�r�)rr;r
rrr{)r#r�r,r�r�r%r%r&r��	s

�zoverlayworkingctx.writecCs0d}|rd}n|rd}|j|dt��|d�dS)NrMr5r1T)r�r�r�)rrr{)r#r�rUr�r�r%r%r&r��	szoverlayworkingctx.setflagscCs|j|dd�dS)NF)r�)rr�r%r%r&r��	szoverlayworkingctx.removecCsZ|�|�rP|j|drBd|j|dvrB|�|j|d���S|j|dS|�|�S)zqexists behaves like `lexists`, but needs to follow symlinks and
        return False if they are broken.
        r�r5r�r�)r�r�r��stripr�r�r%r%r&r��	s
��zoverlayworkingctx.existscCs"|�|�r|j|dS|�|�S)z'lexists returns True if the path existsr�)r�r�r�r�r%r%r&r��	s
zoverlayworkingctx.lexistscCsF|�|�r8|j|dr*t|j|d�St�d|��|j|��Sr�)r�r�r�rr;r�r-r�r%r%r&r-�	s
�zoverlayworkingctx.sizec
s�|dur(���}t|�dkr(|ddf}|ddurH�j|ddf}n�j|d�j|df}���}�fdd�}	|dur��j��}t�j||||	|||||d�
S)z�Converts this ``overlayworkingctx`` into a ``memctx`` ready to be
        committed.

        ``text`` is the commit message.
        ``parents`` (optional) are rev numbers.
        Nrrc	sZ�j|drRt|||�j|dd�j|dvd�j|dv�j|d�SdSdS)Nr�r�r5r�r1r)r��
memfilectx�r$�memctxr�r)r%r&�getfile�	s�z+overlayworkingctx.tomemctx.<locals>.getfile)r�r�r�r��editor)r}r�r!r�r�r�r)
r#rur�r�r�r}r�rr�rr%r)r&�tomemctx�	s.
�zoverlayworkingctx.tomemctxcCs<|����}|��|d<|j|��|��||��|��d�S)Nsamend_source)rur�r�r�r�)r�r�rrr�r�r�r�)r#Z	precursorr�r%r%r&�tomemctx_for_amend
s�z$overlayworkingctx.tomemctx_for_amendcCs
||jvSrr�r�r%r%r&r�
szoverlayworkingctx.isdirtycCsd|_i|_dSr)�_mergestater�r)r%r%r&rE
szoverlayworkingctx.cleanc	Cs�g}t�|��|����t�|��|j���fg�|j��D]`}|j|}z8|j|}|�	�|dkr�|�
�|dkr�|�|�Wq>tj
y�Yq>Yq>0q>|D]}|j|=q�|S)z�Removes 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.
        r�r�)rZ
prefetchfilesr$rrNZ
matchfilesr�r�r�r,r�rTrr�)r#r�r��cacheZ
underlyingr%r%r&�_compact
s,
���


��
zoverlayworkingctx._compactcCsb|r<|dur<|j�|�pi}|�d�}|dur<|j|��}|||||d�|j|<t�|d�dS)Nr�)r�r�rr�rr�)r�r�r�r,rr�)r#r�r�r,r�r�r�Zoldentryr%r%r&r:
s
�zoverlayworkingctx._markdirtycCst|j|||d�S)N)rer�)�overlayworkingfilectxr!r�r%r%r&r=O
s
�zoverlayworkingctx.filectxFcCs"|s|jdurt�|j�|_|jSr)rr�Z
memmergestater!r�r%r%r&rT
szoverlayworkingctx.mergestate)N)rM)NNNNNN)NNrMN)N)F)(r.r�r�r�r'r�r�r,r�r9r~r�r[r\r]r�r�r�rr�rr�r<r�r
r�r�r�r�r�r-rrr�rErrr=rrr%r%r�r&r��sX


	
0

�
>&�

r�cs�eZdZdZd$�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd%dd�Zd&d d!�Zd"d#�Z�ZS)'rz�Wrap a ``workingfilectx`` but intercepts all writes into an in-memory
    cache, which can be flushed through later by calling ``flush()``.Ncs,tt|��||||�||_||_||_dSr)r�rr'r!�_parentr)r#r$r�r�rer�r%r&r'^
szoverlayworkingfilectx.__init__cCs|��|��kSr�r,r<r%r%r&rVd
szoverlayworkingfilectx.cmpcCs|jSr)rr)r%r%r&r�g
szoverlayworkingfilectx.changectxcCs|j�|j�Sr)rr,rr)r%r%r&r,j
szoverlayworkingfilectx.datacCs|j�|j�Sr)rrrr)r%r%r&r�m
szoverlayworkingfilectx.datecCs|��Sr)r�r)r%r%r&r�p
szoverlayworkingfilectx.existscCs|j�|j�Sr)rr�rr)r%r%r&r�s
szoverlayworkingfilectx.lexistscCs|j�|j�Sr)rrrr)r%r%r&r+v
sz overlayworkingfilectx.copysourcecCs|j�|j�Sr)rr-rr)r%r%r&r-y
szoverlayworkingfilectx.sizecCs|j�|j|�dSr)rr�r)r#rr%r%r&r�|
sz overlayworkingfilectx.markcopiedcCsdSrr%r)r%r%r&r�
szoverlayworkingfilectx.auditcCs|j�|j�Sr)rr�rr)r%r%r&r��
szoverlayworkingfilectx.flagscCs|j�|j||�Sr)rr�r)r#r6r3r%r%r&r��
szoverlayworkingfilectx.setflagsFcKs|jj|j||fi|��Sr)rr�rr�r%r%r&r��
szoverlayworkingfilectx.writecCs|j�|j�Sr)rr�r�r#r�r%r%r&r��
szoverlayworkingfilectx.removecCsdSrr%r)r%r%r&r��
sz"overlayworkingfilectx.clearunknown)NN)F)F)r.r�r�r�r'rVr�r,r�r�r�r+r-r�r�r�r�r�r�r�rr%r%r�r&rZ
s"

rcs8eZdZdZd�fdd�	Zddd�Zed	d
��Z�ZS)
�workingcommitctxz�A 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.
    rMNcstt|��||||||�dSr)r�rr')r#r$r�rur�r�r�r�r%r&r'�
s
�zworkingcommitctx.__init__Fc	sj|r�fdd��jD�}ng}t��fdd��jjD��fdd��jjD��fdd��jjD�ggg|�S)z�Return matched files only in ``self._status``

        Uncommitted files appear "clean" via this context, even if
        they aren't actually so in the working directory.
        csg|]}|�jvr|�qSr%)�_changedsetr�r)r%r&rK�
rMz4workingcommitctx._dirstatestatus.<locals>.<listcomp>csg|]}�|�r|�qSr%r%r��r
r%r&rK�
rMcsg|]}�|�r|�qSr%r%r�rr%r&rK�
rMcsg|]}�|�r|�qSr%r%r�rr%r&rK�
rM)r9rrBrrr[r\r])r#r
rQrErPr%rr&r��
s�z workingcommitctx._dirstatestatuscCs,t|jj�}|�|jj�|�|jj�|S)z/Return the set of files changed in this context)rRrrr[�updater\r])r#Zchangedr%r%r&r�
szworkingcommitctx._changedset)rMNNN)FFF)	r.r�r�r�r'r�r�rrr%r%r�r&r�
s�
rcsi���fdd�}|S)z�Create 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.
    cs |�vr�|||��|<�|Srr%r�rr�r%r&�
getfilectx�
sz(makecachingfilectxfn.<locals>.getfilectxr%)r�r"r%r!r&�makecachingfilectxfn�
sr#cs�fdd�}|S)z�Given a context return a memfilectx for ctx[path]

    This is a convenience method for building a memctx based on another
    context.
    c	s2�|}|��}t||||��|��|��|d�S�N)r6r3r+)r+rr,r6r3)r$rr�r=r+�r�r%r&r"�
s�z"memfilefromctx.<locals>.getfilectxr%)r�r"r%r%r&�memfilefromctx�
s
r&cs�fdd�}|S)z�Given a patch (e.g. patchstore object) return a memfilectx

    This is a convenience method for building a memctx based on a patchstore.
    c	s:��|�\}}}|durdS|\}}t|||||||d�Sr$)rr)r$rr�r,r�r+r6r3��
patchstorer%r&r"�
s�z$memfilefrompatch.<locals>.getfilectxr%)r(r"r%r'r&�memfilefrompatch�
sr)csXeZdZdZdZd�fdd�	Zddd�Zdd	�Zed
d��Z	edd
��Z
dd�Z�ZS)raNUse 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
s�tt��j||||||	d�d�_d�_�fdd�|D�}|\}}�fdd�||fD��_tt|��}|�_i�_	t
|tj�r�t
|�}nt|�s�t|�}t|��_|
r�|
�j�g��_�j��j�dS)Nr�csg|]}|p�jjj�qSr%rRr@r)r%r&rK1rMz#memctx.__init__.<locals>.<listcomp>csg|]}�j|�qSr%r r@r)r%r&rK3rM)r�rr'r2rhr|r�rR�_filesrcr�rZ	filestorer)�callabler&r#�
_filectxfnr!ro�savecommitmessage)
r#r$r}rur�Z	filectxfnr�r�r�r�rrr�r�r)r&r's&
�

zmemctx.__init__cCs|�|j||�S)zpget a file context from the working directory

        Returns None if file doesn't exist and should be removed.)r,r!r�r%r%r&r=Eszmemctx.filectxcCs|j�|�S�zcommit context to the repo�r!Z	commitctxr)r%r%r&�commitKsz
memctx.commitcCsn|jd}|����}|jjD]}|jjj||<q|jjD]}|jjj	||<q:|jj
D]}||vrV||=qV|S)z;generate a manifest based on the return values of filectxfnr)r|rAr�rrr[r!rUr�r\r�r])r#r�r�r�r%r%r&r9Os
zmemctx._manifestc	s�|�����|jd}|��tkr:|�����fdd�}n�fdd�}ggg}}}|jD]6}||�st|�|�q\||r�|�|�q\|�|�q\t�|||gggg�S)z?Calculate exact status from ``files`` specified at constructionrcs|�vp|�vSrr%r\��man1Zman2r%r&rZmrMz memctx._status.<locals>.<lambda>cs|�vSrr%r\�r2r%r&rZorM�	rrAr|rNrr*rTrrB�r#r�Zmanagingr[r\r]r�r%r1r&rrcs

zmemctx._statuscCs$|jd��tkr|jdgS|jS)Nrr)r|rNrr)r%r%r&r}|szmemctx.parents)NNNNN)N)
r.r�r�r�Z_returnnoneformissingfilesr'r=r0r�r9rrr}rr%r%r�r&r�
s	�&


rcsLeZdZdZd�fdd�	Zdd�Zdd	�Zd
d�Zddd
�Zdd�Z	�Z
S)rzpmemfilectx represents an in-memory file to commit.

    See memctx and committablefilectx for more details.
    FNcsDtt|��||d|�||_|r(d|_n|r4d|_nd|_||_dS)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.Nr5r1rM)r�rr'�_datar'�_copysource)r#r$r�r�r,r6r3r+r�r%r&r'�szmemfilectx.__init__cCs|jSr)r7r)r%r%r&r+�szmemfilectx.copysourcecCs|��|��kSrrr<r%r%r&rV�szmemfilectx.cmpcCs|jSr�r6r)r%r%r&r,�szmemfilectx.datacCs|j|j=dS)r�N)rrrr%r%r&r��szmemfilectx.removecKs
||_dS)r�Nr8�r#r,r�r�r%r%r&r��szmemfilectx.write)FFN)F)r.r�r�r�r'r+rVr,r�r�rr%r%r�r&r�s�
rcs`eZdZdZd�fdd�	Zdd�Zedd��Zdd	d
�Zdd�Z	ed
d��Z
edd��Z�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	
s(|dur|��}tt|���||||�d|_d|_||_|��|_|durV|�	�}n�fdd�|D�}|dd�}t
|�dkr�|��t�qt|\}	}
|_
|��j	\}}|	|jjjkr�|	��|kr�td��|
|jjjkr�|
��|kr�td��|��|_i|_|�r$||j|g�|_|j�|j�dS)Ncsg|]}|dur�|�qSrr%r@�r$r%r&rK�rMz,metadataonlyctx.__init__.<locals>.<listcomp>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)r�r�r:r'r2rh�_originalctxr��
_manifestnoder}r�rTrr|rjr!rUr�RuntimeErrorr�r*rcror-)
r#r$Zoriginalctxr}rur�r�r�rrr�Zmp1Zmp2r�r;r&r'�s8

��
zmetadataonlyctx.__init__cCs|jSr)r=r)r%r%r&r��szmetadataonlyctx.manifestnodecCs|jj|jSr)r!r�r=r)r%r%r&ri�szmetadataonlyctx._manifestctxcCs|jj||d�S)N)r�)r<r=r�r%r%r&r=�szmetadataonlyctx.filectxcCs|j�|�Sr.r/r)r%r%r&r0szmetadataonlyctx.commitcCs
|j��Sr)r<rAr)r%r%r&r9szmetadataonlyctx._manifestc	s�|�����|jd}|��tkr:|�����fdd�}n�fdd�}ggg}}}|jD]6}||�st|�|�q\||vr�|�|�q\|�|�q\t�|||gggg�S)zjCalculate exact status from ``files`` specified in the ``origctx``
        and parents manifests.
        rcs|�vp|�vSrr%r\r1r%r&rZrMz)metadataonlyctx._status.<locals>.<lambda>cs|�vSrr%r\r3r%r&rZrMr4r5r%r1r&rrs

zmetadataonlyctx._status)NNNNNN)N)r.r�r�r�r'r�rrir=r0r9r�rrrr%r%r�r&r:�s"�0


r:c@sReZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�arbitraryfilectxz�Allows you to use filectx-like functions on a file in an arbitrary
    location on disk, possibly not in the working directory.
    NcCs||_||_dSr)r!r)r#r�r$r%r%r&r')szarbitraryfilectx.__init__cCsZd|��vpd|��v}|sJt|t�rJ|jrJt�|��|j�|����S|��|��kSr4)	r�r�r�r!�filecmprVr�Zwjoinr,)r#r=�symlinksr%r%r&rV.szarbitraryfilectx.cmpcCs|jSrr#r)r%r%r&r�9szarbitraryfilectx.pathcCsdSr�r%r)r%r%r&r�<szarbitraryfilectx.flagscCst�|j�Sr�rZreadfilerr)r%r%r&r,?szarbitraryfilectx.datacCst�|j�SrrBr)r%r%r&rfBszarbitraryfilectx.decodeddatacCst�|j�dSr)rr�rr)r%r%r&r�Eszarbitraryfilectx.removecKs|rJ�t�|j|�dSr)rZ	writefilerr9r%r%r&r�Hszarbitraryfilectx.write)N)r.r�r�r�r'rVr�r�r,rfr�r�r%r%r%r&r?$s
r?)<Z
__future__rr�r@r�r�Zi18nrr(rrrrr�r	r
rrr
r�rr�rrrsrrrrrrrrrZutilsrrZ
dirstateutilsrr��objectrr�rr=rnr�r�r�r�rrr#r&r)rrr:r?r%r%r%r&�<module>s\P@.>~*@^&8,4n

Youez - 2016 - github.com/yon3zu
LinuXploit