
    	^cg                       d dl Z d dlZddlmZ ddlmZ ddlmZ ddlm	Z	 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 ej        Zej        Z d	 Z!d/d
Z" G d d          Z#d Z$d Z%d Z&d Z'd Z(d Z) G d d          Z*	 d0dZ+d Z,	 	 d1dZ-d Z.d Z/d Z0d Z1 ej2        d           G d d                       Z3	 d/d!Z4d" Z5d#Z6d$Z7d%Z8d&Z9	 	 	 	 	 	 	 	 d2d'Z:d3d(Z;d4d)Z<d/d*Z=d4d+Z>	 	 	 	 	 d5d,Z?d4d-Z@	 	 	 	 	 	 	 d6d.ZAdS )7    N   )_)nullrev)attr)
stringutil)	timestamp)copiesencodingerror	filemergematch
mergestateobsutilpathutilpolicypycompatscmutilsubrepoutilutilworkerc                     | j                             ||          }g d}||vrKd                    d |D                       }t          d          }|||||fz  }t	          j        |          |S )N)   aborts   ignore   warns   , c                     g | ]
}d |z   d z   S )   ' ).0vs     1/usr/lib/python3/dist-packages/mercurial/merge.py
<listcomp>z*_getcheckunknownconfig.<locals>.<listcomp>*   s     >>>1tax$>>>    s$   %s.%s not valid ('%s' is none of %s))uiconfigjoinr   r   ConfigError)reposectionnamer#   validvalidstrmsgs          r   _getcheckunknownconfigr,   &   s    W^^GT**F***EU::>>>>>??788vx00$$$Mr!   c                 ,   |                                 rdS ||}| j        j                            |          o[| j                            |          oA| j                            |          | j        vo ||                             ||                   S NF)
isinmemorywvfsauditcheckisfileorlinkdirstate	normalizecmp)r&   wctxmctxff2s        r   _checkunknownfiler;   1   s      u	z	a   	"I""1%%	"M##A&&dm;	" HLLa!!	r!   c                       e Zd ZdZd Zd ZdS )_unknowndirscheckeray  
    Look for any unknown files or directories that may have a path conflict
    with a file.  If any path prefix of the file exists as a file or link,
    then it conflicts.  If the file itself is a directory that contains any
    file that is not tracked, then it conflicts.

    Returns the shortest path at which a conflict occurs, or None if there is
    no conflict.
    c                 R    t                      | _        t                      | _        d S N)set_unknowndircache_missingdircacheselfs    r   __init__z_unknowndirschecker.__init__O   s$     !$
 !$r!   c                    |                                 rdS t          t          t          j        |                              D ]}|| j        v r d S || j        v r|j        j        	                    |          r|j        
                    |          r%|j                            |          |j        vr|c S |j                            |          s| j                            |            d S | j                            |           |j        j        	                    |          r|j                            |          r~|j                            |          D ]c\  }}}|D ]Z}t#          j        |j                            ||                    }|j                            |d          }||j        vr|c c S [dd S )NFT)isknown)r/   reversedlistr   finddirsrB   rA   r0   r1   r2   r3   r4   r5   lexistsaddisdirwalkr   pconvertreljoin)	rD   r&   r7   r9   pdirsfilesfnrelfs	            r   __call__z_unknowndirschecker.__call__Z   s   ?? 	5 $x0334455 	- 	-AD)))D)))y$$Q'' 	-I**1--//22$-GGHHHy((++ )--a000FF%))!,,, 9?  ## 	!	(:(: 	!"&).."3"3 ! !4 ! !B=):):1b)A)ABBD=2242FFD4=00  1!
 tr!   N)__name__
__module____qualname____doc__rE   rV   r   r!   r   r=   r=   D   s<         	& 	& 	&    r!   r=   c           
          t                      }t                      t                      t                      t           dd          }t           dd          } j                            dd          }	|sfd}
t	                      }|                    t          j        t          j        f          D ]T}t           |||          r|
                    |           *|	r(||vr$ | ||          }|
                    |           U|                    t          j        g          D ]4\  }}}t           ||||d                   r|
                    |           5|z  } fd	|D             }||z
  } |
||            |
||           nt          |                    t          j        g                    D ]\  }}}|\  }}t           |||          } j                            |          r|}n|}|s%|                    |t          j        |d
fd           c|s|dk    r(|                    |t          j        ||dd
|fd           |dk    r
                    |           |dk    r
                    |           |                    |t          j        |dfd           t)                    D ]} j        j        }|v rR j                            |          r |t1          d          |z             H |t1          d          |z             d |t1          d          |z             r!t3          j        t1          d                    t)                    D ]q} j                            |          r+ j                            t1          d          |z             G j                            t1          d          |z             rt          |                    t          j        g                    D ]c\  }}}||v p0|v p,t7          fdt9          j        |          D                       }|\  }|                    |t          j        ||f|           ddS )z
    Considers any actions that care about the presence of conflicting unknown
    files. For some actions, the result is to abort; for others, it is to
    choose a different action.
       merges   checkunknowns   checkignored   experimental   merge.checkpathconflictsc                 |    |dk    r                     |            d S |dk    r                     |            d S d S )Nr   r   )update)	conflictsr#   abortconflictswarnconflictss     r   collectconflictsz,_checkunknownfiles.<locals>.collectconflicts   sU    !!%%i000007""$$Y///// #"r!   Nr   c                 H    h | ]}j                             |          |S r   )r4   _ignore)r   cr&   s     r   	<setcomp>z%_checkunknownfiles.<locals>.<setcomp>   s.    PPP!t}7L7LQ7O7OPAPPPr!   F   remote createdr   s#   remote differs from untracked localr   Ts,   %s: untracked file conflicts with directory
s,   %s: untracked directory conflicts with file
s   %s: untracked file differs
sL   untracked files in working directory differ from files in requested revisions   %s: replacing untracked file
s+   %s: replacing untracked files in directory
c              3       K   | ]}|v V  	d S r?   r   )r   rQ   pathconflictss     r   	<genexpr>z%_checkunknownfiles.<locals>.<genexpr>   s(      DD!1%DDDDDDr!   )r@   r,   r"   
configboolr=   rS   mergestatemodACTION_CREATEDACTION_DELETED_CHANGEDr;   rL   
getactionsACTION_LOCAL_DIR_RENAME_GETrI   ACTION_CREATED_MERGEr4   rf   addfile
ACTION_GETACTION_MERGEsortedwarnr0   r3   r   r   
StateErroranyr   rJ   )r&   r7   r8   forcemresult
mergeforcefileconflictsunknownconfigignoredconfig
pathconfigrd   checkunknowndirsr9   pathargsr+   allconflictsignoredconflictsunknownconflictsfl2anc	differentr#   rx   backupflagsrb   rk   rc   s   `                         @@@r   _checkunknownfilesr   |   sw    EEMEEMEEMUUN*4?KKM*4?KKM##4 J  O	0 	0 	0 	0 	0 	0 /00,4
 
 	, 	,A !tT155 ,!!!$$$$ ,''dA66#!%%d+++#..67
 
 	% 	%LAtS !tT1d1g>> %!!!$$$$}4PPPP|PPP'*::)=999)=9999  BCDD
 
 .	 .	LAtS HC)$dA>>I}$$Q'' '&&  !,%L%	     v11!.4,:	    8##""1%%%%W$$!%%a(((!,$K%	    N## 9 9w|y%%a(( NQGHH1LMMMMQGHH1LMMMMD233a78888 
; 
 
 	
 M"" Q Q9!!!$$ 	QGLL<==ABBBBGLLJKKaOPPPPM89::  	K 	K4  EM!EDDDDx/@/C/CDDDDD 	
 =3eV_cJJJJ	K 	Kr!   c                 "   t           j        }|rt           j        }|                                 D ]}||vr|                    ||dd           |s=|                                 D ]*}||vr"|                    |t           j        dd           )dS dS )a  
    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.
    Ns   forget deleteds   forget removed)rn   ACTION_FORGETACTION_REMOVEdeletedrt   removed)r7   r8   branchmerger|   mr9   s         r   _forgetremovedr      s     	#A ('\\^^ ; ;D==OOAq$(9:::  	 	A}}!/%	   	 	r!   c                 .   |                                  }|                                sit          |                    |                    }|rDt	          |                                          D ]"} ||          s|                    |           #nt          |          }|r|                    t          j        t          j	        t          j
        t          j        t          j        t          j        f          D ]}|                    |           |                    t          j        f          D ]}|                    |           |                    t          j        g          D ]5\  }}}|\  }}	|                    |           |                    |           6|                    t          j        f          D ]}|                    |           |                    t          j        g          D ]:\  }}}|\  }
}}}}|r|                    |
           |                    |           ;i }|D ]O}t+          j        |          }||v r0t/          d          }||||         fz  }t1          j        |          |||<   Pdx}x}}t5          |                                          D ]e\  }}|                    |          r?|                    |          s*t/          d          }|||fz  }t1          j        |          |dz   }|dz   }|}fdS )z,
    Check for case-folding collisions.
    s(   case-folding collision between %s and %sr!   s5   case-folding collision between %s and directory of %s   /N)narrowmatchalwaysr@   rN   rI   rS   
removefilern   
ACTION_ADDACTION_ADD_MODIFIEDr   ru   ACTION_CHANGED_DELETEDrp   rL   r   discardrq   ACTION_DIR_RENAME_MOVE_LOCALrr   rv   r   normcaser   r   ry   rw   items
startswith)r&   wmfr|   r   pmmfr9   r   r+   r:   r   f1famover   foldmapfold
foldprefixunfoldprefixlastfulls                      r   _checkcollisionr      s7   
 ""$$K 388K(()) 	*'--//** * *"{1~~ *&&q))) 3xx (1+(44	
 	
 
	 
	A HHQKKKK ;=>> 	 	ALLOOOO#..78
 
 	 	LAtS IBLLHHQKKKK IKLL 	 	AHHQKKKK#..0J/KLL 	 	LAtS$(!BBc !R   HHQKKKK G  }Q7???@@CAwt}%%C"3''' ,/.J.'--//**  a??:&& 	(q||L/I/I 	(LMMCHa= C"3'''D[
4x r!   c              #   Z   K   |D ]%}t          j        |          D ]}||v r||fV   n&dS )z
    Generator that yields pairs of all the files in the manifest that are found
    inside the directories listed in dirs, and which directory they are found
    in.
    N)r   rJ   )r&   manifestrR   r9   rQ   s        r   _filesindirsr   d  s\         "1%% 	 	ADyyd


  r!   c           
      	   |                                 }t                      }t                      }t                      }t                      }t                      }	|                    t          j        t          j        t          j        t          j        f          D ]S}
|                    t          j
        |
                     |                    |
          r|                    |
           T|                    t          j        f          D ]}
|	                    |
           |                    t          j        f          D ]%\  }
}}|\  }}}}}|r|	                    |           &|                    t          j        f          D ] \  }
}}|\  }}|	                    |           !|D ]}||v r/||v r|                    |           n|                    |           |                    |          }|rK|d         t          j        t          j        t          j        t          j        fv r|                    |           |D ]}||	vrt#          |                              d          }t'          j        |||t          |                                                    }||                                         p|}|                    |t          j        ||fd           |                    |t          j        |dfd           |r&t#          |                              d          }t3          | ||          D ]\  }
}|
|	vr|                    |          \  }}}t'          j        |||t          |                                                    }|t          j        t          j        fv r|                    ||||           n,|d         }|                    |t          j        ||fd           |                    |t          j        |dfd           |                    |            n|rP|D ],}| j                            t=          d          |z             -t?          j         t=          d	                    d
S )z
    Check if any actions introduce path conflicts in the repository, updating
    actions to record or handle the path conflict accordingly.
    r      +s   local path conflict   ls   path conflicts   remote path conflict   rs#   %s: is both a file and a directory
s,   destination manifest contains path conflictsN)!r   r@   rS   rn   ro   rp   rv   rs   r`   r   rJ   hasdirrL   r   rq   r   getfilebytesrstripr   safename
copysourcert   ACTION_PATH_CONFLICT_RESOLVEACTION_PATH_CONFLICTr   rr   remover"   rx   r   r   ry   )r&   r7   r8   r|   mflocalconflictsremoteconflictsinvalidconflictscreatedfiledirsdeletedfilesr9   r   r+   r   r:   r   r   r   r   rQ   pdctxnamepnewporigr   fls                             r   checkpathconflictsr   q  s   
 
B UUN eeO
 uu eeO 55L]](0&.		
  # # 	x03344499Q<< 	# """]]M79::  !,,m.H-JKK ! !D# $BD# 	!R   !,,		35   D# 	E  $ $77Dyy !$$Q'''' ""1%%%__Q 		$"Q%(0&.	
 
 
   ###   L  Dkk((..G=GT3w}}3G3GHHDG&&((-AEOO:E
&	   OO2t 	    ++$$T** r?;; 	 	DAq$$&q114}Qs7==??7K7KLL!8!.  
 OOD!T37777 aBOO%AB/	   !64L$	    &&q)))3 %6  
! 	I 	IAGLLBCCaGHHHH=>>
 
 	

 
r!   c                 6   |                                 D ]\  }} | |          r|s|                    |           *|d         j        r|                    |           M|d         j        r|                    d          s8|                    |           |                    |d|d         j                   t          d          }t          d          }t          j	        ||z  |          t          d          }t          j
        ||z            dS )	z
    Filters out actions that can ignored because the repo is narrowed.

    Raise an exception if the merge cannot be completed because the repo is
    narrowed.
    r   r   s   outside-narrow-merge-actionsB   merge affects file '%s' outside narrow, which is not yet supporteds'   merging in the other direction may workhints-   conflict in file '%s' is outside narrow cloneN)filemapr   no_opnarrow_safeendswithaddcommitinfochangesr   r   Abortry   )r   r   r|   r9   actionr+   r   s          r   _filternarrowactionsr     sG    __&& , ,	6;q>> 	, 	,q!!!!AY_ 	,q!!!!AY" 	,::d## 6""1%%%%%5vay7H    2  CDDk#'5555FGGC"37+++/, ,r!   c                       e Zd ZdZd Zd Zd ZddZddZd Z	dd
Z
ddZddZd Zed             Zed             Zed             Zed             Zd Zd ZdS )mergeresultzAn object representing result of merging manifests.

    It has information about what actions need to be performed on dirstate
    mapping of divergent renames and other such cases.c                     i | _         i | _        i | _        t          j        t
                    | _        t          j        t
                    | _        dS )aY  
        filemapping: dict of filename as keys and action related info as values
        diverge: mapping of source name -> list of dest name for
                 divergent renames
        renamedelete: mapping of source name -> list of destinations for files
                      deleted on one side and renamed on other.
        commitinfo: dict containing data which should be used on commit
                    contains a filename -> info mapping
        actionmapping: dict of action names as keys and values are dict of
                       filename as key and related data as values
        N)_filemapping_diverge_renamedeletecollectionsdefaultdictdict_commitinfo_actionmappingrC   s    r   rE   zmergeresult.__init__!  sG     &2488)5d;;r!   c                 "    || _         || _        d S r?   )r   r   )rD   divergerenamedeletes      r   updatevalueszmergeresult.updatevalues3  s    )r!   c                     || j         v r| j         |         \  }}}| j        |         |= |||f| j         |<   ||f| j        |         |<   dS )a  adds a new file to the mergeresult object

        filename: file which we are adding
        action: one of mergestatemod.ACTION_*
        data: a tuple of information like fctx and ctx related to this merge
        message: a message about the merge
        Nr   r   )rD   filenamer   datamessageadr   s           r   rt   zmergeresult.addfile7  se     t((('1GAq!#A&x0'-tW&=(#15wF#H---r!   Nc                 2    || j         v r| j         |         S |S )zfreturns (action, args, msg) about this file

        returns default_return if the file is not present)r   )rD   r   default_returns      r   r   zmergeresult.getfileH  s&     t((($X..r!   c              #   `   K   || j         D ]}|V  dS |D ]}| j        |         D ]}|V  dS )zvreturns files on which provided action needs to perfromed

        If actions is None, all files are returned
        Nr   )rD   actionsr9   r   s       r   rS   zmergeresult.filesP  sv       ?&      ,Q/  AGGGG r!   c                 T    | j         |         \  }}}| j         |= | j        |         |= dS )zXremoves a file from the mergeresult object as the file might
        not merging anymoreNr   )rD   r   r   r   r   s        r   r   zmergeresult.removefile`  s9     !% 1( ;gh''111r!   Fc              #      K   |D ]n}|r;t          | j        |                   D ]}| j        |         |         \  }}|||fV   ?| j        |                                         D ]\  }\  }}|||fV  odS )zget list of files which are marked with these actions
        if sort is true, files for each action is sorted and then added

        Returns a list of tuple of form (filename, data, message)
        N)rw   r   r   )rD   r   sortr   r9   r   r+   s          r   rq   zmergeresult.getactionsg  s        	' 	'A ' 3A 677 ' 'A $ 3A 6q 9ID#T3,&&&&' '+&9!&<&B&B&D&D ' 'NA{cT3,&&&&'	' 	'r!   c                 f     |t           j                  S t           fd|D                       S )zreturns number of files which needs actions

        if actions is passed, total of number of files in that action
        only is returnedNc              3   L   K   | ]}t          j        |                   V  d S r?   )lenr   )r   r   rD   s     r   rl   z"mergeresult.len.<locals>.<genexpr>  s3      @@13t*1-..@@@@@@r!   )r   r   sum)rD   r   s   ` r   r   zmergeresult.lenv  s>     ?t()))@@@@@@@@@@r!   c              #      K   t           r4t          | j                                                  D ]\  }}||fV  d S | j                                        D ]\  }}||fV  d S r?   )rw   r   r   )rD   r   keyvals       r   r   zmergeresult.filemap  s       	"4#4#:#:#<#<==  S3h  !-3355  S3h r!   c                 &    || j         |         |<   dS )zdadds key-value information about filename which will be required
        while committing this mergeNr   )rD   r   r   values       r   r   zmergeresult.addcommitinfo  s     +0"3'''r!   c                     | j         S r?   )r   rC   s    r   r   zmergeresult.diverge  s
    }r!   c                     | j         S r?   )r   rC   s    r   r   zmergeresult.renamedelete  s    !!r!   c                     | j         S r?   r   rC   s    r   
commitinfozmergeresult.commitinfo  s    r!   c                     t          j        t                    }| j                                        D ]@\  }}|                                D ]&\  }\  }}||                             |||f           'A|S )z}returns a dictionary of actions to be perfomed with action as key
        and a list of files and related arguments as values)r   r   rI   r   r   append)rD   resr   r   r9   r   r+   s          r   actionsdictzmergeresult.actionsdict  s~     %d++'--// 	. 	.DAq"#'')) . .;D#Aq$n----.
r!   c                     || _         t          j        t                    | _        | j                                         D ]\  }\  }}}||f| j        |         |<   d S r?   )r   r   r   r   r   r   )rD   r   r9   actr   r+   s         r   
setactionszmergeresult.setactions  sj    #)5d;;#'#4#:#:#<#< 	4 	4AT3*.)D$Q''	4 	4r!   c                     | j                                         D ]I}|t          j        t          j        t          j        t          j        fvr| j         |         r
|j        s dS JdS )z^tells whether this merge resulted in some actions which can
        result in conflicts or notTF)r   keysrn   ru   ACTION_EXECr   r   r   )rD   r   s     r   hasconflictszmergeresult.hasconflicts  sy     $))++ 	 	A!,!-!/!>	  '*  ttur!   r?   F)rW   rX   rY   rZ   rE   r   rt   r   rS   r   rq   r   r   r   propertyr   r   r   r  r  r  r   r!   r   r   r     s^       : :
< < <$* * *@ @ @"       2 2 2' ' ' '	A 	A 	A 	A   0 0 0
   X " " X"     X    X4 4 4    r!   r   Fc
                    t                      }
||                                rd}d t                                          ||gz   t          j                  D              t          j                    }t          j                    }i }|rt          j        | ||          \  }}}t          j
        t          |                    }t          j
        t          |                    }t          j
        t          |                    }| j                            t          d                     | j                            d|||fz             | j                            d||fz                                             |                                |                                }}}t#          |j                                                  }|                    |j                                                   t#          |j                                                  }|                    |j                                                   d|v rC                                /t/          fdj        D                       r| j        j        |d<   ||g                                z   vr|	s| j                            d	d
          s| j        dk    st#          |                    |                                                    }|j                                        D ]\  }}||v r|                     |           |j        D ]}|                     |           t	          j!        | |          }tE          j#        ||          }|                    ||          }|                                D ]\  }\  \  }}\  }} |r|r||vr|j        $                    |d          p|j        $                    |d          }!d\  }"}#|!|||!d|%                                f}"d|!z  }#n||dd|%                                f}"d}#|
&                    |tN          j(        |"|#           ||j        v rK|j        |         }!|
&                    |tN          j(        ||!|!d|%                                fd|!z             ||j        v rK|j        |         }!|
&                    |tN          j(        |!||!d|%                                fd|!z             [||         }$|)                    |          }%d|| z   |%z   v}&||$k    r*| |%k    r$|
&                    |tN          j*        dd           ||$k    rp||%k    rj||k    r%|
&                    |tN          j+        | fd           |
&                    |tN          j,        | dfd           |r|
-                    |dd           (|&r+||$k    r%|
&                    |tN          j+        | fd           U|&rE||$k    r?|
&                    |tN          j,        |dfd           |r|
-                    |dd           |
&                    |tN          j(        |||d|%                                fd           |r||v r||j        v ru|j        |         }'|'|v r;|
&                    |'tN          j(        ||'dd|%                                fd           5|
&                    |'tN          j.        ||fd|z             ^||j        v rK|j        |         }'|
&                    |tN          j(        ||'|'d|%                                fd|'z             ||v r|||         k    rz|r$|
&                    |tN          j/        dd           |
&                    |tN          j0        |d|d|%                                fd            |r|
-                    |d!d"           <|| j        j1        k    r$|
&                    |tN          j2        dd#           p|
&                    |tN          j/        dd$           |r|
-                    |d!d"           |
&                    |tN          j3        dd%           |r||v r||j        v ru|j        |         }'|'|v r;|
&                    |'tN          j(        |'|dd|%                                fd&           /|
&                    |'tN          j4        || fd'|z             X||j        v rw|j        |         }'d\  }#}"|'|v r|'||'d|%                                f}"d(|'z  }#n|'||'d|%                                f}"d)|'z  }#|
&                    |tN          j(        |"|#           ||vr|s%|
&                    |tN          j5        | fd*           |s%|
&                    |tN          j5        | fd*           *|
&                    |tN          j6        | |%                                fd+           b|||         k    rd}(|j7        D ]>})|8                    |)          r'|j7        |)         |ts          |)          d         z   }( n?|(B|(|v r>|
&                    |(tN          j(        |(||d|%                                fd,|z             |r%|
&                    |tN          j5        | fd-           "|
&                    |tN          j:        d||d|%                                fd.           |r|
-                    |d!d"           v|
&                    |tN          j;        dd/           |r|
-                    |d!d"           | j                            d	d0          rty          | ||
           | =                                }*|*                                st}          |*||
           |j?        }+|+                    |j?                   |
@                    ||+           |
S )1a  
    Merge wctx and p2 with ancestor pa and generate merge action list

    branchmerge and force are as passed in to update
    matcher = matcher to filter file lists
    acceptremote = accept the incoming changes without prompting

    Returns an object of mergeresult class
    Nc                 6    g | ]}|                                 S r   )r   )r   xs     r   r    z!manifestmerge.<locals>.<listcomp>  s0        	


  r!   )r   s   resolving manifests
s)    branchmerge: %s, force: %s, partial: %s
s%    ancestor: %s, local: %s, remote: %s
   .hgsubstatec              3   f   K   | ]+}                     |                                          V  ,d S r?   )subdirty)r   sr7   s     r   rl   z manifestmerge.<locals>.<genexpr>  s9      ::qtxx{{  ""::::::r!   r]   s   merge-track-salvageds   changeset-sidedata)r   NNFs   both renamed from %ss   both createds   local replaced from %ss   other replaced from %sr   r   s   remote unchangeds   update permissionss   remote is newers   filenode-sources   others   versions differTs%   remote directory rename, both createds&   remote directory rename - move from %ss   local copied/moved from %ss   remote deletes   prompt changed/deleteds   merge-removal-candidate   yess   remote deleteds   other deleteds    ancestor missing, remote missings$   local directory rename, both createds$   local directory rename - get from %ss   remote copied from %ss   remote moved from %sri   s   remote created, get or merges-   local directory rename - respect move from %ss   remote recreatings   prompt deleted/changeds#   local not present, remote unchangedr^   )Ar   r   rw   parentsr   intrevr	   branch_copiesmergecopiesr   bytestrboolr"   noter   debugr   r@   copyvaluesr`   movewithdirrevrz   substatenodeconstantsmodifiednodeidrm   filecopiesmodediffr	  r   rL   
matchfilesmatchmodintersectmatchersgetnodert   rn   rv   r   ACTION_KEEPr
  ru   r   r   r   r   addednodeidr   ACTION_KEEP_NEWrr   ro   rs   dirmover   r   rp   ACTION_KEEP_ABSENTr   r   r   r   r   ),r&   r7   p2par   r{   matcheracceptremotefollowcopiesforcefulldiffr|   branch_copies1branch_copies2r   boolbmboolfboolmm1m2macopied1copied2relevantfilescopykey	copyvalue
movedirkeyfilesmatcherr(  r9   n1fl1n2r   r   r   r+   r   flanolr:   dfr   r   r   s,    `                                          r   manifestmergerN    s   * mmGw~~// "b1w~FFF   
 )++N)++NG  
282D$B3
 3
/ d;//00FT%[[))ET']]++EGLL+,,---GMM58NN   	GMM;r4nLMMM"++--BB.%,,..//GNN>-4466777.%,,..//GNN>-4466777

 2 ::::DM::::: 	C!%!3!BB~ 	D":.// 	0 G0GHH 	0 "&;;; BGGBKK,,..// #1"5";";"="= 	+ 	+GYM))!!'***(4 	* 	*Jj)))))$>>,WlCC772W7%%D%)ZZ\\ QQ QQ!!IRyC P	Q" P	Q{{#(,,t  6#(,,Q55  '	c>q"eRWWYY7D1B6CCq$rwwyy9D)C=#=tSIIIIn)))#(+!.Brwwyy1-2	    n)))#(+!.Brwwyy1-2	    qEhhqkk#)c/177sczzOO%1+	    1WWRxx)5 F1	     )4 %L.	   ' #11 !#5x    R1WWOO%1-	     R1WWOO%0e*	   # O--a1CXNNNOO%2Aq%3*	     }	QG||^///#/288OO%2BdBGGII6@	    OO%BCAAE	    n)))#(+!.Brwwyy11B6	    bA;;# )7 ,	     )@a		:5	   ' #11 !#=v   4-999 OO%3)	    OO%3(	   # 
  --96  
 !17	     k	QG||n000#/288OO%2QeRWWYY7?	    OO%AC?!C	    n)))#(+&	T882ubggii8D2R7CC2tRWWYY7D1B6C=#=tSIIII"  OO%4)	    % OO%4)	    OO%:bggii(7	    r!u'/  A||A +3A63q6688D >bBhhOO%2Q5"''))4#%&'	    " OO%4,	    OO%<q!UBGGII61	   # --96   !4:	    Q
 ))!-GPPPw/+FGG 44r7333""$$K @[+w???!.L3444,///Nr!   c                    t          |                    t          j        f                    D ]I}||v rC||                             ||                   s"|                    |t          j        dd           Jt          |                    t          j        f                    D ]<}||v r6||                             ||                   s|                    |           =dS )zXResolves false conflicts where the nodeid changed but the content
    remained the same.Ns   prompt same)	rI   rS   rn   r   r6   rt   r   rp   r   )r&   r7   r8   ancestorr|   r9   s         r   _resolvetrivialrQ  ?  s    
 '--!E GHHII  ==aXa[!9!9=OO=.n   '--!E GHHII " "==aXa[!9!9=q!!!" "r!   c
                    ddl m}
 d}t          |          dk    r3t          | |||d         |||||	  	        }t	          | |||||	           n;| j                            t          d          ||t          d                              d |D                       fz             i }t                      }d\  }}|D ]d}| j                            t          d	          |z             t          | ||||||||d

  
        }t	          | |||||	           |%t          |j
                  t          |          k     r|j
        }|%t          |          t          |j                  k     r|j        }|j                            |j                   |                    d
          D ]x\  }}|\  }}}| j                            d|||                                fz             ||v r/||         }||v r||                             |           i|g||<   p||gi||<   yf| j                            t          d          t          |          z             t%          |                                          D ]\  }}| j        j        r~| j                            d|z             t%          |                                          D ]?\  }D ]7\  }}}| j                            d||                                fz             8@t          |          dk    rt+          |                                          d         \  }t-          fddd         D                       rT| j                            t          d          ||                                fz              |j        |gd         R   Dt0          j        |v rP| j                            t          d          |z              |j        |g|t0          j                 d         R   t0          j        |v rP| j                            t          d          |z              |j        |g|t0          j                 d         R    t0          j        |v r^t0          j        |v rP| j                            t          d          |z              |j        |g|t0          j                 d         R   lt0          j        |v rP| j                            t          d          |z              |j        |g|t0          j                 d         R   t0          j        |v r^t0          j        |v rP| j                            t          d          |z              |j        |g|t0          j                 d         R   6t0          j        |v r|t0          j                 d         t-          fd|t0          j                 dd         D                       r:| j                            t          d          |z              |j        |gR   | j                            t          d          |z             t%          |                                          D ]?\  }D ]7\  }}}| j                            d||                                fz             8@t+          |                                          d         \  }| j                            t          d          ||                                fz              |j        |gd         R   | j                            t          d                     |                     ||           |!                                tE          ||||           |
#                    | ||||           tI          | |||d         |           |S )a  
    Calculate the actions needed to merge mctx into wctx using ancestors

    Uses manifestmerge() to merge manifest and get list of actions required to
    perform for merging two manifests. If there are multiple ancestors, uses bid
    merge if enabled.

    Also filters out actions which are unrequired if repository is sparse.

    Returns mergeresult object same as manifestmerge().
    r   sparseNr   s5   note: merging %s and %s using bids from ancestors %s
s    and c              3   >   K   | ]}t          j        |          V  d S r?   )r   r  )r   r   s     r   rl   z#calculateupdates.<locals>.<genexpr>  s-       L L3!1#!6!6 L L L L L Lr!   r  s"   
calculating bids for ancestor %s
T)r8  r       %s: %s -> %s
s/   
auction for merging merge bids (%d ancestors)
s    list of bids for %s:
s      %s -> %s
c              3   0   K   | ]}|d          k    V  dS )r   Nr   )r   r   ls     r   rl   z#calculateupdates.<locals>.<genexpr>  s+      00QqAaDy000000r!   s    %s: consensus for %s
s    %s: picking 'keep' action
s"    %s: picking 'keep absent' action
s&    %s: picking 'changed/deleted' action
s    %s: picking 'keep new' action
s%    %s: picking 'delete/changed' action
c              3   $   K   | ]
}|k    V  d S r?   r   )r   r   ga0s     r   rl   z#calculateupdates.<locals>.<genexpr>  s'      LLAqCxLLLLLLr!   s    %s: picking 'get' action
s%    %s: multiple bids for merge action:
s     %s -> %s
s(    %s: ambiguous merge - picked %s action
s   end of auction

)% rT  r   rN  r   r"   r  r   r$   r   r   r   r   r`   r   r  	__bytes__r  rw   r   	debugflagrI   allrt   rn   r.  r2  r   r0  rp   ru   rx   r   r#  r   filterupdatesactionsrQ  )r&   r7   r8   	ancestorsr   r{   r6  r7  r5  r}   rT  r|   fbidsr   r   rP  mresult1r9   r   r   r   r+   r   bids_fr[  rY  s                            @@r   calculateupdatesrf  Q  se   0 G
9~~aL

 

 	4tUGZHHHH 	GHH(   L L) L L LLL	
 	
 	
 -- *! )	( )	(HGLLBCChNOOO$"  H tT4*MMM #h&6"7"7#g,,"F"F"*#s<'8'83%< < ( (  (4 &&x';<<< ((d(33 
( 
(1 40AsAKKMM3JJKKK::aAAvv!A !s! !A3xE!HH
( 	BCC)nn	
 	
 	
 ekkmm,, O	 O	GAtw  O81<==="4::<<00 O ODAq)* O OD#&6#q{{}}9M&MNNNNO 4yyA~~DJJLL))!,10000!ABB%00000 GLL455AKKMM8JJ   $GOA-!----(D00Q>??!CDDDGD)B$CA$FGGGG/477QEFFJKKKND)I$J1$MNNNN 4<<!1T99QIJJQNOOO]AB1E    ,44QBCCaGHHHKD)F$G$JKKKK 4<<!,44QHIIAMNNN]AB1E    '4//=34Q7LLLLm.F)G)KLLLLL GLL#A!B!BQ!FGGG#GOA,,,,, GLLDEEIJJJtzz||,, I I1%& I IMBcGLLC3G!GHHHHI 

%%a(DAqGLL>??akkmm$%   GOA%!%%%%Q,--...Wl333xxzztT;888
dD+wGGGD$ilG<<<Nr!   c                  L    	 t          j                    S # t          $ r Y d S w xY wr?   )r
   getcwdFileNotFoundErrorr   r!   r   _getcwdrj    s7          tts    
##c           	   #     K   | j         j        }t                      }d}|D ]\  }}}| j                             d||fz             |r*| j                             t          d          |z             ||                                          	 ||                             d           nZ# t          $ rM}	| j         	                    t          d          |t          j        |	j                  fz             Y d}	~	nd}	~	ww xY w|dk    r||fV  d}|d	z  }|dk    r||fV  |r?t                      s3| j         	                    t          d
          | j        z             dS dS dS )zSapply removes to the working directory

    yields tuples for progress updates
    r   s    %s: %s -> r
   removing %s
T)ignoremissings    update failed to remove %s: %s!
Nd   r   sC   current directory was removed
(consider changing to repo root: %s)
)r"   verboserj  r  r  r   r1   r   OSErrorrx   r   forcebytestrstrerrorroot)
r&   r7   r   ro  cwdir9   r   r+   insts
             r   batchremoverw     s     
 goG
))C	A  4'1c(2333 	2GLL+,,q0111Q	GNNN.... 	 	 	GLL677j-dm<<=>       	
 88Q$JJJA	Q1uud



 	
799 	
 	:  i		
 	
 	
 	
 	
	
 	
 	
 	
s   B**
D4AC<<Dc              #   b  K   i }| j         j        }|j        }| j         }d}	| j                            |t          |                    5  |D ]\  }
\  }}}| j                             d|
|fz             |r*| j                             t          d          |
z             |r|
}| j        	                    |
          s5t          j        |
          D ] }| j                            |          r|} n!| j        	                    |          r>t          j        || |          }t          j        |                     |          |           ||
         }|                                 |                    dd          }|                     ||
                                          |d|          }|r7|                                }|j        }t1          j        |          }|||f||
<   |	d	k    r
d
|	|
ffV  d}	|	dz  }		 ddd           n# 1 swxY w Y   |	dk    rd
|	|
ffV  d|fV  dS )aj  apply gets to the working directory

    mctx is the context to get from

    Yields arbitrarily many (False, tuple) for progress updates, followed by
    exactly one (True, filedata). When wantfiledata is false, filedata is an
    empty dict. When wantfiledata is true, filedata[f] is a triple (mode, size,
    mtime) of the file f written for each action.
    r   )expectedcounts    %s: %s -> g
s   getting %s
r]   s   update.atomic-fileT)backgroundclose
atomictemprn  Fr   N)r"   ro  filectxr0   backgroundclosingr   r  r  r   rK   r   rJ   r3   r   
backuppathr   renamewjoinclearunknownrm   writer   lstatst_moder   mtime_of)r&   r8   r7   wantfiledatar   filedataro  fctxr"   ru  r9   r   r   r+   conflictingrQ   origwfctxr{  sizer  modemtimes                          r   batchgetr  G  s      HgoG<D	B	A		$	$Rs7||	$	D	D A A'. @	 @	#AvGMM+q#h6777 5Q//!3444 ?  y((++ "%.q11 " "911!44 "*+K!E" 9$$[11 ?"-b$DDDK

; 7 7>>>GE   8MNNJ;;Q $%	   D  !2: KKMMy!*1--#T51CxxaVm###FAAA@	A A A A A A A A A A A A A A AD 	1uuaVm
.s   
F9HHHc                    |                     t          j        t          j        t          j        t          j        g          }t          j        }t          j        } || |	                                 || |          fg           dS )zInvoke ``scmutil.prefetchfiles()`` for the files relevant to the dict
    of merge actions.  ``ctx`` is the context being merged in.N)
rS   rn   ru   rp   rr   rv   r   prefetchfilesr)  r#  )r&   ctxr|   rS   prefetchr)  s         r   _prefetchfilesr    s     MM$05&		
 E $H#JH 		
4''	
    r!   T)frozenc                       e Zd Z ej                    Z ej                    Z ej                    Z ej                    Zd Z	dS )updateresultc                 <    | j         p| j        p| j        p| j         S r?   )updatedcountmergedcountremovedcountunresolvedcountrC   s    r   isemptyzupdateresult.isempty  s5     $$ $ #	
 	
r!   N)
rW   rX   rY   r   ibr  r  r  r  r  r   r!   r   r  r    sW        4799L$'))K4799LdgiiO
 
 
 
 
r!   r  c                 F   t          | ||           d\  }}}	|                    d          }
|
                    |                                                                |                                |           |j                                        D ]\  }}|
                    ||           |                    t          j
        j                  }|                                |z
  }| j                            t          d          t          d          |          }d|j        t          j                 v rt#          j        | |||||           |                    t          j        gd          D ]\  }}}|\  }}| j        j        } |t          d	          |z             |d
k    r |t          d          |z             n |t          d          |z              |t          d          |z             |
                    |||           |                    |           |                                rdnd}t3          j        | j        |t4          | |ft7          |                    t          j        gd                              }|D ]\  }}|                    ||           |                    t          j        f          }	|                    t          j        gd          D ]!\  }}}| j                            d||fz             |\  }}||                                         r| j                            t          d          ||fz             ||                                           ||         !                    |"                    |          #                                |"                    |          $                                           ||         %                                 |                    |           #| j        &                    dd          }t3          j        | j        |tN          | |||ft7          |                    t          j(        gd                    |d          }i }|D ]&\  }}|r|}
|\  }}|                    ||           'd|j        t          j(                 v rt#          j        | |||||           |                    t          j)        fd          D ];\  }}}| j                            d||fz             |                    |           <|                    t          j*        fd          D ];\  }}}| j                            d||fz             |                    |           <|                    t          j+        fd          D ];\  }}}| j                            d||fz             |                    |           <t          j
        j        D ]S}|                    |fd          D ]8\  }}}| j                            d|||,                                fz             9T|                    t          j-        fd          D ]\  }}}| j                            d||fz             |                    |           |\  }} | j                            t          d          ||fz             ||                                           ||         !                    |"                    |          #                                |            ||         %                                 |                    t          j.        fd          D ]\  }}}| j                            d||fz             |                    |           |\  }} | j                            t          d          ||fz             ||         !                    |"                    |          #                                |            |                    t          j/        fd          D ]y\  }}}| j                            d||fz             |                    |           |\  } ||                                           ||         0                    d
| v d| v            zg }!t7          |                    t          j1        t          j2        t          j3        gd                    }"|"D ]\  }}}|\  }}#}$}%}&|dk    r|ti          j5        ||$          }'n'| j                            d!||fz             ||         }'|#ti          j5        ||$          }(n||#         }(| |&         })|$|)v r	|)|$         }*n| "                    |tl          "          }*|
7                    |'|(|*|           ||k    r|%r|!8                    |           |!D ]m}||                                         rQ| j                            d#|z             ||                                           ||         %                                 n|                    t          j(        t          j/        t          j.        t          j-        f          }	 |"D ]\  }}}| j                            d$||fz             |
                    |d%d&i           |                    |           |dk    r-t#          j        | |||9                    |          ||           ||                                           |
:                    ||           n# tv          j<        $ r Y nw xY w|
=                                 n# |
=                                 w xY w|
>                                }+|
?                                \  },}-}.||,z  }||-z  }|	|.z  }	|
@                                }/|A                                 t          |||	|+          ||/fS )'a  apply the merge action list to the working directory

    mresult is a mergeresult object representing result of the merge
    wctx is the working copy context
    mctx is the context to be merged into the working copy

    Return a tuple of (counts, filedata), where counts is a tuple
    (updated, merged, removed, unresolved) that describes how many
    files were affected by the update, and filedata is as described in
    batchget.
    )r   r   r   T)cleans   updatings   files)unittotalr  rV  sD   %s: path conflict - a file or link has the same name as a directory
r   s&   the local file has been renamed to %s
s'   the remote file has been renamed to %s
s1   resolve manually then use 'hg resolve --mark %s'
)itemr   gMbP?)stepr  s    %s: %s -> pr
s   moving %s to %s
r]   s   worker.wdir-get-thread-safe)
threadsafe	hasretvals    %s: %s -> f
s    %s: %s -> a
s    %s: %s -> am
rW  s    %s: %s -> dm
s    %s: %s -> dg
s   getting %s to %s
s    %s: %s -> e
   xNs!    preserving %s for resolve of %s
)fileidrl  s    %s: %s -> m
s   mergedr  )Cr  r   startp1r-  r   r   r   r   rn   MergeActionNO_OP_ACTIONSr"   makeprogressr   r   r   r   submergerq   r   statusaddpathconflict	incrementr/   r   rw  rI   r   r  rK   r  r1   r  r|  r   r   r   rm   r  ru   r   r   r   r]  r   rr   r
  setflagsr   rp   rv   r   absentfilectxr   rL   r  rP  resolver   InterventionRequiredcommitr  countsr   completer  )0r&   r|   r7   r8   	overwriter  labelsupdatedmergedr   msr9   op	num_no_op
numupdatesprogressr   r+   r   for  costprogru  r  f0origf0r  getfiledatafinalr  r   r   movesmergeactionsr:   r   r   r   fclfcoactxfca
unresolved	msupdatedmsmerged	msremovedextraactionss0                                                   r   applyupdatesr    s   * 4w'''&GVW	t	$	$BHHTWWYY^^tyy{{F333#))++    2 	BM5CDDI*Jw##	+Qx[[
 $  H /0KLLLT4tYGGG  **		+,4 +   # #4 BGN	  		
 	
 	
 ::Aa:;;b@AAAAAa;<<rABBB	!A
B
BQ
FGGG
1b"%%%"""" !!,11uD =	tW!< =DIIJJ D  . .4----kk=6899G  **		344 +   
# 
#4 	(As83444V8 	GLL/00B7:;;;GMMOOOGMM$,,r**//114<<3C3C3I3I3K3KLLLHOO"""" ##7 J =	tT<(W!9 :FFGG  D K 2 2
s 	2KKGAtAD1111/0HIIIT4tYGGG  **		$&T +   # #4 	'1c(2333""""  **		!#$ +   # #4 	'1c(2333""""  **		*,4 +   # #4 	(As83444"""" &4 H H#..t$.?? 	H 	HLAtSGMM,3/FFGGGG	H
  **		35D +   	 	4 	(As83444"""	EQ+,,Aw6777QQdll2&&++--u555R  **		244 +   6 64 	(As83444"""	EQ,--Q7888Qdll2&&++--u5555  **		"$4 +   7 74 	'1c(2333"""QQ6666E 44*
  	 	
 	
	 	L %  4 $BD#:)$33CCGMM?2q'IJJJr(C:)$33CCr(CCy::r(CC ,,r',22C
sCa   77t7LL   7?? 	GMM*Q.///GMMOOOGNN kk$%56		
 G( 
	  
	 LAtSGMM+q#h6777QF 3444A&&&N""$$dmmD&9&99f   GMMOOOJJq$
	  %    	
 					##%%J%'YY[["IxyG
hFyG::<<LWfgz:: s+   .B9m( 'n (m:7n 9m::n n(c                 :   | j                             dd          }| j                             dd          }t          j        d          }|| j                             dd          }	 ddlm} |                    d           | j                             dd          d	k    }n# t          $ r d
}Y nw xY w|r[|s[|| j
        k    rR||k    rNt          j                            d          r1| j                             t          d                     d S d S d S d S d S d S )Ns	   fsmonitors   warn_when_unuseds   warn_update_file_countr4   s   warn_update_file_count_rustr   )
extensionss   modes   offF)s   linuxs   darwins   (warning: large working directory being used without fsmonitor enabled; enable fsmonitor to improve performance; see "hg help -e fsmonitor")
)r"   rm   	configintr   
importrustr\  r  findr#   KeyErrornullidr   sysplatformr   rx   r   )r&   num_getsp1nodefsmonitorwarningfsmonitorthresholddirstate_rustmodr  fsmonitorenableds           r   _advertisefsmonitorr    s    w)),8KLL**/  (44#!W..*
 


!      %%%7>>,@@FJ  ! ! ! ! 	
 
 dk!!*** ++,ABB + 	1 	
 	
 	
 	
 	

 
 
 
 "!****s   ):B$ $B32B3r   s   nones   linears
   noconflictc                     ddl m} |J |s;|s9|
t          }
t          t          t          f}|
|vrd}||
|fz  }t          |          |(|                                rt          j                    }n 	                                }|5  | d         }|
                                }|d         } |         }|
 |         g}n j                            dd          dgk    rc j                            |                                |                                          } fd	t!          |          p j        gD             }n|                    ||
          g}|                                |                                t'          |          t'          |          f\  }}}}|o| }|st)          |          dk    r!t+          j        t/          d                    |                                }|                                r4t/          d          }t/          d          }t+          j        ||          |rBt/          d          }||gk    rt+          j        |          ||gk    r`|s^|                                |                                k    r4t/          d          }t/          d          }t+          j        ||          |s\|                                s|                                r4t/          d          }t/          d          }t+          j        ||          |                                s>t!          |j                  D ])}|                    |                                            *n|s||k    rP !                    dd|d            !                    d|dd           tE          dddd          cddd           S |
t          k    r||g|gfvr|#                    d          }|rytI          j%         |                                g          } |                                         |v rn5t/          d          }t/          d          }t+          j&        ||          	 |r|g}n|s|g} j        '                    dd          } |rd} n
|d         sd} |s|#                    d          sd} tQ           ||||||| ||
  
        }!|
t          k    rH|!)                                r4t/          d          }t/          d          }t+          j        ||          |!*                    d           }"|"rdd }#|"\  }$}%}tW          j,        |          }&|#|&d!<   |$tZ          j.        k    r j        /                    t/          d"          |&z  d          r#|!0                    |#tZ          j1        dd#           n|#|v r#|!0                    |#tZ          j2        dd$           n|!0                    |#tZ          j3        dd$           n|$tZ          j4        k    r|%\  }'}(})}*}+||(         5                                }, j        /                    t/          d%          |&z  d          dk    r%|!0                    |#tZ          j6        |,dfd&           n|!7                    |#           t          j8         j9                  sb|s=|s|#                    dd'          s$tu           |;                                d           n#tu           |;                                |!           t!          |!j<        =                                          D ]^\  }#}- j        >                    t/          d(          |#z             t!          |-          D ]}. j        >                    d)|.z              _t!          |!j?        =                                          D ]^\  }#}- j        >                    t/          d*          |#z             t!          |-          D ]}. j        >                    d)|.z              _|s| j        |df\  }}}}|du p|@                                }/|	o|/o|                                 }	|	rF !                    dd||            jA        B                    d+|C                                           t           |!                    tZ          j6        f          |                                           |	o| }0t           |!||||0|,          \  }1}2}3|	r|3r^|3=                                D ]I\  }4}5|5D ]}6 |!j0        |6d         |4g|6dd         R    |4tZ          j6        k    r|0r|5D ]}6d|2|6d         <   Jt)          |2          |0r |!                    tZ          j6        f          ndk    sJ  jF        G                                5  |2ri }7t          jI         jA                  }8|8d}2ni|8d         }9|2=                                D ]-\  }#}$|$&|$d-         d         |9k    r|$d         |$d         df|7|#<   .|7=                                D ]
\  }#}$|$|2|#<    J                    ||           t[          jK         |!jL        ||2           t          jM         jA        N                    d+                     |s, jF        O                    |                                           |s|P                                ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |	r !                    d|||1j                   |1S ).a	  
    Perform a merge between the working directory and the given node

    node = the node to update to
    branchmerge = whether to merge between branches
    force = whether to force branch merging or file overwriting
    matcher = a matcher 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.
    labels = labels to use for local, other, and base
    mergeforce = whether the merge was run with 'merge --force' (deprecated): if
      this is True, then 'force' should be True as well.

    The table below shows all the behaviors of the update command given the
    -c/--check and -C/--clean 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 or not). Match from top first. The -n
    option doesn't exist on the command line, but represents the
    experimental.updatecheck=noconflict option.

    This logic is tested by test-update-branches.t.

    -c  -C  -n  -m  dirty  rev  linear  |  result
     y   y   *   *    *     *     *     |    (1)
     y   *   y   *    *     *     *     |    (1)
     y   *   *   y    *     *     *     |    (1)
     *   y   y   *    *     *     *     |    (1)
     *   y   *   y    *     *     *     |    (1)
     *   *   y   y    *     *     *     |    (1)
     *   *   *   *    *     n     n     |     x
     *   *   *   *    n     *     *     |    ok
     n   n   n   n    y     *     y     |   merge
     n   n   n   n    y     y     n     |    (2)
     n   n   n   y    y     *     *     |   merge
     n   n   y   n    y     *     *     |  merge if no conflict
     n   y   n   n    y     *     *     |  discard
     y   n   n   n    y     *     *     |    (3)

    x = can't happen
    * = don't-care
    1 = incompatible options (checked in commands.py)
    2 = abort: uncommitted changes (commit or update --clean to discard changes)
    3 = abort: uncommitted changes (checked in commands.py)

    The merge is performed inside ``wc``, a workingctx-like objects. It defaults
    to repo[None] if None is passed.

    Return the same tuple as applyupdates().
    r   rS  Nz&Invalid updatecheck %r (can accept %r)r   r\   s   preferancestor   *c                      g | ]
}|         S r   r   )r   r   r&   s     r   r    z_update.<locals>.<listcomp>o  s    LLLStCyLLLr!   )rx   s   outstanding uncommitted merges   outstanding merge conflictss   use 'hg resolve' to resolver   s7   merging with a working directory ancestor has no effects   nothing to merges#   use 'hg update' or check 'hg heads's   uncommitted changess   use 'hg status' to list changess	   preupdateTr!   )throwparent1parent2s   update)r  r  r   )missings+   commit or update --clean to discard changess   followcopiesF)r5  r}   s   conflicting changesr     fsj   local%(l)s changed %(f)s which other%(o)s deleted
use (c)hanged version or (d)elete?$$ &Changed $$ &Deletes   prompt deletes   prompt keepsr   other%(o)s changed %(f)s which local%(l)s deleted
use (c)hanged version or leave (d)eleted?$$ &Changed $$ &Deleteds   prompt recreating)r  branchs<   note: possible conflict - %s was renamed multiple times to:
s    %s
s9   note: possible conflict - %s was deleted and renamed to:
s   updatestate)r     )Qr\  rT  UPDATECHECK_LINEARUPDATECHECK_NONEUPDATECHECK_NO_CONFLICT
ValueErrorr/   r   nullcontextmanagerwlockr  r"   
configlist	changelogcommonancestorsheadsr-  rw   r  rP  r   r   r   ry   r   r   r  r   r  rS   r   r$  r  bailifchangedhookr  r  r   
foregroundUpdateAbortrm   rf  r  r   r   
partextrasrn   r   promptchoicert   r   r   r   rp   r   ru   r   fscasesensitiver   r   r   r   r   rx   r   r   vfsr  hexr  r  r4   parentchanger   
get_fs_now
setparentsrecordupdatesr  unlinkr$   	setbranchprunetemporaryincludes):r&   r-  r   r{   rP  mergeancestorr  r5  r}   updatedirstateupdatecheckwcrT  okayr+   maybe_wlockplr  r3  pascahsfp1fp2xp1xp2r  r  r   m_ar  r  r  r7  r|   valsr9   r   r   promptsr   r:   r   r   r   r   r   nfr   r  statsr  r  kactsr   ambiguous_mtimenownow_secs:   `                                                         r   _updater    sy   F   
"u 
" ,K "46MNd"";CK&&CS//!	~"--//~-//jjll	 @8 @8:dBZZ\\U$Z>"CCw!!(,=>>4&HH~::27799bggiiPPLLLLVD\\-Jdk]LLL{{2K{889WWYY		599eBiiGS#s-+o	 	72ww{{&q)I'J'JKKKB!!## 7677788&s6666 *	NOOCrd{{k#&&&$ 6		)C)C/00CCDDD+c5555 7bhhjj 7BJJLL 7.//;<<&s6666==?? .,, . .AFF1II++---- 	Rxx		,dC	MMM		)S#Q	GGG#Aq!Q//c@8 @8 @8 @8 @8 @8 @8 @8f 000SA 6 6 ..  ")!3D27799+!F!FJDz((J66 677 !OPP#/$????  	$CC 	$C w))(ODD 	! LLQ 	! L 	!288D8#9#9 	! L #!
 
 
 111##%% 7.//GHH&s6666
 ~.. 9	*ALAtS*622GGDMM8887''2 
     OO%3(	    "WWOO%9&	    OO%0&	    m:::(,%BD#2G((7 
 ""   	 	 OO%0,	    &&q)))#DI.. 	> >>XXd5XAA>  bkkmmT::::bkkmmW=== GO113344 		, 		,EArGLL,  	   Rjj , ,X]++++, G0668899 		, 		,EArGLL)  	   Rjj , ,X]++++,  	<!$dk3!;Cc3 D4GNN$4$4'JFJ2==??7J 	5IIl$SIIIIHNN>26688444'++}79::BGGII	
 	
 	
 &9k/+7,
 ,
 ,
({L  \	8 5+1133 5 5GAt! 9 9'!a8!ABB%88888M4444!% 5 5A04K!--{##<HO]57888a    ++-- O8 O8d  /&(O#.tx88C{ '+"%a&$/$5$5$7$7 H HDAq }1aG1C1C67dAaD$5G 2$3$9$9$;$; / /DAq-.KNNS)))+'-{K   DHMM.99:::" 9M++BIIKK888 # 811$777_O8 O8 O8 O8 O8 O8 O8 O8 O8 O8 O8 O8 O8 O8 O8c@8 @8 @8 @8 @8 @8 @8 @8 @8 @8 @8 @8 @8 @8 @8D
  
		sCu7L 	 	
 	
 	
 Ls?   	Ml-W?l-D/l
l-l	l-l	l--l14l1c           	      v    t          |                                 |                                 |d|||          S )zMerge another topological branch into the working copy.

    force = whether the merge was run with 'merge --force' (deprecated)
    T)r  r   r{   r}   r
  r  r&   r#  )r  r  r{   r
  s       r   merger!    s@     

		   r!   c           	      z    t          |                                 |                                 ddg d||          S )a  Do a regular update to the given commit, aborting if there are conflicts.

    The 'updatecheck' argument can be used to control what to do in case of
    conflicts.

    Note: This is a new, higher-level update() than the one that used to exist
    in this module. That function is now called _update(). You can hopefully
    replace your callers to use this new update(), or clean_update(), merge(),
    revert_to(), or graft().
    F)s   working copys   destinations   working copy parent)r   r{   r  r	  r
  r   )r  r	  r
  s      r   r`   r`     sF     

		HHH   r!   c                 r    t          |                                 |                                 dd|          S )zDo a clean update to the given commit.

    This involves updating to the commit and discarding any changes in the
    working copy.
    FT)r   r{   r
  r   )r  r
  s     r   clean_updater$    s-     388::swwyye4BOOOOr!   c           	      v    t          |                                 |                                 ddd||          S )zRevert the working copy to the given commit.

    The working copy will keep its current parent(s) but its content will
    be the same as in the given commit.
    FT)r   r{   r  r5  r
  r   )r  r5  r
  s      r   	revert_tor&    s@     

		   r!   c           
         |p| d         }|                                 }|p|                                 }| j                            |                                |                                          p)|                                |                                k    }t          | |                                dd|                                |||          }	|r|	j        r|                                }
nc| j        }
|                                }|rFt          |          dk    r3||v r/|
                    |           |d                                         }
|
|                                k    r| j        }
|                                r?|                    |                                |
           t          j        |||           n| j                                        5  |                     |                                |
           | j                            |                                            t          j        |||           ddd           n# 1 swxY w Y   |	S )aI  Do a graft-like merge.

    This is a merge where the merge ancestor is chosen such that one
    or more changesets are grafted onto the current changeset. In
    addition to the merge, this fixes up the dirstate to include only
    a single parent (if keepparent is False) and tries to duplicate any
    renames/copies appropriately.

    ctx - changeset to rebase
    base - merge base, or ctx.p1() if not specified
    labels - merge labels eg ['local', 'graft']
    keepparent - keep second parent if any
    keepconflictparent - if unresolved, keep parent used for the merge

    NT)r  r  r
  r  r   )r  r  
isancestorr-  r#  r  r  r  r  r   r   r/   r  r	   graftcopiesr4   r   r  currenttransaction)r&   r  baser  
keepparentkeepconflictparentr7   pctxr  r  potherr  s               r   graftr0    sV   @ 4:D7799D36688D!!$))++sxxzz:: 	$88::# 
 

		#	 	 	E  'e3 '++-- 	'#g,,!++NN4   QZ__&&F 	0		V,,,4d++++]'')) 	0 	0OODIIKK000M 7 7 9 9:::tS$///		0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0
 Ls   %A+II #I c                     |>|                                  d}t          j        |          |                                 }t	          |                                 |dd|                                 d          S )Ns/   must specify parent of merge commit to back outTF)r   r{   rP  r  )r3  r   ProgrammingErrorr  r  r&   r-  )r  parentr
  r+   s       r   back_outr4  ;	  sq    ~6688DC(---

   r!   c	                      fd}	|j         }
g }	 |rg }|j        |_                              |||          }|rd}t          |j                  }t          |j                  }|r|rt          d          }|||fz  }nw|rt          d          }||z  }n`|rt          d          }||z  }nI|rGd}|D ],} ||          r j                            |          s|dz  }-|rt          d	          }||z  }|	||
|_         S |d
z  } j	        
                    |d          dk    r!t          j        t          d                    |rvt          |j        |j        z             D ]Y}|s@ j	                            t          d          |z              |	 j        j        |           |                    |           Z|rt          |d          D ]~} ||          rq j                            |          sW|s@ j	                            t          d          |z              |	 j        j        |           |                    |           ||
|_         S # |
|_         w xY w)a  Purge the working directory of untracked files.

    ``matcher`` is a matcher configured to scan the working directory -
    potentially a subset.

    ``unknown`` controls whether unknown files should be purged.

    ``ignored`` controls whether ignored files should be purged.

    ``removeemptydirs`` controls whether empty directories should be removed.

    ``removefiles`` controls whether files are removed.

    ``abortonerror`` causes an exception to be raised if an error occurs
    deleting a file or directory.

    ``noop`` controls whether to actually remove files. If not defined, actions
    will be taken.

    ``confirm`` ask confirmation before actually removing anything.

    Returns an iterable of relative paths in the working directory that were
    or would be removed.
    c                     	  | |           d S # t           $ rV t          d          |z  }rt          j        |          j                            t          d          |z             Y d S w xY w)Ns   %s cannot be removeds   warning: %s
)rp  r   r   r   r"   rx   )removefnr   r   abortonerrorr&   s      r   r   zpurge.<locals>.removeo	  s    	6HTNNNNN 	6 	6 	6)**T1A 6k!nn$Q/0014555555	6s    AA0/A0)r   ignoredunknownNs3   permanently delete %d unknown and %d ignored files?s$   permanently delete %d unknown files?s$   permanently delete %d ignored files?r   r   s1   permanently delete at least %d empty directories?s    (yN)$$ &Yes $$ &No)defaults   removal cancelleds   removing file %s
T)reverses   removing directory %s
)traversedirr  r  r   r9  r:  r   r0   listdirr"   r  r   CanceledErrorrw   r  r  rmdir)r&   r5  r:  r9  removeemptydirsremovefilesr8  noopconfirmr   oldtraversedirr  directoriesr  r+   
nb_ignored
nb_unknown	dir_countr9   s   `     `            r   purgerJ  K	  s   H6 6 6 6 6 6 (N
C7- 	5K"-"4G7GWMM 	GCV^,,JV^,,J %j %NOO
J// %?@@z! %?@@z!  	%	$ ' 'Awqzz '$)*;*;A*>*> '!Q	 %L C 9$C{0 -- --7''Q'771<<-a0D.E.EFFF 	FNV^;<<   0GLL#8!9!9A!=>>>F49+Q///

1 	"K666 " "71:: "di&7&7&:&: " 3Q'A%B%BQ%FGGGty222JJqMMM -n,,,,s   C*I EI 	I'r?   r  r.   )NFNNFTNN)NFNr  )NNFFN)TFTTFFF)Br   structi18nr   r-  r   
thirdpartyr   utilsr   dirstateutilsr   r\  r	   r
   r   r   r   r*  r   rn   r   r   r   r   r   r   r   r   pack_packunpack_unpackr,   r;   r=   r   r   r   r   r   r   r   rN  rQ  rf  rj  rw  r  r  r  r  r  r  UPDATECHECK_ABORTr  r  r  r  r!  r`   r$  r&  r0  r4  rJ  r   r!   r   <module>rU     s)                                $ $ $ $ $ $                               " 	
-     &5 5 5 5 5 5 5 5p@K @K @KF  BA A AH
 
 
D
 D
 D
N ,  ,  ,F` ` ` ` ` ` ` `Z ~ ~ ~ ~B" " "6 E E E EP  $
 $
 $
NS S Sl  : t
 
 
 
 
 
 
 
, E E E EP2
 2
 2
j    '  ] ] ] ]@   "   ,P P P P   * 
	I I I IX   & 	k- k- k- k- k- k-r!   