��c@sCddlmZmZmZmZddlmZddlmZddl Z ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZdefd��YZd�Zd�Zd �Zd
�Zed�Zd�Zd
�Zd�Zed�Zd�Zded�Z!dS(i�(tnullidtnullrevthextbin(t_(tobsoleteNt
mergestatecBskeZdZd�Zdd�Zd�Zd�Zd�Zd�Z d�Z
d�Zd �Zd
�Z
RS(s+track 3-way merge state of individual filescCs ||_t|_|j�dS(N(t_repotFalset_dirtyt_read(tselftrepo((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt__init__s cCsDi|_|r||_ntj|jjd�t�t|_dS(Ntmerge( t_statet_localtshutiltrmtreeRtjointTrueRR (Rtnode((s3/sys/lib/python2.7/site-packages/mercurial/merge.pytresets
cCs�i|_y�|jjd�}xdt|�D]V\}}|dkrYt|d �|_q+|d jd�}|d|j|d<q+W|j�Wn+tk
r�}|j t j
kr��q�nXt|_dS(Nsmerge/stateii�ti(
RRtopenert enumerateRRtsplittclosetIOErrorterrnotENOENTRR (Rtftitltbitsterr((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyR
s
cCs�|jr�|jjdd�}|jt|j�d�x>|jj�D]-\}}|jdj|g|�d�qHW|j �t
|_ndS(Nsmerge/statetws
R(R RRtwriteRRRt iteritemsRRR(RRtdtv((s3/sys/lib/python2.7/site-packages/mercurial/merge.pytcommit)s %
cCs�tj|j��j�}|jjjd||j��d||j�|j�t|j ��|j�|j
�g|j|<t|_
dS(Nsmerge/tu(tutiltsha1tpatht hexdigestRRR%tdataRtfilenodetflagsRRR (Rtfcltfcotfcatfdthash((s3/sys/lib/python2.7/site-packages/mercurial/merge.pytadd1s
.cCs
||jkS(N(R(Rtdfile((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt__contains__7scCs|j|dS(Ni(R(RR8((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt__getitem__9sccs3|jj�}|j�x|D]}|Vq WdS(N(Rtkeystsort(RR!R((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt__iter__;s
cCs||j|d<t|_dS(Ni(RRR (RR8tstate((s3/sys/lib/python2.7/site-packages/mercurial/merge.pytmark@scCs�||dkrdS|j|\}}}}}} }
||}|| }|jj|d|�}
|j�}|
j�}d|
||kr�|
||kr�
j�tkr�|jjjtd�|�q�
|kr�}
q�|jj d|�}|jj
||j�|
�|j�t
j
|j|j||||
�}|dkre|j|=n|s~|j|d�n|S(NtritfileidtxR!s#warning: cannot merge flags for %s
smerge/(RRtfilectxR1RRtuitwarnRRtwwritetreadRt filemergeRtNoneR?(RR8twctxtoctxR>R6tlfiletafiletanodetofileR1tfcdR3R4tflotflaRR@((s3/sys/lib/python2.7/site-packages/mercurial/merge.pytresolveCs."
(
$
N(t__name__t
__module__t__doc__R
RIRR
R)R7R9R:R=R?RS(((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyRs cCs^|jj|�o]tjj|j|��o]|jj|�|jko]||j||�S(N(tdirstatet_ignoretosR-tisfiletwjoint normalizetcmp(RRJtmctxR((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt_checkunknownfile_scCs�t}xU|D]M}||kr
t||||�r
t}|jjjtd�|�q
q
W|r|tjtd���ndS(s<check for collisions between unknown files and files in mctxs%s: untracked file differs
sLuntracked files in working directory differ from files in requested revisionN( RR_RRRDRERR+tAbort(RRJR^terrorR((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt
_checkunknownes
!$cCs�g}|rdpd}x<|j�D].}||kr%|j||ddf�q%q%W|s�x?|j�D].}||krj|j|dddf�qjqjWn|S(s�
Forget removed files
If we're jumping between revisions (as opposed to merging), and if
neither the working directory nor the target rev has the file,
then we need to remove it from the dirstate, to prevent the
dirstate from listing the file when it is no longer in the
manifest.
If we're merging, and the other revision has removed a file
that is not present in the working directory, we need to mark it
as removed.
R@Rsforget deletedsforget removedN(tdeletedtappendRItremoved(RJR^tbranchmergetactionsR>R((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt_forgetremovedqs #cs�t|���fd�}�fd�}d�}�fd�}�fd�}i |d6|d6|d6|d 6|d
6|d6|d6|d
6|d6} xH|D]@\}
}}}
| j|�}|s�t|��||
|�q�Wi|d6|d6} xB|D]:\}
}| j|�}|s)t|��||
d�q�}x_t��D]Q}
tj|
�}||kr�tjtd�|
||f��n|
||<qMWdS(Ncs�j|�dS(N(R7(Rtargs(tpmmf(s3/sys/lib/python2.7/site-packages/mercurial/merge.pytaddop�scs�j|�dS(N(tdiscard(RRi(Rj(s3/sys/lib/python2.7/site-packages/mercurial/merge.pytremoveop�scSsdS(N((RRi((s3/sys/lib/python2.7/site-packages/mercurial/merge.pytnop�scs6|\}}}|r%�j|�n�j|�dS(N(RlR7(RRitf2R5R1(Rj(s3/sys/lib/python2.7/site-packages/mercurial/merge.pytrenameop�scs6|\}}}|r%�j|�n�j|�dS(N(RlR7(RRiRoR5tmove(Rj(s3/sys/lib/python2.7/site-packages/mercurial/merge.pytmergeop�staR'tdrteRtgtmR@trdtcdtdcs(case-folding collision between %s and %s( tsettgettAssertionErrorRItsortedR+tnormcaseR`R(RtwmfRgtpromptsRkRmRnRpRrtopmapRRwRitmsgtoptfoldmaptfold((Rjs3/sys/lib/python2.7/site-packages/mercurial/merge.pyt_checkcollision�sD
c*Cs�|o
|}gii} }
}t}|r6|}n_||krQ|j�}nD|rn|jdt�rnn'|r�|jjddt�r�t}ngt|j�||gdd��D]}
|
j�^q�|rvt j
||||�}|\}
}}}x6|j�D](\}}| j|d|fdf�qWx9|j�D](\}}| j|d|fd f�qGWn|jj
td
��|jjdt|�t|�t|�f�|jjd|||f�|j�|j�|j�}}}t|
j��}|j|j��d
|kruxCt|j�D]/}|j|�j�r?|d
cd7<Pq?q?Wngg}}tj||�}|j|�}tj||�}x�|j�D]�\}\}}|r�\} }!n(|j|d5�} }!| d5krq�n|r&|\}"}#n|j|�}"}#|rR||�rRq�n| r�|!r�|j|�}$d|"|#|$k}%|j|t�}&|!|&kr�|#|$kr�qg| |&kr|"|$kr| |!kr�j|d|#fdf�q�| j|d|#fdf�qg|%rA|!|&krA| j|d|#fdf�qg|%rr| |&krr| j|d|"fdf�qg| j|d||tfdf�q�||kr�q�| r�|kr�|}'| j|dd5|'|"fd|'f�q�| r0||
kr0|
|}'| j|d|'|tfd|'f�q�| r�||kr�| ||krh|j|df�qg| ddkr�| j|dd5df�qg| j|dd5df�q�|!r�|kr�|}'| jd5d||'|#fd |'f�q�|!ro||
kro|
|}'|'|krF| j|'d||tfd!|f�qg| j|'d||tfd"|f�q�|!r;||kr;|r�|r�| j|d|#fd#f�qgt||||�}(|r�r�r�j|d||tfd$f�qg|r|(r|j|d%f�qg| j|d|#fd#f�q�|!r�|!||kr�|j|d&f�q�q�WxUt|�D]G\}})|)d%kr�|jjtd'�|�qxtsxt |)��qxW|r�!j"td(���nt!j#|j$�sE|r/|s|jdtd)t�r/t%||gg�qEt%||| |�nxet|�D]W\}})|)dkr�r�| j|dd5d*f�q�|jj&td+�|td,�td-�fd.�r�| j|dd5d/f�q�| j|dd5d0f�qR|)d&kr�|r2 | j|d|j|�fd1f�q�|jj&td2�|td,�td3�fd.�d.kr�| j|d|j|�fd4f�q�qRtsRt |)��qRW| S(6s�
Merge p1 and p2 with ancestor pa and generate merge action list
branchmerge and force are as passed in to update
partial = function to filter file lists
acceptremote = accept the incoming changes without prompting
tmissingRtfollowcopiestkeycSs
|j�S(N(trev(RB((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt<lambda>�sRtsdivergent renamesRxsrename and deletesresolving manifests
s) branchmerge: %s, force: %s, partial: %s
s% ancestor: %s, local: %s, remote: %s
s.hgsubstatet+R!Rusupdate permissionsRvsremote is newerRwsversions differR'sremote renamed directory to slocal copied/moved to RyiRsRsremote deletedR@s
other deletedslocal renamed directory to sremote copied to sremote moved to sremote createds#remote differs from untracked localtudRzs%s: untracked file differs
sLuntracked files in working directory differ from files in requested revisiontbranchs
remote deletesHlocal changed %s which remote deleted
use (c)hanged version or (d)elete?s&Changeds&Deleteis
prompt deletesprompt keepsremote recreatingsOremote changed %s which local deleted
use (c)hanged version or leave (d)eleted?s&Deletedsprompt recreatingN('Rtp1tdirtyRRDt
configboolR~tparentstmanifesttcopiestmergecopiesR&RdtnoteRtdebugtboolR{tvaluestupdatetsubstatetsubtdicthelperstdifft flagsdiffRR|RIR1RR_RER}R+R`t checkcaseR-R�tpromptchoice(*RRJtp2tpaRftforcetpartialtacceptremotet overwriteRgtcopytmovewithdirR�RBtrettdivergetrenamedeletetoftfltm1tm2tmatcopiedtstabortsR�tfdiffR�tdiff12Rtn12tfl12tn1tn2tfl1tfl2RRtnolRsRot differentRw((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt
manifestmerge�s
9 ##&
%
( $+cCs |ddkrdpd|fS(NiR@i�i((Rs((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt actionkeysccs|jj}tj}|j}|j}|j}|jj} d}
x|D]}|d}|ddkr�r�|jj t
d�|�n| |�y|||�dt�Wq3tk
r�}
|jj
t
d�||
jf�q3XnG|r|jj t
d�|�n||||�j�|dd�|
d krS|
|fVd}
n|
d7}
qIW|
dkr{|
|fVnd
S(s�apply usually-non-interactive updates to the working directory
mctx is the context to be merged into the working copy
yields tuples for progress updates
iiR@sremoving %s
t
ignoremissings update failed to remove %s: %s!
sgetting %s
iidN(RDtverboseR+t
unlinkpathR[RCRFtwopenertauditR�RRtOSErrorREtstrerrorR/(RR^R�RiR�tunlinkR[tfctxRFR�R targRtinst((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt getremove�s6
$ c(Cs�d\}}}} t|�}
|
j|j�j��g}|jdt�xB|D]:}|\}
}}}|jjd|
||f�|dkrT|\}}}|dkr�qTn|jjd|
|f�||
}||}||kr#|j�r|j�}q5|j |
dt
�}n|j||�}|sS|j |
dt
�}n|
j||||�|
|kr�|r�|j
|
�q�qTqTW|jj}x`|D]X}
tjj|j|
��r�|jjd|
�||
�tj|j|
��q�q�Wt|�}g|D]}|d d
kr|^q}g|D]}|d dkr=|^q=}t|�}g|D]}|d dkrr|^qr}t|�}g|D]}|d d
kr�|^q�}g|D] }|ddkr�|d ^q�}|r(|ddkr(tj|||||�nd}tj|jd
t|||f|�}xO|D]G\}} ||7}|jjtd�|d| d|dtd��q\Wtj|jd
t|||f|�}xO|D]G\}} ||7}|jjtd�|d| d|dtd��q�W|rR|ddkrRtj|||||�ntd�}!td�}"|jj}#x�|�D]�\}}|\}
}}}|#|!||d d|
d|d|"�|dkr�|\}}}|dkrtj||||j|�|�q�n||�|
j|||�}$|$dk r[|$dkr[| d 7} qa|$dkrt|d 7}qa|d 7}q�|dkr_|\}}}%|
r|jj td�|
|f�||
�|j!||j |
�j"�|%�tj|j|
��n|rR|jj td�||f�|j!||j |�j"�|%�n|d 7}q�|dkr�|\}&|jj#td�|
�x�|&D]}'|jj#d|'�q�Wq�|dkr
|\}&|jj#td�|
�xy|&D]}'|jj#d|'�q�q�|dkr�|\}%||
�tj$|j|
�d|%kd|%k�|d 7}q�q�W|
j%�|#|!dd|d|"�|||| fS( sMapply the merge action list to the working directory
wctx is the working copy context
mctx is the context to be merged into the working copy
actx is the context of the common ancestor
Return a tuple of counts (updated, merged, removed, unresolved) that
describes how many files were affected by the update.
iR�s %s: %s -> %s
Rws.hgsubstates" preserving %s for resolve of %s
RAsremoving %s
itgrRvR@g�MbP?tupdatingtitemttotaltunittfilesR'smoving %s to %s
sgetting %s to %s
Rts<note: possible conflict - %s was renamed multiple times to:
s %s
Rxs9note: possible conflict - %s was deleted and renamed to:
RuR!RB(iiiiN(&RRR�RR<R�RDR�R�RCRtancestorR7RdR�R�RYR-tlexistsR[R+R�tlentsubrepotsubmergetworkerR�tprogressRRRSRIR�RFR/REtsetflagsR)((RRgRJR^tactxR�tupdatedtmergedRet
unresolvedtmstmovesRsRRwRiR�RoR5RqR2R3R4R�t
numupdatest
workeractionst
updateactionst
removeactionsthgsubtztprogR R�t _updatingt_filesR�R@R1R�tnf((s3/sys/lib/python2.7/site-packages/mercurial/merge.pytapplyupdates�s�
))))-
$
$'
" %
(
c
CsZg}|t||||||||�7}|j�dkrV|t|||�7}n|S(s4Calculate the actions needed to merge mctx into tctxN(R�R�RIRh( RttctxR^R�RfR�R�R�Rg((s3/sys/lib/python2.7/site-packages/mercurial/merge.pytcalculateupdates,s
cCs�x�|D]~}|\}}}}|dkrW|rD|jj|�q�|jj|�q|dkr|s�|jj|�q�q|dkr�|jj|�q|dkr�|jj|�q|dkr�r�jj|�q�|jj|�q|dkr�|\}} }
|r�|jj| �||kr�|
rK|jj|�n|| krm|jj|| �q�|jj|| �q�q�|| kr�|jj| �n|
r�|jj|�q�q|dkr|\}} }|r�|jkr�n|rY|jj| �|r:|jj|�|jj|| �n|r�|jj|| �q�q�|jj| �|r�|jj|�q�qqWdS( s$record merge actions to the dirstateR@RsRRuRvRwR'N( RWtremovetdropR7tnormallookuptotherparenttnormalRR�(RRgRfRsRRwRiR�RoR5Rqtflag((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt
recordupdates8sZ
cCs;|}|j�}z�d} |dkr�y|j| j��}Wq�tjk
r�| j�dkr{|jd�}q�tjt d�| j���q�Xn|o�|}
| j
�}|d||}}
|r�|}n|j|
�}|j�|
j�t
|�t
|
�f\}}}}|
rXt|�dkrXtjt d���n|re||
kr�tjt d���nR||kr�|r�|j�|
j�kr�tjt d�d t d
���q�n|r| j�s�j�rtjt d�d t d���nxt| j�D]7}| j|�j�r'tjt d
�|��q'q'Wn�|
s)|||
fkr)| jdt�}|s�|dkrtj||j�g�}||j�|kr�|}q#|r�d�}tj|��q#t d�}tj|��q&|}q)nt|| |
|||||�}|sq|t|df\}}}}n|s�|jddtd|d|�nt||| |
||
�}|s�j||�t|||�|s�jj|
j��q�Wd|j �X|s7|jdd|d|d|d�n|S(s�
Perform a merge between the working directory and the given node
node = the node to update to, or None if unspecified
branchmerge = whether to merge between branches
force = whether to force branch merging or file overwriting
partial = a function to filter file lists (dirstate not updated)
mergeancestor = whether it is merging with an ancestor. If true,
we should accept the incoming changes for any prompts that occur.
If false, merging with an ancestor (fast-forward) is only allowed
between different named branches. This flag is used by rebase extension
as a temporary fix and should be avoided in general.
The table below shows all the behaviors of the update command
given the -c and -C or no options, whether the working directory
is dirty, whether a revision is specified, and the relationship of
the parent rev to the target rev (linear, on the same named
branch, or on another named branch).
This logic is tested by test-update-branches.t.
-c -C dirty rev | linear same cross
n n n n | ok (1) x
n n n y | ok ok ok
n n y * | merge (2) (2)
n y * * | --- discard ---
y n y * | --- (3) ---
y n n * | --- ok ---
y y * * | --- (4) ---
x = can't happen
* = don't-care
1 = abort: crosses branches (use 'hg merge' or 'hg update -c')
2 = abort: crosses branches (use 'hg merge' to merge or
use 'hg update -C' to discard changes)
3 = abort: uncommitted local changes
4 = incompatible options (checked in commands.py)
Return the same tuple as applyupdates().
tdefaultttipsbranch %s not foundiisoutstanding uncommitted mergess7merging with a working directory ancestor has no effectsnothing to mergethints#use 'hg update' or check 'hg heads'soutstanding uncommitted changessuse 'hg status' to list changess5outstanding uncommitted changes in subrepository '%s'R�sCcrosses branches (merge branches or use --clean to discard changes)sCcrosses branches (merge branches or update --check to force update)tt preupdatetthrowtparent1tparent2NR�Rai(!twlockRIt branchtipR�RatRepoLookupErrortlookupR+R`RR�R�RtstrR�R�RcR~R�R�R�RRt
foregroundR�RthookR�t
setparentsR�RWt setbranchtrelease(RRRfR�R�R�t
mergeancestortonodeR�twcR�tplR�R�R�tfp1tfp2txp1txp2R�R�RR�Rgtstats((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyR�vs~+
&
6 !" &("RRRRRti18nRt mercurialRRaR+RHR�R�R�R�RRYRtobjectRR_RbRhR�RR�R�R�R�R�R�RIR�(((s3/sys/lib/python2.7/site-packages/mercurial/merge.pyt<module>s""T$Q 9� $ � >
|