
    	^cH                     |    d dl mZ d dlmZmZ d dlmZmZmZm	Z	m
Z
mZ d ZddZddZd	 Zdd
Zd Z	 ddZd ZdS )   )_)hexnullrev)context
mergestatemetadataphasesscmutilsubrepoutilc                 t    | j         dk    rd}d}n%| j                            dd          }|dk    }|dv }||fS )zreturn a (changelog, filelog) boolean tuple

    changelog: copy related information should be stored in the changeset
    filelof:   copy related information should be written in the file revision
       changeset-sidedataT   experimentals   copies.write-to   changeset-only)r   s   compatibility)filecopiesmodeuiconfig)repowritechangesetcopywritefilecopymetawritecopiestos       2/usr/lib/python3/dist-packages/mercurial/commit.py_write_copy_metar      sb     333! 8JKK)->>* /
 
 000    FNc                 >   |                                  } |                                |                                }}|                                }|                                 5  |                     d          5 }t          ||||          \  }}	|                                                                }
|
dD ]}|
	                    |d           | j
        j        dk    rt          | |
|	          }
| j
                                        }| j                            t!          d                     | j
                            |           | j
                            ||	|                                ||                                |                                ||                                |
	  	        }| |                                         }|| j
                                        k    r.|                     || j
                            |                     |                                |r|                                pd}}|                     dd	t3          |          ||
           t7          j        | j        |          }|| j
                                        k    o| |                                          }|r|st=          j        | |||g           |cddd           cddd           S # 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )a  Add a new revision to the target repository.
    Revision information is passed via the context argument.

    ctx.files() should list all files involved in this commit, i.e.
    modified/added/removed files. On merge, it may be wider than the
    ctx.files() to be committed, since any file nodes derived directly
    from p1 or p2 are excluded from the committed ctx.files().

    origctx is for convert to work around the problem that bug
    fixes to the files list in changesets change hashes. For
    convert to be the identity, it can pass an origctx and this
    function will use the same files list when it makes sense to
    do so.
    s   commit)errororigctxN)   p1copies   p2copies
   filesadded   filesremoveds   extras   committing changelog
r   s   pretxncommitT)thrownodeparent1parent2) 
unfilteredp1p2userlocktransaction_prepare_filesextracopypop	changelog_copiesstorage_extra_with_copiestiprevr   noter   delayupdateadddescriptionr"   daterevregister_changesetchangelogrevisionr   hookr   newcommitphasephaser	   registernew)r   ctxr   r   r&   r'   r(   trmnfilesr,   nameoldtipnr8   xp1xp2targetphase	waspublics                      r   	commitctxrJ   *   sr    ??DVVXXsvvxxB88::D	 : :d&&y11 :R"2s%III	E		  "" & & 		$%%%%>(H44&tUE::E &&(( 	Q011222""2&&&NOOGGIIGGIIHHJJ

 

 1gkkmmT^**,,,,##C)I)I#)N)NOOO6688R_BFFHH3S		Q 	 	
 	
 	
 "0#>> dn33555Od3ioo>O>O:O	 	=y 	= tRse<<<u: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :s7   %L;I&K:!L:K>	>LK>	LLLc                    |                                 }|                                }t          |          \  }}t          j                    }t
          j                            |          }	t          ||	|          }
|
D ]}|                    |           i }|                                 	                                
                                sH|	                                                                D ]!\  }}|                    d          }||||<   "|                                r|s|j                            d           |                                }|                    |                                           |rN|                    |                                           |                    |                                           nZ|                                s1|s/|j                            d           |                                }nt/          | ||	|||          }|r]|                                |k    rE|                                }|j                            |          sJ |                    |           |rN|                    |                                           |                    |                                           ||fS )Ns   outside-narrow-merge-actions   reusing known manifest
s*   reusing manifest from p1 (no file change)
)r   )r   r&   r   r   ChangingFilesr   read_get_salvagedmark_salvagednarrowmatchalways	allextrasitemsgetmanifestnoder   debugupdate_touchedrB   update_added
filesaddedupdate_removedfilesremoved_process_filestouchedissubsetupdate_copies_from_p1p1copiesupdate_copies_from_p2p2copies)r@   r?   r   r   r   r&   r   r   rB   mssalvagedsnarrow_filesfeactionrA   	origfiless                     r   r+   r+   {   s   88::D	B,<T,B,B))"$$E			#	#D	)	)BT2s++H  AL88::!!##**,, )LLNN((** 	) 	)DAqUU9::F!"(Q
 K, K1222SYY[[))) 	5s~~//000  !1!1!3!3444YY[[ K KDEEE__BREJJJ (7''))R//MMOO	}%%i00000Y''' 4##CLLNN333##CLLNN333u9r   c                    g }| j         dk    }|rt          |                                          dk    r|                                r}t	          |                                                                          D ]I}|                    |                              d          }|dk    r||v r|	                    |           J|S )zzreturns a list of salvaged files

    returns empty list if config option which process salvaged files are
    not enabledr   r      merge-removal-candidate   yes)
r   lenparentsactivesortedrR   keysextrasrT   append)r   rc   r?   rd   copy_sdfnamemight_removeds          r   rN   rN      s    
 H!%::G /3s{{}}%%))99;; 	/ 3 3 5 566 / / "		% 0 0 4 45O P P F**|| ...Or   c                 @
   |                                 }|                                }|                                }t          |          \  }	}
|                                }|                                }|                                }|                                |                                |                                g }t          |                                          }t          |          }|j
                            t          d                     t          j        |          }|                                |                                z   }|                    |                                           |                                 |D ]}|j
                             ||          dz              ||v rz|                    |          }|t*          j        k    r,|                    |           |                    |           n'|t*          j        k    ri|                    |           |                    |           |         |<   |                    |          d         pd}                    ||           n|t*          j        k    ri|                    |           |                    |           |         |<   |                    |          d         pd}                    ||           n5t          d          }t          d          }|                    ||          	 ||         }||                    |           n|                    |           tA          |||| |
|          \  |<   }|rM|dk    r|                    |           n1|d	k    r|!                    |           n|                    |                               ||"                                           s# tF          $ r5 |j
        $                    t          d
           ||          z              w xY wfd|D             }tK          fd|D                       }|D ]}|= |&                                tN          k    r|(                    |           n>tS          j*        |||f          }|D ]"} ||          s|                    |           #tW          | ||||j,        ||t[          |          	  	        }|S )Ns   committing files:
   
r   r   s/   corrupted mergestate, unknown narrow action: %bs   restart the merge)hintaddedmergeds   trouble committing %s!
c                 $    g | ]}|v s|v 
|S  r~   ).0rg   m1m2s     r   
<listcomp>z"_process_files.<locals>.<listcomp>   s&    888QQ"WWRqr   c                     g | ]}|v |	S r~   r~   )r   rg   ms     r   r   z"_process_files.<locals>.<listcomp>   s    000a1r   ).r   r&   r'   r   manifestctxr-   rM   listremovedrn   r   r3   r   r
   getuipathfnmodifiedr{   extendrr   sortrT   r   CHANGE_REMOVEDmark_removedrt   CHANGE_ADDED
mark_addedfindsetflagCHANGE_MODIFIEDmark_touchedAbort_filecommitmark_mergedflagsOSErrorwarnrq   r8   r   rZ   r   get_removal_filter_commit_manifestr]   bool) r@   r?   rc   rB   rf   r   r   r&   r'   r   r   m1ctxm2ctxmctxr{   r   linkrevuipathfn	all_filesrg   narrow_actionr   msgrz   fctx
is_toucheddroprfrA   r   r   r   s                                 @@@r   r\   r\      s   88::D	B	B,<T,B,B))NNENNE::<<D		A	B	B E3;;==!!G$iiGGLL)**+++"4((H,I\&&(()))NN + +XXa[[5()))(,,Q//M
 999""1%%%q!!!!*"999  ###Q!u!

1a(/C		!U####*"<<<""1%%%Q!u!

1a(/C		!U####JKK-..kk#Dk111	q6D|q!!!!Q#.$B5F$ $ !j  .!W,,((++++#x//))!,,,,**1---		!TZZ\\*** 	 	 	GLL677((1++EFFF	
 98888'888G0000g00011D  aDD	vvxx7W%%%%(r2r2.>?? 	& 	&A2a55 &""1%%%	
	\

 

B Is   CP?Qc                    |                                 }|                    || j                  }	|                    || j                  }
d}|	|
cxk    r| j        k    rn nd}t          |t          j                  r|                                }||	|
fv r| j                            d|z             |	| j        k    r+|	                    |          |	                                k    s6|
| j        k    r-|	                    |          |	                                k    rd}||fS | 
                    |          }i }|                                }d}|r||k    r|                    |          }|
}|r|
| j        k    s|||v r
||         }|	}|rQ| j                            d||t          |          fz             |r||d<   t          |          |d<   | j        |}
}	n| j                            t          d          ||fz             n|	| j        k    r
|
| j        }
}	n|
| j        k    r|                                r6|                    |                              d	          d
k    r
|
| j        }
}	ny|                                r6|                    |                              d          dk    r
|	| j        }
}	n/|                    |	|
          }|	|v r
|
| j        }
}	n|
|v r| j        }
d}| j                            dd          rB|                                r.|                    |                              d          dk    rd}|                                }|
| j        k    s%|	| j        k    s|s|                    |	|          s|r-||
| j        k    rd}nd}|                    |||||	|
          }n6||v r0|	                    |          |	                                k    rd}|	}n|	}||fS )a  
    commit an individual file as part of a larger transaction

    input:

        fctx:       a file context with the content we are trying to commit
        manifest1:  manifest of changeset first parent
        manifest2:  manifest of changeset second parent
        linkrev:    revision number of the changeset being created
        tr:         current transation
        includecopymeta: boolean, set to False to skip storing the copy data
                    (only used by the Google specific feature of using
                    changeset extra as copy source of truth).
        ms:         mergestate object

    output: (filenode, touched)

        filenode: the filenode that should be used by this changeset
        touched:  one of: None (mean untouched), 'added' or 'modified'
    Nr{   s   reusing %s filelog entry
r   s    %s: copy %s:%s
s   copys   copyrevs8   warning: can't find ancestor for '%s' copied from '%s'!
s   filenode-sources   others   mergedrm   Fr   s   merge-track-salvagedrl   Tr|   )pathrT   nullid
isinstancer   filectxfilenoder   rV   r   file
copysourcer   r   r   rp   rs   commonancestorsheads
configbooldatacmpr5   )r   r   	manifest1	manifest2r   r@   includecopymetarc   rv   fparent1fparent2r]   r"   flogmetacfnamefnodecnode
newfparentfparentancestorsforce_new_nodetexts                         r   r   r     s^   > IIKKE}}UDK00H}}UDK00HG8****t{*****$(( ! }}Hh'''GMM7%?@@@DK''OOE**djjll::DK''OOE**djjll::$= 99UDD__FE D'&E//( f%%
 	*DK''5=Y&&%f-E!)J  	GMM.%U1LLMMM . &W#&u::Z !%jhHHGLL+  &/	"    
T[	 	 %t{(	T[	 	 99;; 
	'299U++//0BCCxOO!)4;hHHYY[[ 	'RYYu--11)<<FF!)4;hHH  $888LL+++%-t{(---;N 	?,CDDIIKK IIe  !;<<FF99;;DDKt{"" #88Hd## #  #
 ?4;&&$"tR(HEE	)			 6 6$**,, F F'>r   c	           	         |                                 }	d}
|                                }|                                }|                                }|                                }|s;|                    |t          j        |	|                                                    }
|s|
r|	j	        
                    d           |s|
r|	j	                            t          d                     |rd}n|	                                }|                    | ||                                |                                |||          }n.|	j	        
                    d           |                                }|S )a  make a new manifest entry (or reuse a new one)

    given an initialised manifest context and precomputed list of
    - files: files affected by the commit
    - added: new entries in the manifest
    - drop:  entries present in parents but absent of this one

    Create a new manifest revision, reuse existing ones if possible.

    Return the nodeid of the manifest revision.
    NsI   not reusing manifest (no file change in changelog, but manifest differs)
s   committing manifest
)matchs;   reusing manifest from p1 (listed files actually unchanged)
)r   r&   r'   r   rM   diffr
   
matchfilesrB   r   rV   r3   r   rP   writerU   )r@   r   r?   r   manifestrB   r{   r   has_some_narrow_actionr   mdr&   r'   r   r   r   rA   s                    r   r   r     ss   , 88::D	B 
B	BNNE	B F WWXw1$		DDEE 
R 
2	
 	
 	
   Q/00111 " 	'EE$$&&EZZOOOO  
 
 	O	
 	
 	
 __Ir   c                    |j         }|j        }|j        }|j        }t	          |j                  }t          |           d         s|pd}|pd}|pd}|pd}||||f}|t          d |D                       ri }|t          j	        ||          }||d<   |t          j	        ||          }||d<   |t          j
        ||          }||d<   |t          j
        ||          }||d<   |S )z2encode copy information into a `extra` dictionnaryr   Nc              3      K   | ]}|d uV  	d S )Nr~   )r   xs     r   	<genexpr>z%_extra_with_copies.<locals>.<genexpr>  s&      BBqQd]BBBBBBr   r   r   r   r    )copied_from_p1copied_from_p2r{   r   rq   r]   r   anyr   encodecopiesencodefileindices)r   r,   rB   r`   rb   rY   r[   extrasentriess           r   r1   r1     s.   #H#HJ=L5=!!ED!!!$ ,
 #t#t'4
#+th
L@M}BBMBBBBB}(99%k(99%k/zBB
)m1%FF!-oLr   )FN)NF)F)i18nr   r"   r   r    r   r   r   r	   r
   r   r   rJ   r+   rN   r\   r   r   r1   r~   r   r   <module>r      s@               
               1 1 1&N N N Nb( ( ( (V  "^ ^ ^ ^Bb b b\ !G G G GT         r   