o ]LbJ@sddlmZddlZddlmZddlmZmZddlm Z m Z m Z m Z m Z mZddZdd d Zdd d ZddZdddZddZ dddZddZdS))absolute_importN)_)hexnullrev)context mergestatemetadataphasesscmutil subrepoutilcCs@|jdkr d}d}||fS|jdd}|dk}|dv}||fS)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 experimentalscopies.write-tochangeset-only)rs compatibility)filecopiesmodeuiconfig)repowritechangesetcopywritefilecopymeta writecopiestor2/usr/lib/python3/dist-packages/mercurial/commit.py_write_copy_metas rFc Cs|}||}}|}||d}t||||d\}} |} | dur;dD]} | | dq2|j j dkrGt || | } |j } |jtd|j ||j || ||||||| } || }| |j kr|||j |||r|pd}}|jdd t| ||d t|j|}| |j ko|| }|r|st||||g| WdWdS1swYWddS1swYdS) aAdd 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. scommit)errororigctxN)p1copiesp2copies filesadded filesremovedsextrascommitting changelog s pretxncommitT)thrownodeparent1parent2) unfilteredp1p2userlock transaction_prepare_filesextracopypop changelog_copiesstorage_extra_with_copiestiprevrnoter delayupdateadd descriptionr"daterevregister_changesetchangelogrevisionrhookr newcommitphasephaser registernew)rctxrrr&r'r(trmnfilesr,nameoldtipnr8xp1xp2 targetphase waspublicrrr commitctx-sT      RrJcCst|}|}t|\}}t}tj|} t|| |} | D]} || q i} | sJ| D]\} }| d}|durI|| | <q8|rr| sr|jd|}|||rq||||n|s| s|jd|}n t||| || |d}|r||kr|}|j|sJ|||r||||||fS)Nsoutside-narrow-merge-actionsreusing known manifest s*reusing manifest from p1 (no file change) )r)rr&rr ChangingFilesrread _get_salvaged mark_salvaged narrowmatchalways allextrasitemsget manifestnoderdebugupdate_touchedrB update_added filesaddedupdate_removed filesremoved_process_filestouchedissubsetupdate_copies_from_p1p1copiesupdate_copies_from_p2p2copies)r@r?rrrr&rrrBmssalvageds narrow_filesfeactionrA origfilesrrrr+~sF           r+cCsng}|jdk}|r5t|dkr5|r5t|D]}||d}|dkr4||vr4| |q|S)zzreturns a list of salvaged files returns empty list if config option which process salvaged files are not enabledr rmerge-removal-candidateyes) rlenparentsactivesortedrQkeysextrasrSappend)rrbr?rccopy_sdfname might_removedrrrrMs  rMc st|}|}|}t|\} } |} |} | } | | | g}t|}t |}|j t dt |}||}||||D] }|j ||d||vr||}|tjkr~||||nY|tjkr||||||<| |dpd}||n4|tjkr||||||<| |dpd}||nt d}t d}|j||dqXzJ||}|dur||n:||t ||||| |\|<}|r|dkr ||n|d kr|!|n||||"WqXt#y7|j $t d ||t%yc}z t&|d t'j(}|sR|r^|t'j(kr^|j $t d ||d}~wwfd d |D}t)fdd |D}|D]}|=q{|*t+kr|,|nt-.|||f}|D] }||s||qt/|||| |j0||t1| }|S)Nscommitting files:  rr s/corrupted mergestate, unknown narrow action: %bsrestart the merge)hintaddedmergedstrouble committing %s! errnocs g|] }|vs |vr|qSrr.0rf)m1m2rr s z"_process_files..csg|]}|vr|qSrrr{)mrrrs)2rr&r'r manifestctxr-rLlistremovedrlrr3rr getuipathfnmodifiedrxextendrpsortrSrCHANGE_REMOVED mark_removedrr CHANGE_ADDED mark_addedfindsetflagCHANGE_MODIFIED mark_touchedAbort _filecommit mark_mergedflagsOSErrorwarnIOErrorgetattrrzENOENTror8rrYr get_removal_filter_commit_manifestr\bool)r@r?rbrBrerrr&r'rrm1ctxm2ctxmctxrxrlinkrevuipathfn all_filesrf narrow_actionrmsgrwfctx is_touchedinsterrcodedroprfrAr)rr}r~rr[s                             r[cCs |}|||j} |||j} d} | | kr|jkr#nnd} t|tjr]|} | | | fvr]|jd|| |jkrI| || ksW| |jkrY| || krYd} | | fS| |} i}| }d}|r||kr||}| }|r| |jks|dur||vr||}| }|r|jd||t |f|r||d<t ||d<|j|} } nc|j td||fnV| |jkr| |j} } nJ| |jkr|r||d d kr| |j} } n/|r||d d kr| |j} } n| | | }| |vr | |j} } n| |vr|j} d }|jddr-|r-||dd kr-d}|}| |jksJ| |jksJ|sJ| | |sJ|rh| durZ| |jkrXd} nd} | ||||| | }|| fS||vr| || krd} | }|| fS| }|| fS)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' Nrxsreusing %s filelog entry rs %s: copy %s:%s scopyscopyrevs8warning: can't find ancestor for '%s' copied from '%s'! sfilenode-sourcesothersmergedrkFrsmerge-track-salvagedrjTry)pathrSnullid isinstancerfilectxfilenoderrUrfile copysourcerrrrnrqcommonancestorsheads configbooldatacmpr5)rr manifest1 manifest2rr@includecopymetarbrtfparent1fparent2r\r"flogmetacfnamefnodecnode newfparentfparentancestorsforce_new_nodetextrrrr s                    rc  Cs|} d} |} |} | } | }|s$||t| |} |s.| r.| j d|s2| rU| j t d|r?d}n| }|j||| | |||d}|S| j d| }|S)amake 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. NsInot reusing manifest (no file change in changelog, but manifest differs) scommitting manifest )matchs;reusing manifest from p1 (listed files actually unchanged) )rr&r'rrLdiffr matchfilesrBrrUr3rrOwriterT)r@rr?rmanifestrBrxrhas_some_narrow_actionrmdr&r'rr}rrArrrrs@rcCs|j}|j}|j}|j}t|j}t|ds'|pd}|pd}|p"d}|p&d}||||f}|dur!sz%_extra_with_copies..rrrr) copied_from_p1copied_from_p2rxrror\ranyr encodecopiesencodefileindices)rr,rBr_rarXrZ extrasentriesrrrr1s4       r1)FN)NF)F) __future__rrzi18nrr"rrrrr r r r rrJr+rMr[rrr1rrrrs     Q+ f/ J