o ]Lb\h@s ddlmZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZmZmZmZmZmZmZmZmZmZmZmZmZmZej Z!ej"Z#d d Z$dId d Z%Gddde&Z'ddZ(ddZ)ddZ*ddZ+ddZ,ddZ-Gddde&Z. dJdd Z/d!d"Z0  dKd#d$Z1d%d&Z2d'd(Z3d)d*Z4d+d,Z5e j6d-d.Gd/d0d0e&Z7 dId1d2Z8d3d4Z9d5Z:d6Z;d7ZdMd;d<Z?dNd=d>Z@dId?d@ZAdNdAdBZB     dOdCdDZCdNdEdFZD -  - -   dPdGdHZEdS)Q)absolute_importN)_)nullrev)attr) stringutil) timestamp)copiesencodingerror filemergematch mergestateobsutilpathutilpolicypycompatscmutil subrepoutilutilworkercCsX|j||}gd}||vr*ddd|D}td}|||||f;}t||S)N)abortsignorewarns, cSsg|]}d|dqS)').0vrr1/usr/lib/python3/dist-packages/mercurial/merge.py ,sz*_getcheckunknownconfig..s$%s.%s not valid ('%s' is none of %s))uiconfigjoinrr ConfigError)reposectionnamer validvalidstrmsgrrr_getcheckunknownconfig(s r)cCsV|rdS|dur |}|jj|o*|j|o*|j||jvo*||||SNF) isinmemorywvfsauditcheck isfileorlinkdirstate normalizecmp)r#wctxmctxff2rrr_checkunknownfile3s r7c@s eZdZdZddZddZdS)_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. cCst|_t|_dSN)set_unknowndircache_missingdircacheselfrrr__init__Qs z_unknowndirschecker.__init__c Cs|rdSttt|D]?}||jvrdS||jvrq|jj |rN|j |r9|j ||j vr9|S|j |sH|j|dS|j|q|jj |r|j|r|j|D]'\}}}|D]}t|j||}|j j |dd}||j vr|SqiqbdS)NFT)isknown)r+reversedlistrfinddirsr<r;r,r-r.r/r0r1lexistsaddisdirwalkrpconvertreljoin) r>r#r3r5pdirsfilesfnrelfrrr__call__\s6        z_unknowndirschecker.__call__N)__name__ __module__ __qualname____doc__r?rOrrrrr8Fs r8c st}ttttdd}tdd}jdd} |sfdd} t} |tjtjfD]$} t ||| rC| | q4| rX| |vrX| || } | durX | q4| tj gD]\} }}t ||| |d rt| | q`|B}fd d |D}||}| ||| ||nft | tjgD]\\} }}|\}}t ||| }j| r|}n|}|s|| tj|d fd q|s|dkr|| tj| | dd |fdq|dkr | q|dkr | || tj|dfd qtD],} jj}| vrj| r|td| q|td| q|td| qr2ttdtD] } j| rKjtd| q6jtd| q6t | tjgD],\} }}| |vp|| vp|tfddt| D}|\}|| tj||f|q`dS)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 experimentalmerge.checkpathconflictscs0|dkr |dS|dkr|dSdS)Nrr)update) conflictsr )abortconflicts warnconflictsrrcollectconflictss z,_checkunknownfiles..collectconflictsNrcsh|] }j|r|qSr)r0_ignore)rcr#rr sz%_checkunknownfiles..Fremote createdrs#remote differs from untracked localrTs,%s: untracked file conflicts with directory s,%s: untracked directory conflicts with file s%s: untracked file differs sLuntracked files in working directory differ from files in requested revisions%s: replacing untracked file s+%s: replacing untracked files in directory c3s|]}|vVqdSr9r)rrJ) pathconflictsrr z%_checkunknownfiles..)r:r)r configboolr8rL mergestatemodACTION_CREATEDACTION_DELETED_CHANGEDr7rE getactionsACTION_LOCAL_DIR_RENAME_GETrBACTION_CREATED_MERGEr0r\addfile ACTION_GET ACTION_MERGEsortedwarnr,r/rr StateErroranyrrC)r#r3r4forcemresult mergeforce fileconflicts unknownconfig ignoredconfig pathconfigr[checkunknowndirsr5pathargsr( allconflictsignoredconflictsunknownconflictsfl2anc differentr robackupflagsr)rYrar#rZr_checkunknownfiles~s                    rcCsjtj}|rtj}|D]}||vr|||ddq |s1|D]}||vr0||tjddq!dSdS)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. Nsforget deletedsforget removed)re ACTION_FORGET ACTION_REMOVEdeletedrkremoved)r3r4 branchmergersmr5rrr_forgetremoveds&  rcCs|}|s$t||}|r#t|D] }||s"||qnt|}|r|tjtj tj tj tj tj fD]}||q;|tjfD]}||qJ|tjgD]\}}}|\}} ||||qY|tjfD]}||qt|tjgD]\}}}|\} }} } } | r|| ||qi}|D] }t|}||vrtd}||||f;}t||||<qd}}}t|D]'\}}||r||std}|||f;}t||d}|d}|}qdS)z, Check for case-folding collisions. s(case-folding collision between %s and %ss5case-folding collision between %s and directory of %s/N) narrowmatchalwaysr:rGrBrL removefilere ACTION_ADDACTION_ADD_MODIFIEDrrlACTION_CHANGED_DELETEDrgrErdiscardrhACTION_DIR_RENAME_MOVE_LOCALrirmrnormcaserr rprnitems startswith)r#wmfrsrpmmfr5r{r(r6rf1famoverfoldmapfold foldprefix unfoldprefixlastfullrrr_checkcollision"sj              rccs6|D]}t|D] }||vr||fVnq qdS)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)rrC)r#manifestrKr5rJrrr _filesindirsfs rc Cs|}t}t}t}t}t} |tjtjtjtjfD]} |t | | | r4| | q |tj fD]} | | q<|tjfD]\} } } | \} }}}}|r^| | qK|tjfD]\} } } | \}}| |qf|D]/}||vr||vr| |n| |||}|r|dtjtjtjtjfvr| |qw|D]7}|| vrt|d}t|||t|}||p|}||tj||fd||tj|dfdq|rBt|d}t|||D]P\} }| | vrA||\}} } t|||t|}|tjtjfvr |||| | n| d}||tj||fd||tj|dfd||nq|r\|D] }|jtd|qGt td d S) z Check if any actions introduce path conflicts in the repository, updating actions to record or handle the path conflict accordingly. r+slocal path conflictls path conflictsremote path conflictrs#%s: is both a file and a directory s,destination manifest contains path conflictsN)!rr:rLrerfrgrmrjrWrrChasdirrErrhrgetfilebytesrstriprsafename copysourcerkACTION_PATH_CONFLICT_RESOLVEACTION_PATH_CONFLICTrriremoverrorr rp)r#r3r4rsmflocalconflictsremoteconflictsinvalidconflictscreatedfiledirs deletedfilesr5r{r(rr6rrrrrJpdctxnamepnewporigrflrrrcheckpathconflictsss            rcCs|D]Q\}}||r q|s||q|djr ||q|djrK|ds:||||d|djqtd}td}tj |||dtd}t ||dS) 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. rrsoutside-narrow-merge-actionsBmerge affects file '%s' outside narrow, which is not yet supporteds'merging in the other direction may workhints-conflict in file '%s' is outside narrow cloneN) filemaprno_op narrow_safeendswith addcommitinfochangesrr Abortrp)rrrsr5actionr(rrrr_filternarrowactionss*        rc@seZdZdZddZddZddZd$d d Zd$d d Zd dZ d%ddZ d$ddZ d%ddZ ddZ eddZeddZeddZeddZd d!Zd"d#ZdS)& 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.cCs.i|_i|_i|_tt|_tt|_dS)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 defaultdictdict _commitinfo_actionmappingr=rrrr?#s   zmergeresult.__init__cCs||_||_dSr9)rr)r>diverge renamedeleterrr updatevalues5s zmergeresult.updatevaluescCsL||jvr|j|\}}}|j||=|||f|j|<||f|j||<dS)aadds 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 Nrr)r>filenamerdatamessageadrrrrrk9s  zmergeresult.addfileNcCs||jvr |j|S|S)zfreturns (action, args, msg) about this file returns default_return if the file is not present)r)r>rdefault_returnrrrrJs  zmergeresult.getfileccsD|dur|jD]}|VqdS|D] }|j|D]}|VqqdS)zvreturns files on which provided action needs to perfromed If actions is None, all files are returned Nr)r>actionsr5rrrrrLRs zmergeresult.filescCs(|j|\}}}|j|=|j||=dS)zXremoves a file from the mergeresult object as the file might not merging anymoreNr)r>rrrrrrrrbszmergeresult.removefileFccsr|D]3}|r!t|j|D]}|j||\}}|||fVqqt|j|D] \}\}}|||fVq)qdS)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)rnrr iteritems)r>rsortrr5r{r(rrrrhiszmergeresult.getactionscs(|dur tjStfdd|DS)zreturns number of files which needs actions if actions is passed, total of number of files in that action only is returnedNc3s|] }tj|VqdSr9)lenrrrr=rrrbz"mergeresult.len..)rrsum)r>rrr=rrzs zmergeresult.lenccsRtrtt|jD] \}}||fVq dSt|jD] \}}||fVqdSr9)rnrrr)r>rkeyvalrrrrs  zmergeresult.filemapcCs||j||<dS)zdadds key-value information about filename which will be required while committing this mergeNr)r>rrvaluerrrrszmergeresult.addcommitinfocC|jSr9)rr=rrrrzmergeresult.divergecCrr9)rr=rrrrrzmergeresult.renamedeletecCrr9rr=rrr commitinforzmergeresult.commitinfocCsPtt}t|jD]\}}t|D]\}\}}|||||fqq |S)z}returns a dictionary of actions to be perfomed with action as key and a list of files and related arguments as values)rrrBrrrappend)r>resrrr5r{r(rrr actionsdicts zmergeresult.actionsdictcCsD||_tt|_t|jD]\}\}}}||f|j||<qdSr9)rrrrrrr)r>rr5actrr(rrr setactionss  zmergeresult.setactionscCsB|jD]}|tjtjtjtjfvr|j|r|jsdSqdS)z^tells whether this merge resulted in some actions which can result in conflicts or notTF)rkeysrerl ACTION_EXECrrr)r>rrrr hasconflictss zmergeresult.hasconflictsr9F)rPrQrRrSr?rrkrrLrrhrrrpropertyrrrrrrrrrrrs,          rFc , st} |dur |r d}ddt||gtjdDt} t} i} |r6t|||\} } } t t |}t t |}t t |}|j td|j d|||f|j d||f||}}}t| j}|| jt| j}|| jd|vrdurtfd d jDr|jj|d<||gvr| s|j d d s|jd kst||}t | jD] \}}||vr| |q| jD]}| |qt!||}t"#||}|j||d}t |D]\}\\}}\}} |r6|r6||vr[| j$|dp-| j$|d}!d\}"}#|!durE|||!d|%f}"d|!}#n ||dd|%f}"d}#| &|t'j(|"|#q || jvrz| j|}!| &|t'j(||!|!d|%fd|!q || jvr| j|}!| &|t'j(|!||!d|%fd|!q ||}$|)|}%d|| |%v}&||$kr| |%kr| &|t'j*ddq ||$kr||%kr||kr| &|t'j+| fdq | &|t'j,| dfd|r| -|ddq |&r||$kr| &|t'j+| fdq |&r$||$kr$| &|t'j,|dfd|r"| -|ddq | &|t'j(|||d|%fdq |r||vr@q || jvrq| j|}'|'|vrb| &|'t'j(||'dd|%fdq | &|'t'j.||fd|q || jvr| j|}'| &|t'j(||'|'d|%fd |'q ||vr|||kr|r| &|t'j/dd!q | &|t'j0|d|d|%fd"|r| -|d#d$q ||jj1kr| &|t'j2dd%q | &|t'j/dd&|r| -|d#d$q | &|t'j3dd'q |r ||vrq || jvr3| j|}'|'|vr$| &|'t'j(|'|dd|%fd(q | &|'t'j4|| fd)|q || jvrm| j|}'d\}#}"|'|vrU|'||'d|%f}"d*|'}#n |'||'d|%f}"d+|'}#| &|t'j(|"|#q ||vr|s| &|t'j5| fd,q |s| &|t'j5| fd,q | &|t'j6| |%fd-q |||kr d}(| j7D]})|8|)r| j7|)|t9|)d}(nq|(dur|(|vr| &|(t'j(|(||d|%fd.|q |r| &|t'j5| fd/q | &|t'j:d||d|%fd0|r | -|d#d$q | &|t'j;dd1|r | -|d#d$q |j d d2r1t<||| |=}*|*s@t>|*|| | j?}+|+| j?| @| |+| S)3a 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 NcSsg|]}|qSr)r)rxrrrrsz!manifestmerge..)rsresolving manifests s) branchmerge: %s, force: %s, partial: %s s% ancestor: %s, local: %s, remote: %s .hgsubstatec3s|] }|VqdSr9)subdirty)rsr3rrrbrz manifestmerge..rUsmerge-track-salvagedschangeset-sidedata)r NNFsboth renamed from %ss both createdslocal replaced from %ssother replaced from %srrsremote unchangedsupdate permissionssremote is newersfilenode-sourcesothersversions differTs%remote directory rename, both createds&remote directory rename - move from %sslocal copied/moved from %ss remote deletesprompt changed/deletedsmerge-removal-candidateyessremote deleteds other deleteds ancestor missing, remote missings$local directory rename, both createds$local directory rename - get from %ssremote copied from %ssremote moved from %sr`sremote created, get or merges-local directory rename - respect move from %ssremote recreatingsprompt deleted/changeds#local not present, remote unchangedrV)Arrrnparentsrintrevr branch_copies mergecopiesrbytestrboolrnoterdebugrr:copyvaluesrW movewithdirrevrqsubstate nodeconstantsmodifiednodeidrdfilecopiesmodediffrrrE matchfilesmatchmodintersectmatchersgetnoderkrermr ACTION_KEEPrrlrrrr addednodeidrACTION_KEEP_NEWrirfrjdirmoverrrgACTION_KEEP_ABSENTrrrrr),r#r3p2parrrmatcher acceptremote followcopies forcefulldiffrsbranch_copies1branch_copies2rboolbmboolfboolmm1m2macopied1copied2 relevantfilescopykey copyvalue movedirkey filesmatcherr r5n1fl1n2rrr{r(rflanolr6dfrrrrrr manifestmergesT                                               r2cCst|tjfD]}||vr!||||s!||tjddq t|tjfD]}||vr?||||s?||q+dS)zXResolves false conflicts where the nodeid changed but the content remained the same.Ns prompt same) rBrLrerr2rkrrgr)r#r3r4ancestorrsr5rrr_resolvetrivialCs  r4c  sXddlm} d} t|dkr't||||d||||| } t||||| | nb|jtd||tddd|Dfi} t } d \} }|D]}|jtd |t|||||||||d d }t|||||| | dusyt|j t| kr||j } |dust|t|j kr|j }| j |j |jd d D]7\}}|\}}}|jd|||f|| vr| |}||vr|||q|g||<q||gi| |<qqI|jtdt|t| D]\}}|jjr|jd|t|D]\}D]\}}}|jd||fqqt|dkrQt|d\}tfddddDrQ|jtd||f| j|gdRqtj|vrp|jtd|| j|g|tjdRqtj|vr|jtd|| j|g|tjdRqtj|vrtj|vr|jtd|| j|g|tjdRqtj|vr|jtd|| j|g|tjdRqtj|vrtj|vr|jtd|| j|g|tjdRqtj|vr,|tjdtfdd|tjddDr,|jtd|| j|gRq|jtd|t|D]\}D]\}}}|jd||fqBq.rs" calculating bids for ancestor %s T)rr %s: %s -> %s s/ auction for merging merge bids (%d ancestors) s list of bids for %s: s %s -> %s c3s|] }|dkVqdS)rNrr)lrrrbss %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 c3s|]}|kVqdSr9rr)ga0rrrbrcs %s: picking 'get' action s% %s: multiple bids for merge action: s %s -> %s s( %s: ambiguous merge - picked %s action send of auction )%r6rr2rrrrr!rrrrrWrr __bytes__rrnr debugflagrBallrkrerrrrrgrlrorrrfilterupdatesactionsr4)r#r3r4 ancestorsrrrrrrrtr6rsfbidsrrr3mresult1r5rrr{r(rbids_fr)r;r:rcalculateupdatesUs                   &  rFc Cs@ztWSty}z|jtjkrWYd}~dSd}~wwr9)r getcwdOSErrorerrnoENOENT)errrrr_getcwds  rLc cs|jj}t}d}|D]]\}}}|jd||f|r'|jtd|||z ||jddWn"tyY} z|j td|t | j fWYd} ~ nd} ~ ww|dkre||fVd}|d 7}q |dkrs||fV|rts|j td |j dSdSdS) zSapply removes to the working directory yields tuples for progress updates rs %s: %s -> r removing %s T) ignoremissings update failed to remove %s: %s! NdrsCcurrent directory was removed (consider changing to repo root: %s) )rverboserLrrrr-rrHror forcebytestrstrerrorroot) r#r3rrPcwdir5r{r(instrrr batchremove&sD     rWccsi}|jj}|j}|j}d} |jj|t|d|D]\} \} } } |jd| | f|r9|jtd| | rk| }|j | sUt | D] }|j |rT|}nqH|j |rkt |||}t||||| }||dd}|j|| | d|d}|r|}|j}t|}|||f|| <| d krd | | ffVd} | d 7} qWd n1swY| dkrd | | ffVd|fVd S) ajapply 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 rUsupdate.atomic-fileT)backgroundclose atomictemprOFrN)rrPfilectxr,backgroundclosingrrrrrDrrCr/r backuppathrrenamewjoin clearunknownrdwriterlstatst_modermtime_of)r#r4r3 wantfiledatarfiledatarPfctxrrUr5rrr( conflictingrJorigwfctxrZsizermodemtimerrrbatchgetMsZ        BrncCsD|tjtjtjtjg}tj}tj}||| |||fgdS)zInvoke ``scmutil.prefetchfiles()`` for the files relevant to the dict of merge actions. ``ctx`` is the context being merged in.N) rLrerlrgrirmr prefetchfilesr r)r#ctxrsrLprefetchr rrr_prefetchfiless  rrT)frozenc@s4eZdZeZeZeZeZddZ dS) updateresultcCs|jp |jp |jp |j Sr9) updatedcount mergedcount removedcountunresolvedcountr=rrrisemptyszupdateresult.isemptyN) rPrQrRribrurvrwrxryrrrrrts  rtc0 Cst|||d\}}} |jdd} | |||t|jD] \} } | | | q$| t j j } | | }|j jtdtd|d}d|jt jvr[t|||||||jt jgddD]?\} }}|\}}|j j}|td | |d kr|td |n|td ||td | | | |||j| dqd|rdnd}t|j |t||ft|jt jgdd}|D] \}}|j||dq| t jf} |jt jgddD]J\} }}|j d| |f|\}}||r#|j td|| f|| !|| "|#|$|#|%||&|j| dq|j 'dd}tj|j |t(||||ft|jt j)gdd|dd}i}|D]\}}|rZ|}qO|\}}|j||dqOd|jt j)vrzt|||||||jt j*fddD]\} }}|j d| |f|j| dq|jt j+fddD]\} }}|j d| |f|j| dq|jt j,fddD]\} }}|j d| |f|j| dqt j j D]}|j|fddD]\} }}|j d| ||-fqq|jt j.fddD]?\} }}|j d| |f|j| d|\}} |j td|| f|| !|| "|#|$| ||&q|jt j/fddD]3\} }}|j d| |f|j| d|\}} |j td|| f|| "|#|$| qP|jt j0fddD]+\} }}|j d| |f|j| d|\} || !|| 1d | vd| vqg}!t|jt j2t j3t j4gdd}"|"D]h\} }}|\}}#}$}%}&| dkrߐq|d urt56||$}'n|j d!|| f||}'|#d urt56||$}(n||#}(||&})|$|)vr|)|$}*n|j#|t7d"}*| 8|'|(|*| || kr3|%r3|!9|q|!D]} || rT|j d#| || !|| &q7| t j)t j0t j/t j.f}zUzC|"D]>\} }}|j d$| |f| | d%d&i|j| d| dkrt||||:|||qg|| !| ;| |qgWn tn| >w| ?}+| @\},}-}.||,7}||-7}| |.7} | A}/|BtC||| |+||/fS)'aapply 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. )rrrT)cleansupdatingsfiles)unittotalrr8sD%s: path conflict - a file or link has the same name as a directory rs&the local file has been renamed to %s s'the remote file has been renamed to %s s1resolve manually then use 'hg resolve --mark %s' )itemrgMbP?)stepr~s %s: %s -> pr smoving %s to %s rUsworker.wdir-get-thread-safe) threadsafe hasretvals %s: %s -> f s %s: %s -> a s %s: %s -> am r9s %s: %s -> dm s %s: %s -> dg sgetting %s to %s s %s: %s -> e xNs! preserving %s for resolve of %s )fileidrMs %s: %s -> m smergedr)Drrrstartp1rrrrrrre MergeAction NO_OP_ACTIONSr makeprogressrrrrsubmergerhrstatusaddpathconflict incrementr+rrWrBrrrDrr-rar[rrrrdrnrlrrrr=rrirsetflagsrrgrmr absentfilectxrrErr3resolver InterventionRequiredcommitrxcountsrcompletert)0r#rsr3r4 overwriterelabelsupdatedmergedrmsr5op num_no_op numupdatesprogressr{r(rforcostprogrUr~f0origf0r getfiledatafinalrrrmoves mergeactionsr6rrrfclfcoactxfca unresolved msupdatedmsmerged msremoved extraactionsrrr applyupdatessz      $                        rcCs|jdd}|jdd}td}|dur|jdd}zddlm}|d|jddd k}Wn t y?d }Ynw|r]|s_||j kra||krct j d re|jtd dSdSdSdSdSdS) Ns fsmonitorswarn_when_unusedswarn_update_file_countr0swarn_update_file_count_rustr) extensionssmodesoffF)slinuxsdarwins(warning: large working directory being used without fsmonitor enabled; enable fsmonitor to improve performance; see "hg help -e fsmonitor") )rrd configintr importrustr<rfindr KeyErrornullidr sysplatformrror)r#num_getsp1nodefsmonitorwarningfsmonitorthresholddirstate_rustmodrfsmonitorenabledrrr_advertisefsmonitorsB       rrsnoneslinears noconflictc : sJddlm} |dus J|s+|s+| durt} tttf} | | vr+d}|| | f;}t|| dur8| r8t}n }|| durHd} | }|d}|}|dur^|g}n-j dddgkrj ||}fd d t|pjgD}n|j||d g}||t|t|f\}}}}|o| }|st|dkrttd | }|rtd }td}tj||d|r)td}||gkrt|||gkr|s| |krtd}td}tj||d|s| s| rtd}td}tj||d| s(t| jD] }| | qnb|s||krQj!dd|ddj!d|dddt"ddddWdS| tkr||g|gfvr| j#dd}|rt$%|g}||vr{ntd}td}tj&||d |r| g}n|s|g}j 'dd} |rd} n|dsd} |s| j#ddsd} t(| |||||| ||d }!| tkr|!)rtd }td}tj||d|!*d!}"|"r^d!}#|"\}$}%}t+,|}&|#|&d"<|$t-j.kr,j /td#|&dr|!0|#t-j1dd$nK|#|vr"|!0|#t-j2dd%n<|!0|#t-j3dd%n2|$t-j4kr^|%\}'}(})}*}+||(5},j /td&|&ddkrY|!0|#t-j6|,dfd'n|!7|#t8j9s|s||ss| j#ddd(s|t:|;dnt:| ;|!tt<=|!j>D]\}#}-j ?td)|#t|-D] }.j ?d*|.qqtt<=|!j@D]\}#}-j ?td+|#t|-D] }.j ?d*|.qƐq|s|j|df\}}}}|dup|A}/| o|/o|  } | r j!dd||djBCd,|DtE|!t-j6f|| o| }0tF|!| |||0|d-\}1}2}3| r|3rht<=|3D]0\}4}5|5D]}6|!j0|6d|4g|6ddRq=|4t-j6krf|0rf|5D] }6d|2|6d<q\q7t|2|0ru|!t-j6fndks{JjGH}|2ri}7tIJjB}8|8durd}2n7|8d}9t<=|2D]\}#}$|$dur|$d.d|9kr|$d|$ddf|7|#<qt<=|7D] \}#}$|$|2|#<qK||t-L|!jM||2tNjBOd,|sjGP||s| QWdn 1swYWdn 1swY| r#j!d|||1jd|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(). rr5Nz&Invalid updatecheck %r (can accept %r)rrTspreferancestor*csg|]}|qSrrr7r^rrrusz_update..)rosoutstanding uncommitted mergesoutstanding merge conflictssuse 'hg resolve' to resolvers7merging with a working directory ancestor has no effectsnothing to merges#use 'hg update' or check 'hg heads'suncommitted changessuse 'hg status' to list changess preupdateTr)throwparent1parent2supdate)rrr )missings+commit or update --clean to discard changess followcopiesF)rrtsconflicting changesrfsjlocal%(l)s changed %(f)s which other%(o)s deleted use (c)hanged version or (d)elete?$$ &Changed $$ &Deletes prompt deletes prompt keepsrother%(o)s changed %(f)s which local%(l)s deleted use (c)hanged version or leave (d)eleted?$$ &Changed $$ &Deletedsprompt recreating)rbranchs<note: possible conflict - %s was renamed multiple times to: s %s s9note: possible conflict - %s was deleted and renamed to: s updatestate)r)Rr<r6UPDATECHECK_LINEARUPDATECHECK_NONEUPDATECHECK_NO_CONFLICT ValueErrorr+rnullcontextmanagerwlockrr configlist changelogcommonancestorsheadsrrnrr3rrr rprrrxrrrLrrr bailifchangedhookrtrr foreground UpdateAbortrdrFrrr partextrasrer promptchoicerkrrrrgrrlrfscasesensitiverzrrrrrrorrvfsrahexrrr0 parentchanger get_fs_now setparents recordupdatesrunlinkr! setbranchprunetemporaryincludes):r#rrrrr3 mergeancestorrrrtupdatedirstate updatecheckwcr6okayr( maybe_wlockplrrpascahsfp1fp2xp1xp2rrrm_arrrrrsvalsr5rr{promptsrr6rrrrrnfrrestatsrrkactsrambiguous_mtimenownow_secrr^r_updates C      $         3                    $ 2      D rc Cst|||d|||dS)zMerge another topological branch into the working copy. force = whether the merge was run with 'merge --force' (deprecated) T)rrrrrtrrr#r)rprrrrrrrmergesrc Cs"t||ddgd||dS)aDo 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 destinationsworking copy parent)rrrrrrr)rprrrrrrWs rWcCst||dd|dS)zDo a clean update to the given commit. This involves updating to the commit and discarding any changes in the working copy. FT)rrrrr)rprrrr clean_updatesrc Cst||ddd||dS)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)rrrrrrr)rprrrrr revert_tosrc CsP|p|d}|}|p|}|j||p"||k}t||dd||||d} |r=| jr=|} n|j} |} |r[t | dkr[|| vr[| || d} | |krd|j} | ry| || t |||| S|j | || |j|t |||Wd| S1swY| S)aIDo 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)rrrrr)rr isancestorrrrrxrrrrr+rr graftcopiesr0rracurrenttransaction) r#rpbaser keepparentkeepconflictparentr3pctxrrpotherrrrrgraftsJ        rcCsF|dur|durd}t||}t||dd|ddS)Ns/must specify parent of merge commit to back outTF)rrrr3r)rr ProgrammingErrorrrr#r)rpparentrr(rrrback_outA s  rc sfdd} |j} g} z|rg} | j|_j|||d} |rt| j}t| j}|r8|r8td}|||f;}n>|rCtd}||;}n3|rNtd}||;}n(|rvd}| D]}||rdj|sd|d7}qT|rptd }||;}n| W| |_S|d 7}j j |dd dkrt td |rt | j| jD]}|sj td || jj|| |q|rt | ddD]$}||r܈j|s|s׈j td|| jj|| |q| W| |_S| |_w)aPurge 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. csRz||WdSty(td|}rt|jtd|YdSw)Ns%s cannot be removeds warning: %s )rHrr rrro)removefnrzr abortonerrorr#rrru s   zpurge..remove)r ignoredunknowns3permanently delete %d unknown and %d ignored files?s$permanently delete %d unknown files?s$permanently delete %d ignored files?rrs1permanently delete at least %d empty directories?s (yN)$$ &Yes $$ &No)defaultsremoval cancelledsremoving file %s T)reversesremoving directory %s ) traversedirrrrr r rr,listdirrrr CanceledErrorrnrrrmdir)r#rr r removeemptydirs removefilesr noopconfirmroldtraversedirr directoriesr nb_ignored nb_unknownr( dir_countr5rrrpurgeQ sh$        rr9rr*)NFNNFTNN)NFNr)NNFFN)TFTTFFF)F __future__rrrIstructi18nrrr thirdpartyrutilsr dirstateutilsrr<r r r r r rrrerrrrrrrrpack_packunpack_unpackr)r7objectr8rrrrrrrr2r4rFrLrWrnrrrrtrrUPDATECHECK_ABORTrrrrrrWrrrrrrrrrs      @ 8!D #0  I 'V   5  #    L