^ckdZddlmZddlmZmZmZmZmZm Z m Z m Z iZ e j e Z e ddddZd Zd Zd Zd S) axcheck for unrecorded moves at commit time (EXPERIMENTAL) This extension checks at commit/amend time if any of the committed files comes from an unrecorded mv. The threshold at which a file is considered a move can be set with the ``automv.similarity`` config option. This option takes a percentage between 0 (disabled) and 100 (files must be identical), the default is 95. )_)commandscopieserror extensionspycompat registrarscmutilsimilarautomv similarity_)defaultctjtjdt}|ddddt dfdS)Nscommits no-automvs%disable automatic file move detection)r wrapcommandrtablemvcheckappendr)uientrys ./usr/lib/python3/dist-packages/hgext/automv.pyextsetupr2sQ  "8>9g F FE !HOO lD!$L"M"MNrcxtj|}d}|dd}|s|dd}d|cxkrdks#nt jt d|dkr[tj|d||}t||\} } tj |d } t|| | | |d z }| 5|tj |d d ||||g|Ritj|cdddS#1swxYwYdS) z&Hook to check for moves at commit timeNs no_automvFr r rds+automv.similarity must be between 0 and 100T)legacyrelativevaluegY@)r byteskwargspop configintrAbortrr match_interestingfiles getuipathfn _findrenameswlock _markchanges strkwargs) origrrepopatsoptsrenamesdisabled thresholdr#addedremoveduipathfns rrr9s   % %DGxx e,,H  LLM:: I$$$$$$$$+a NOOPP P q==M$t*dD99E.tU;;NE7*4TJJJH"hw E0AG AA    r2w 7 7 7tB@t@@@x'9$'?'?@@AAAAAAAAAAAAAAAAAAs*8D//D36D3c||}|j}|j}tj|d|d|fd|D}||fS)zFind what files were added or removed in this commit. Returns a tuple of two lists: (added, removed). Only files not *already* marked as moved are included in the added list. )r#.Ncg|]}|v| Srr).0fcopys r z%_interestingfiles..]s / / /1$Qr)statusr1r2r pathcopies)r+matcherstatr1r2r9s @rr$r$Pse ;;W; % %D JElG  T$ZdW = =D / / / / / / /E '>rcji}|dkrqtj||||D]Y\}}}|jjrB|jt d|||||dzfz|||<Z|r7|jt dt |z|S)zFind what files in added are really moved files. Any file named in removed that is at least similarity% similar to a file in added is seen as a rename. rs)detected move of %s as %s (%d%% similar) rsdetected move of %d files )r findrenamesrverboser;rlen) r+r3r1r2 similarityr.srcdstscores rr&r&bsGA~~&2 %*    OCew CDDx}}hhsmmUS[ABGCLLI q7883w<<GHHH NrN)__doc__mercurial.i18nr mercurialrrrrrr r r configtable configitemrrr$r&rrrrLs   *                     !Y !+ . .   AAA.$r