o ]Lb@sdZddlmZddlmZddlmZmZmZm Z m Z m Z m Z m Z iZe eZeddddd d Zd d Zd dZddZdS)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. )absolute_import)_)commandscopieserror extensionspycompat registrarscmutilsimilarautomv similarity_)defaultcCs.ttjdt}|ddddtdfdS)Nscommits no-automvs%disable automatic file move detection)r wrapcommandrtablemvcheckappendr)uientryr./usr/lib/python3/dist-packages/hgext/automv.pyextsetup3src Ost|}d}|dd}|sL|dd}d|krdks'nttd|dkrLt|d||}t ||\} } tj |d d } t || | | |d }| #|dur]t |d d ||||g|Rit|WdS1svwYdS) z&Hook to check for moves at commit timeNs no_automvFr r rds+automv.similarity must be between 0 and 100T)legacyrelativevaluegY@r)r byteskwargspop configintrAbortrr match_interestingfiles getuipathfn _findrenameswlock _markchanges strkwargs) origrrepopatsoptsrenamesdisabled thresholdr!addedremoveduipathfnrrrr:s&    $rcsH|j|d}|j}|j}t|d|d|fdd|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!.Ncsg|]}|vr|qSrr).0fcopyrr ^sz%_interestingfiles..)statusr/r0r pathcopies)r)matcherstatr/r0rr5rr"Qs r"c Cs~i}|dkr/t||||D] \}}}|jjr*|jtd|||||df|||<q|r=|jtdt||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 findrenamesrverboser8rlen) r)r1r/r0 similarityr,srcdstscorerrrr$cs r$N)__doc__ __future__rmercurial.i18nr mercurialrrrrrr r r configtable configitemrrr"r$rrrrs  (