o ]Lb@sdZddlmZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z ddlmZdZiZe eZdd Zed ged ejd d ddZddZGdddeZGdddeZddZddZddZddZddZd d!Zd"d#Z d$d%Z!d&d'Z"d(d)Z#d*d+Z$d,d-Z%d.d/Z&d0d1Z'd2d3Z(d4d5Z)d6d7Z*d8d9Z+d:d;Z,dd?Z.d@dAZ/dBdCZ0dDdEZ1dFdGZ2dHdIZ3dJdKZ4dLdMZ5dNdOZ6dPdQZ7dRdSZ8dTdUZ9dVdWZ:dXdYZ;dZd[Zd`daZ?dbdcZ@dddeZAdfdgZBidhediedjedkedledmedne!doe"dpe#dqe$dre%dse'dte(due)dve*dwe+dxe,idye-dze.d{e/d|e0d}e1d~e2de3de4de5de6de7de8de9de:de;de<de=eBe&dZCe>e?e@eAdZDdS)ztry mapping git commands to Mercurial commands Tries to map a given git command to a Mercurial command: $ hg githelp -- git checkout master hg update master If an unknown command or parameter combination is detected, an error is produced. )absolute_importN)_)encodingerror fancyoptspycompat registrarscmutil)procutilsships-with-hg-corecCs<|dr |ddSd|vr|dd}tdd|}|S)Nsorigin/sHEAD.s~$s~1) startswithreplaceresub)sr//usr/lib/python3/dist-packages/hgext/githelp.pyconvert,s   rs githelp|gits hg githelpT) helpcategory helpbasiccOst|dkst|dkr|ddkrttd|ddkr%|dd}|d}|tvr6ttd||d|dd}t|||g|Ri|S)zgsuggests the Mercurial equivalent of the given git command Usage: hg githelp -- rsgits8missing git command - usage: hg githelp -- Nserror: unknown git command %ssgithelp)lenrAbortr gitcommandspager)uirepoargskwargscmdrrrgithelp6s$     r!c CsZt|}i}t|} z tt|||d}Wn|tjy}znd|jvr&d|j|jvr7dt|j}nd|j|jvrHdt|j}n t t dt|jz| |Wn"t y~t d}t d }tj |t|j|t|jd w| t d |WYd}~nd}~wwq td d |D}tdd t|D}||fS)NTzrequires argumentz------sunknown option %ss-unknown option '%s' packed with other optionss2please try passing the option as its own flag: -%s)hintsignoring unknown option %s cSg|]}t|qSrr).0xrrr sz parseoptions..cSs.g|]\}}t|tr|t|fn||fqSr) isinstancebytesr)r(kvrrrr*us)listrgetopt GetoptErrormsgoptrbytestrrrrremove Exceptionwarndict iteritems)r cmdoptionsroptsexflagr3r%rrr parseoptionsTsL  r?c@sFeZdZddZddZeeZddZddZ d d Z d d Z d S)CommandcCs||_g|_i|_dSN)namerr<)selfrBrrr__init__s zCommand.__init__cCsd|j}|jr6tt|jD]%\}}|D]}|r-t|tr"d}nd}||||f7}q|d|f7}qq|jrE|d7}|d|j7}|S)Nshg s %s %ds %s %ss %s ) rBr<sortedrr:r,intrjoin)rCr r.valuesr/fmtrrr __bytes__s   zCommand.__bytes__cC|j|dSrA)rappend)rCvaluerrrrMzCommand.appendcCrLrA)rextend)rCrIrrrrPrOzCommand.extendcCs|j|g}||dSrA)r< setdefaultrM)rCkeyrNrIrrr __setitem__szCommand.__setitem__cC t||SrA AndCommandrCotherrrr__and__ zCommand.__and__N) __name__ __module__ __qualname__rDrKr strmethod__str__rMrPrSrYrrrrr@~s  r@c@s$eZdZddZddZddZdS)rVcCs||_||_dSrAleftright)rCrarbrrrrDs zAndCommand.__init__cCsd|j|jfS)Ns%s && %sr`)rCrrrr_rOzAndCommand.__str__cCrTrArUrWrrrrYrZzAndCommand.__and__N)r[r\r]rDr_rYrrrrrVs rVcOszddg}t|||\}}|dr|tdtd}ntd}|ds,||n|td|t|d dS) N)AallNppatchNrerhsUnote: Mercurial will commit when complete, as there is no staging area in Mercurial commit --interactiveaddrds?note: use hg addremove to remove files that have been deleted  )r?getstatusrr@rPr-rrrrr;r<r rrradds(    rocO,g}t|||td}|t|ddS)Nsimportrkr?r@rmr-rrrrr;r rrrams rscOsvddtdfdg}t|||\}}td}|dr |d|d<|dr,|d|d<|||t|ddS) Nrgre)re directoryreresimport --no-commit-prts--prefixrk)rGr?r@rlrPrmr-rnrrrapplys    rvcO|tddS)Ns,see 'hg help bisect' for how to use bisect rmrrrrrrrrbisectsrzcOsDg}t|||\}}td}|dd|D|t|ddS)Ns annotate -udlcSr&rr')r(r/rrrr*r+zblame..rkr?r@rPrmr-rnrrrblames r|c Os(gd}t|||\}}td}|ds|dr#|tddS|dr:td}|D]}||d<q.d|d<nP|d rit|d krTt|d krQ|d }n d }nttd |d } ||d<| | n!t|d kr}|d |d<| |d n t|d kr| |d |t |ddS)N))res set-upstreamNre)resset-upstream-torereddeleteNre)DrNre)mmoveNre)MrNrebookmarks set_upstreamsset_upstream_tos.Mercurial has no concept of upstream branches rsstrip-Brrrs"`hg log -T"{activebookmark}" -r .`smissing newbranch argument-m-rrk) r?r@rlrmrrpoprrrMr-) rrrrr;r<r brancholdnewrrrrs4           rcCsht||rdS|}|dkr|}n|d|}|j|}|r#dS|d}||vp1||}|S)a The first argument to git checkout can either be a revision or a path. Let's generally assume it's a revision, unless it's obviously a path. There are too many ways to spell revisions in git for us to reasonably catch all of them, so let's be conservative. Fre/Tr )r isrevsymbolgetcwdwvfsexistsmanifesthasdir)rstringcwdrepopathrrdidexistrrrispath"s    rc Osgd}g}d|vr |d}|||dd|d|}t|||\}}d}|r8t||dr8||}n|rF|d}|dd|}td} |drW|sS|rWd| d<|drdtd } d| d <|d rt|dkr|td } | |d ne| |dtd } | |d | | @} nMt|dkr|t d td } |drd| d <|r|| d<| |n'|r|dr|| d<n| |n|drtd } d| d<nt t d|t | ddS)N)bbranchrere)BrrerefforceNrerfr"rrupdaters-Crhrevert-irrs5note: use --no-backup to avoid creating .orig files r--allsa commit must be specifiedrk) indexrPr?rr@rlrrMrmrrrr-) rrrrr;pathssepindexr<revr bookcmdrrrcheckout?sZ                rcOsgd}t|||\}}td}|drd|d<|dr#d|d<n|dr1|tddS|||t|d dS) N)recontinueNrereabortNre)eeditNresgraftrs--editr --continuers&note: hg graft does not have --abort rkr?r@rlrmrrPr-rnrrr cherrypicks     rcOsPgd}t|||\}}td}|drd|d<|||t|ddS)N))r~r~Nrer)xrNrespurgerrrk)r?r@rlrPrmr-rnrrrcleans  rcOsgd}t|||\}}t|dkrttdtd}||dt|dkr1||d|drBd|d<|tdn |d rKd|d<|d r`td }||d ||@}|t |d dS) N))rebareNre)ns no-checkoutNrerrs'a repository to clone must be specifiedclonerrs-Usanote: Mercurial does not have bare clones. -U will clone the repo without checking out a commit s no_checkoutrrrk) r?rrrrr@rMrlrmr-)rrrrr;r<r cocmdrrrclones,     rcOs gd}t|||\}}td}|drtd}|dr,|dr(td}nd|d<|dr8|d|d <|d rGd |d f|d <|d rS|td|dr_|d|d<|drk|d|d<|drw|d|d<|||t|ddS)N) ardNre)rmessagerererf)Cs reuse-messagerere)Ffilerere)reauthorrere)redaterere)reamendNre)resno-editNrecommitrhrirsno_edits--amends reuse_messages-Mrs'%s'rrdsqnote: Mercurial doesn't have a staging area, so there is no --all. -A will add and remove files for you though. r-lrs-ur-drkrrnrrrcommits6            rcOrw)NsXthis command has been deprecated in the git project, thus isn't supported by this tool )r8rryrrr deprecated rc Osgd}t|||\}}td}|dr|td|dr%d|d<t|D] }||z ||||d<Wq)tyI| |Yq)w|t |ddS) N)r)recachedNre)RreverseNrediffrsLnote: Mercurial has no concept of a staging area, so --cached does nothing rs --reverserrk) r?r@rlrmrr0r6revsr7rMr-)rrrrr;r<r arrrdiffs(       rcOrw)NsMercurial does not enable external difftool by default. You need to enable the extdiff extension in your .hgrc file by adding extdiff = to the [extensions] section and then running hg extdiff -p See 'hg help extdiff' and 'hg help -e extdiff' for more information. rxryrrrdifftool'rrcOsddg}t|||\}}td}t|dkrA||dt|dkrA|td|ddD]}||jvr<||d<q0||d<q0|t|d dS) NrerdNrerpullrrnote: Mercurial doesn't have refspecs. -r can be used to specify which commits you want to pull. -B can be used to specify which bookmark you want to pull. rrrkr?r@rrMrmr _bookmarksr-rrrrr;r<r r/rrrfetch5s$     rcOs:g}t|||\}}td}|||t|ddS)Ngreprkr{rnrrrgrepRs  rcOsJg}t|||\}}td}t|dkr||d|t|ddS)Ninitrrkr?r@rrMrmr-rnrrrinit_s  rc Osgd}t|||\}}|dp|d}|r+td}||d<|dt|dS|td|tdtd }d|d <|d rM|d |d <|d rVd |d <|dr_d|d<|drhd|d<|drqd|d<|ds|ds|dr|dd}d|vr|tdd|d<n |tdd|d<t|dkrd|dvr|dd\} } d | | f|d!<|d=|||t|d"dS)#N) )resfollowNre)resdecorateNre)rnumberrere)1rNrereprettyrere)reformatrere)reonelineNre)restatNre)regraphNrerf)Gs grep-diffrere)Ss pickaxe-regexreres grep_diffs pickaxe_regexrs--diffs%s senote: -v prints the entire commit message like Git does. To print just the first line, drop the -v. sFnote: see hg help revset for information on how to filter log output logs-vrrrr--statrs-Grhrurrrreformat:scnote: --format format:??? equates to Mercurial's --template. See hg help templates for more info. s???s --templatesqnote: --pretty/format/oneline equate to Mercurial's --style or --template. See hg help templates for more info. s--stylers..s'%s::%s'rrk) r?rlr@rmr-rrsplitrP) rrrrr;r<grep_patr formatsinceuntilrrrlogksh          rcOsgd}t|||\}}|ds |ds |ds |drItd}|dr-d|d<|dr6d|d<|dr?d|d <|drHd|d <ntd }|d rY|td |drbd|d<|d|D] }t||d<qi|t|ddS)N))crNre)r~deletedNre)rmodifiedNre)oothersNre)iignoredNre)sstageNre)z_zeroNrerrrrstatusrrs-orsfilesrs>note: Mercurial doesn't have a staging area, ignoring --stage rs-0r s-Irk) r?rlr@rmrrMr shellquoter-)rrrrr;r<r includerrrlsfilessB        rcOsRg}t|||\}}td}t|dkr||t|d|t|ddS)Nmergerrrkrrnrrrmerges  rcOshg}t|||\}}t|dkrddg}td|d|df}|tdtd|t|d dS) Nrcrs&log -T '{node}\n' -r 'ancestor(%s,%s)'rrs1note: ancestors() is part of the revset language s3(learn more about revsets with 'hg help revsets') rk)r?rr@rmrr-rnrrr mergebases rcOsNg}t|||\}}td}t|dkrd|d<|||t|ddS)Nsresolverrrk)r?r@rrPrmr-rnrrr mergetools  rcObddg}t|||\}}td}|||drd|d<|dr'd|d<|t|ddS) Nrrsdry-runNremvr-fdry_run-nrkr?r@rPrlrmr-rnrrrmv   r cOsgd}t|||\}}td}d|d<t|dkrE||dt|dkrE|td|ddD]}||jvr@||d<q4||d<q4|t|d dS) N)rr)rrebaseNrers--rebaserrrrrrkrrrrrpull$s"     rcOsddg}t|||\}}td}t|dkrA||dt|dkrA|td|ddD]}||jvr<||d<q0||d<q0|d rJd|d <|t|d dS) Nrrpushrrsnote: Mercurial doesn't have refspecs. -r can be used to specify which commits you want to push. -B can be used to specify which bookmark you want to push. rrrrrk) r?r@rrMrmrrrlr-rrrrpushCs(      rcOsgd}t|||\}}|dr3|tdtd}t|dkr)|td|t|ddS|drDtd }|t|dtd }|d sR|drVd|d <|d r_d|d<|dr|tdt|d|d<t|dkrt tddt|dt|df|d<n%t|dkrt|d|d<nt|dkrt|d|d<t|d|d<|t|ddS)N)r)r interactiveNre)reontorererr)reskipNrersEnote: hg histedit does not perform a rebase. It just edits history. shisteditrscalso note: 'hg histedit' will automatically detect your stack, so no second argument is necessary rkrsrevert --all -r .r rrrs--abortrsxnote: if you're trying to lift a commit off one branch, try hg rebase -d -s rrs(expected format: git rebase --onto X Y Zs '::%s - ::%s'rs-ss-b) r?rlrmrr@rr-rrrrnrrrrebasecsR      "  rcOsldg}t|||\}}td}|drd|d<t|dkr%||d|t|d|tddS)Nrsjournalrdrrs sHnote: in hg commits can be deleted from repo but we always have backups )r?r@rlrrMrmr-rrnrrrreflogs  rc Osgd}t|||\}}tt|dkr|dnd}|d}|dr+|td|dr7|tdtd }|rB|d |||t|d dS) N))resoftNre)rehardNre)remixedNrerr rrsBnote: --mixed has no meaning since Mercurial has no staging area rsAnote: --soft has no meaning since Mercurial has no staging area rs--cleanrk) r?rrrlrmrr@rMr-) rrrrr;r<rhardr rrrresets*     rcOs\g}t|||\}}t|dkr|tdtd}|r$||d|t|ddS)Nrs;note: hg backout doesn't support multiple commits at once sbackoutrrk)r?rrmrr@rMr-rnrrrreverts rcOsrddg}t|||\}}|ds|dr0td}|dr&|td|t|ddS|tddS) N)res show-cdupNre)res show-toplevelNres show_cdups show_toplevelsroots1note: hg root prints the root of the repository rks5note: see hg help revset for how to refer to commits )r?rlr@rmrr-rnrrrrevparses rcOr) Nrrrmrrrrrkr rnrrrrmr rcOsddddtdfg}t|||\}}|dr5|ddkr&td }d |d <nRtd }|d |dnCt|dkr`t||drGtd}ntd}|||dr_|d|dfn|drttd}|d|dfntd}|t |ddS)N)res name-statusNrerUsunifiedres name_statusrrrr s--changers--style statuss-r .rscatsexports--config diff.unified=%drk) rGr?rlr@rMrrrPrmr-rnrrrshows2          r cOsdg}t|||\}}td}t|dkr|dnd}|dkr-d|d<|dr,d|d<n|dkrM|dr;d|d<nd|d <t|d krL||d nw|d krVd|d <nn|d krrd|d<t|d krl||d nX|dnR|dksz|dkrtd}t|d kr||d |dkrd|d<n0|dks|dkr|tddSt|dkr|ddkr|d|d<n t|d kr|d |d<|t|ddS)Nrfsshelverlistrrhrushowrrsclears --cleanupsdroprs spopapplysunshelves--keeprscreatesTnote: Mercurial doesn't have equivalents to the git stash branch or create actions ssaves--namerk)r?r@rrlrMrmrr-)rrrrr;r<r actionrrrstash/sX            r%cOsNdg}t|||\}}td}|||drd|d<|t|ddS)N)rerNrerrrrkr rnrrrrmcs  rmcOs\|s ttd|d}|tvrttd||dd}t|||g|Ri|S)Nsmissing svn commandrsunknown git svn command "%s"r)rrrgitsvncommands)rrrrsvncmdrrrsvnrs r(cOrp)Nrrkrqrrrrr svndcommit}s r)cOs6g}t|||td}|d|t|ddS)Nr default-pushrkr?r@rMrmr-rrrrrsvnfetchs   r,cOsNg}t|||\}}|sttdtd}|d|d<|t|ddS)Nsmissing find-rev argumentrrrrk)r?rrrr@rmr-rnrrr svnfindrevs r-cOsRdg}t|||td}|dtd}|d||@}|t|ddS)N)lslocalNrerr*r stiprkr+)rrrrr;pullcmd rebasecmdr rrr svnrebases   r1cOsgd}t|||\}}|drtd}n2td}|s#ttd||dt|dkr6|d|d<|d r?d|d <|d rHd|d <|t |d dS)N)r)r.r!Nrer}r!stagstagsmissing tag argumentrrrrs--removerrrk) r?rlr@rrrrMrrmr-rnrrrtags      r3rjsamr#sbisectsblamerscheckouts cherry-pickscleanrrrsdifftoolfetchrrrsls-filesrs merge-bases mergetoolrrrr sreflogsresetrs rev-parserr"sstashrssvn)r2s whatchanged)sdcommitr4sfind-revr )E__doc__ __future__rr1rmercurial.i18nr mercurialrrrrrr mercurial.utilsr testedwithcmdtablecommandr CATEGORY_HELPr!r?objectr@rVrorsrvrzr|rrrrrrrrrrrrrrrrrrr rrrrrrrrr r%rmr(r)r,r-r1r3rr&rrrrs       *) ,@#5    P-   >#!4          !"#(