o ]Lb( @s$dZddlmZddlmZddlmZmZmZm Z m Z m Z m Z mZmZmZmZiZeeZiZeeZeddddedd ddd Z d#d d Zedddd edfdddedfdddededfgejejejejedejdddZddZedgejdd d!d"Zd S)$aHuncommit part or all of a local changeset (EXPERIMENTAL) This command undoes the effect of a local commit, returning the affected files to their uncommitted state. This means that files modified, added or removed in the changeset will be left unchanged, and so will remain modified, added and removed in the working directory. )absolute_import)_) cmdutilcommandscontextcopieserrorobsutilpathutilpycompat registrar rewriteutilscmutil experimentaluncommitondirtywdirF)default uncommit.keepsships-with-hg-coreNc s|}t|}fdd|D} | sdS|s|S|| t||fddtD|dffdd } sH|j t d |durP| }|sV| }|s\| }tj|||jg|| |||d } || S) zrRecommit ctx with changed files not in match. Return the new node identifier, or None if nothing changed. csh|]}|r|qSr.0f)matchr0/usr/lib/python3/dist-packages/hgext/uncommit.py Gsz"_commitfiltered..Ncsi|] \}}|vr||qSrr)rdstsrc)filesrr Tsz#_commitfiltered..rc sF||vrdS||}tj|||||||d}|S)N) copysource)r memfilectxpathdataislinkisexecget)repomemctxr contentctxredirectfctxmctx)copiedrr filectxfnXs z"_commitfiltered..filectxfnsnote: keeping empty commit parentstextrr,userdateextra)p1setrnode copiesmod pathcopiesr iteritemsuistatusr descriptionr0r1rr&nullidr2 commitctx) r%ctxr keepcommitmessager0r1base initialfilesexcluder,newr)r+rrr_commitfiltered>s@      rEuncommitkeeps(allow an empty commit after uncommittingsallow-dirty-working-copys'allow uncommit with outstanding changesnsnotesstore a note on uncommitsTEXTs[OPTION]... [FILE]...) helpcategoryc Os~t|t||t|}|||}|j|j |j |j f\}}}}t t ||||t |@} |dpH|jdd} | sX|rO| rXtj|tdd|d} t|| gdt| dkruttd t| ||} | r| j| | d d } t | j t | jBt | j B}t | |}|r|d d t|D8}t|D]*}|| j vrtd}n|j!"|rtd}ntd}tjtdt#|||d|$d|ds|ds| %|d<t&||}|}|s|'ddur |'d}n|dd}t(|| | |||'d|'dd}|durC|td WdWdWddSi}|| )krV|f|| )<nd|| )<|j*+t,|||| Wdn 1svwYtj-||dd dWdn 1swYWdn1swYWddSWddS1swYdS)auncommit part or all of a local changeset This command undoes the effect of a local commit, returning the affected files to their uncommitted state. This means that files modified or deleted in the changeset will be left unchanged, and so will remain modified in the working directory. If no files are specified, the commit will be pruned, unless --keep is given. sallow_dirty_working_copyrrs/requires --allow-dirty-working-copy to uncommit)hint.rFscannot uncommit merge changesetT) listcleancSsh|]}|qSrrrrrrrszuncommit..s0file was not changed in working directory parents.file was untracked in working directory parentsfile does not existscannot uncommit "%s"smessageslogfilerHNrsusersdate)r@r0r1snothing to uncommit rfixphase).rcheck_note_sizeresolve_commit_optionsr byteskwargswlocklockr:modifiedaddedremoveddeletedanyr4r9 configbool bailifchangedrr precheckrevlenr.r InputErrorrrrr3r dirssortedcleanwvfsexists getuipathfn transactionr; logmessager$rEr5dirstate parentchange movedirstate cleanupnodes)r9r%patsoptsstmard isdirtypathallowdirtywcopyoldrseligiblebadfilesrrKr@r?newidmappingrrruncommit~s                J  Tr|ccs6|jj|dD] }t||Vq dS)zFyields the obsolete markers marking the given changeset as a successorrN)r%obsstore predecessorsr$r5r marker)r>r!rrrpredecessormarkerssrunamendT)rJ helpbasicc s|}|||d|dt|gdtdkr1t t dd}t fdd|DsEt t dt t}t|dkr^t d }t |t||d }||}|d <fd d } tj|f| |d} || } || } |j} | t|| Wdn1swY| fi}tj ||dddWdn1swYWdn1swYWddSWddS1swYdS)a3undo the most recent amend operation on a current changeset This command will roll back to the previous version of a changeset, leaving working directory in state in which it was before running `hg amend` (e.g. files modified as part of an amend will be marked as modified `hg status`) rrLrMscannot unamend merge changeset)s amend_sourceunamend_sourcec3s|] }|vVqdSN)r2)rkey)curctxrr szunamend..sAworking copy parent was not created by 'hg amend' or 'hg unamend's:changeset must have one predecessor, found %i predecessorsrrcs"z|WStyYdSwr)filectxKeyError)r%ctx_r )predctxrrr,.s   zunamend..filectxfnr-NTrO)! unfilteredrTrUrgr r]r^r_r.rr`rrZlistrprednoder2hexrr&r3p2r;rr0r1r=rirjrrkr5rl)r9r%rnunfi expected_keysmarkerserextrasr,newctx newprednode newpredctxrir{r)rrrunamendsV        Pr)NNN) __doc__ __future__rmercurial.i18nr mercurialrrrrr6rr r r r r rcmdtablecommand configtable configitem testedwithrEwalkopts commitopts commitopts2 commitopts3CATEGORY_CHANGE_MANAGEMENTr|rrrrrrsf  4    @     g