o ]Lb[k @sddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlmZddlmZmZmZmZddlmZmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z3m4Z4m5Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZMmNZNmOZOmPZPmQZRmSZSmTZUmVZVmWZWddlXmYZYdd lZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`dd lambZcmdZdmeZemfZfe3jgZgiZhehieKjjjke>jehZjejd ged d dddZlejdgddZmejdgdddZnejddddedfdddedfdd ded!fd"d#ded$fged%  & & & &dd'd(Zodd)d*Zpdd+d,Zqdd-d.Zrd/d0Zsdd1d2Ztejd3d4d5ded6fd"d7ged8fd"d9ded:fgedd d;ddged?d d;d@dAZvejdBdCgdDdEdFZwejdGgd"dHdIZxejdJd"dKdedLfgdMdNdOZydPdQZzdRdSZ{ejdTgddUdVZ|ejdWdXdYdedZfd[d\ded]fd"d^ded_fd`dadedbfgedcd dddddeZ}ejdfe#j~edgddhdiZejdjdkdldedmfgednd d doddpdqZejdre#j~e#jedsd dddtduZejdvd"dwdedxfd"dyd edzfd"d{ded|fd"d5d&ed}fged~ddZejdged"ddZejdd"ddedfd"ddedfd"dgdfdddge#je#jeddddZdZejdddd"edfgd ddddZejde#jgd dddZejdddd"ededDfd"dd&edfd`ddedfddgededfgedddZejdd"dd"ededfd"dd"ededfd"dd&edfge#jddZejdge#jddZejdgedd d;dddZejdddgededfddgededfdXddedăedŃfgedƃd d;dddȄZejdgdʃdd̄Zejde#j~e#jedsdddτZejde#j~edsd dddd҄ZejdgddՄZejdge#jd"d d;dd؄Zejdgedڃd d;dd܄ZejdgedރddZejddddedfdddedfd`ddedfdddedfged~ddZejdd"dd&edfd4dgededfgd"dddZejdge#jd"ddZejdgedddZejdd"dd&edfd"dd&edfd"dd&edfd"dd&edfgdd Zejd d"d ded fd"d d&edfddgedfd"dd&edfd"dd&edfd"dgedfge#je#jeddېddZejdddd"ededDfgedddZejdddd"ededDfgedddZejd d!d"ded#fdd$ded%fd4d&ded'fdd(ded)fged*d+d,Zejd-e#jd.d d/d0d1Zejd2ged?d d;d3d4Zejd5ddd"ed6edDfd"d7ded8fge#je#jed9d d/d:d;Zejdd?Zejd@gedAdېdBdCZejdDddd"edEedDfd"dFdedGfgeddHdIZejdJd"dKd&edLfgd"dMdNZejdOddd"ededDfgedPdQdRZejdSgd"dTdUZejdVe#j~dWdXd&edYfgedsd ddېdZd[Zejd\e#j~d!d]ded^ed_fged`d ddېdadbZejdcd"dddedefd"dfd edgfd`dhdedifddgededfd"djd&edkfd"dld&edmfgdndodpZejdqd"drd&edsfd"dtd"edufd"dvd"edwfgd"dxdyZejdzged{dېd|d}Zejd~e#j~edgdېddZejdgdd ddېddZejddge#jedddZejdddd"ededDfgeddېddZejdd dddZejdd"dd&edfgedddZejdgddZejdddgededDfddgededfgedd dddZejdddd"ededfgedd d;dddZejdddd"ededfgedd d;dddZejdgddZejddddgededfd"dd&edfd"dd edfd"ddedfd"ddedfd"ddedfgdddZejde#jedd d/dd„ZejdgedDdĐdńZejdgdǢe#jedȃd d;dɐdʄZdːd̄Zejdd"dd&edσfd"dd"edуfd"dd&edӃfd"dd&edՃfge#jedd ddېd֐dׄZdS()absolute_importN)_)binhexnullrevshort)getattropen)4bundle2 bundlerepo changegroupcmdutilcolorcontextcopies dagparserencodingerrorexchange extensions filemerge filesetlang formatterhghttppeer localrepolock logcmdutil mergestatemetadataobsoleteobsutilpathutilphasespolicypvecpycompat registrarrepairrepoview requirementsrevlogrevset revsetlangscmutil setdiscovery simplemergesshpeersslutil streamclonestriptags templater treediscoveryupgradeurlutilvfswireprotoframingwireprotoserver) repository)cborutil compressiondateutilprocutil stringutilurlutil)deltasnodemaprewritesidedatas debugancestors[INDEX] REV1 REV2T) optionalrepoc Gst|dkr|\}}}ttjtdd|}|j}n!t|dkr6|s+tt d|\}}|j }|j}ntt d| ||||}| d| |t|fdS) zGBDK|qyDK~v2MM*sz!debugbuilddag..rwsbuildings revisions)unittotalsbuilddagdefaultsnode %s smfcsg|]}|qSra)data)rxxfnrarbrzs cSsg|]}|qSrar5rxlrararbrzs s r%isofsr%i snf%isnfcs |vrt||||SdSN)r memfilectx)rZcxpath) filecontentrarbfctxfn9s  zdebugbuilddag..fctxfncsg|]}|qSrararxp)nodeidsrarbrzEr%irsbranch)dateuserextralstag %s %s %s as branch %s s localtags)#statusrfinreadrUrPrrTrparsedagr'xrangeappend makeprogresswlockr transactionupdatenotebytestrrVr1 Merge3Textrender_minimizedrsplitrj startswithrmemctx commitctxrnoder<rW)"rYrZtextmergeable_fileoverwritten_filenew_file from_existingclr|typer linesperrevinitialmergedlinesr6progressatatbranchidpsfilesp2p1pabaselocalotherm3ml mergedtextrparsrnodeidnamera)rrrrb debugbuilddagsB  .                          Trc sd||r8dfdd}|d|dtjiD] }|d}||q+dSttjrEt t d D]}|\} } } } } }}} d t | fqMdS) N s3%sformat: id, p1, p2, cset, delta base, len(delta) c sld|fD]&}|\}}}}}}}} dt|t|t|t|t|t|fq dS)Ns %s%s s%s%s %s %s %s %s %d )rW deltaiterrrP) named deltadatarrrcs deltabasedeltaflagsrIrq indent_stringrYrarb showchunkshs  z%_debugchangegroup..showchunks changelogmanifestsfilenamesuse debugbundle2 for this file%s%s ) writenoi18nchangelogheadermanifestheaderiter filelogheader isinstancer unbundle20rrTrrrWr)rYrqallindentoptsr chunkdatarprrrrrrrrrIrarrb_debugchangegroup`s.   rc Kst|}|}d|}z t|\}}Wn%tjy;}zd} | ||jt|f;} | | WYd}~dSd}~wwd} | ||t|f;} | | | d|} t |D]} t d| } | | |t| | qV| dS)/display version and markers contained in 'data'rs%%sunsupported version: %s (%d bytes) Ns%sversion: %d (%d bytes) debugobsolete)r' byteskwargsrr! _readmarkersrUnknownVersionversionrPrWrsortedr"marker startitemplainr showmarkerend) rYpartrrrrrmarkersexcmsgfm rawmarkermrararb_debugobsmarkerss*       rcCsVd|}t|}tjD]}||D]}|||dt|tj|fqq dS)rrrN)r$ binarydecode allphasesrWr phasenames)rYrrr headsbyphasephaseheadrararb_debugphaseheadss    rcsBtttjtjfrddfddtDSt t S)Ns{%s}, c3s |] }d||fVqdS)s%s: %sNra)rxkthingrarb z_quasirepr..) rdictr;sortdict collections OrderedDictrjrr'rreprrrarrb _quasireprs rc Kst|tjs ttd|dt|j| dg}| D]_}|r+|j |vr+q!d}|||j t|j|j f|j dkr^|j dd}t ||d}|js^t||f|d d ||j d krq|jsqt||fd d i||j d kr|jst||d dq!dS)zlists the contents of a bundle2snot a bundle2 filesStream params: %s part_types%s -- %s (mandatory: %r) s changegroupsversions01sUN)rrs obsmarkersrs phase-heads)rN)rr rrrTrrWrparamsget iterpartsr mandatoryr getunbundlerquietrrr) rYrqrr parttypesrrrcgrararb _debugbundle2s,      rs debugbundlerallsshow all detailss part-typesshow only the named part typesspecs"print the bundlespec of the bundle)norepocKst||K}|rt||}|d| WddSt|||}t|tjr>t ||fd|i|WdSt ||fd|i|WddS1sTwYdS)zlists the contents of a bundle%s Nr) rrmr getbundlespecrWrnrr rrr)rY bundlepathrspecrrkrqrararb debugbundles    "rsdebugcapabilitiessPATHc Kst|}t|||}zP|}|dt|D] }|d|qt |}|rO|dtt |D]\}}|d||D] } |d| qDq7W| dSW| dS| w)z'lists the capabilities of a remote peersMain capabilities:  %s sBundle2 capabilities: s %s N) r'rrpeer capabilitiesrrrWr bundle2caps iteritemsclose) rYrrrcapscb2capskeyvaluesvrararbdebugcapabilitiess&      r'sdebugchangedfiles)rwscomputeFs6compute information instead of reading it from storagesREVcKst||d}d}|drt|}n|j|}|tj}|dur*t |}|durt |j D]R}||j vr=d} n||j vrEd} n||jvrMd} n ||jvrUd} nd} d} d} ||jvrhd } |j|} n ||jvrtd } |j|} | | || f} d } || | q3dSdS) z,list the stored files changes for a revisionNcomputeaddedremovedsmergedssalvagedstouchedrwp1p2s%-8s %2s: %s, %s; )r revsingler compute_all_files_changesrUrIrXr SD_FILESdecode_files_sidedatartouchedaddedremovedmergedsalvagedcopied_from_p1copied_from_p2rW)rYrZrXrctxrsd files_blockrkaction copy_parent copy_sourcertemplaterararbdebugchangedfiless@            r?sdebugcheckstatec Csz|j\}}||}||}d}|j||D]}||d|dd|d7}q|r;td}t|dS)z0validate the correctness of the current dirstaterrNs8.hg/dirstate inconsistent with current parent's manifest)dirstateparentsmanifestverifywarnrrrT) rYrZparent1parent2m1m2errorserrerrstrrararbdebugcheckstate+s    rLs debugcolorsstylesshow all configured styless hg debugcolorcKs0|dt|j|drt|St|S)z&show available color, effects or stylescolor mode: %s style)rrDpprint _colormoder _debugdisplaystyle_debugdisplaycolorrYrZrrararb debugcolor:s rScCs|}|jt|D]}||j|<q|jrB|dD]!\}}|dr3|dd|j|<q |drA|dd|j|<q | t dt |j ddd }|D] \}}|j d ||d qVdS) Nscolorscolor.s terminfo. savailable colors: cSsd|dv|d|dfS)N_rrra)ryrararbUz$_debugdisplaycolor..r$rlabel) copy_stylesclearr_activeeffectskeys_terminfoparams configitemsrrWrritems)rYeffectrr&rc colornamer[rararbrQHs      rQc stdjs dStddjD}tjD]8\}}jd||d|rPddtd|t|d fd d|Dd qdS) Nsavailable style: cs|]}t|VqdSrrPrxsrararbr^z%_debugdisplaystyle..%srZs: rrrc3s|] }||VqdSrrZrxerYrarbrer) rWrr]maxrrcrPrjr)rYwidthr[effectsrarnrbrPZs " rPsdebugcreatestreamclonebundlecCsTt|r |tdt|\}}t||||tdd t |dS)zcreate a stream clone bundle file Stream bundles are special bundles that are essentially archives of revlog files. They are commonly used for cloning very quickly. s=(warning: stream clone bundle will contain secret revisions) sbundle requirements: %s rN) r$ hassecretrDrr4generatebundlev1r writechunksrWrjr)rYrZrpr+rqrararbdebugcreatestreamclonebundleis  rvsdebugdagtstagssuse tags as labelsbbranchessannotate with branch namessdotssuse dots for runsssspacessseparate elements by spacessPTION]... [FILE [REV]...]c s|d}|d}|r(ttjtdd|ddDfdd}n;|r\|j|d |d rRi|D]\}}   | g |qAfd d}nt td tj||d d ||ddD] } || |dqpdS)aformat the changelog or an index DAG as a concise textual description If you pass a revlog index, the revlog's DAG is emitted. If you list revision numbers, they get labeled in the output as rN. Otherwise, the changelog DAG of the current repo is emitted. spacesdotsFrLcSsh|]}t|qSra)intrxr_rararb rzdebugdag..c3sLD] }d|tdd|DffV|vr#d|d|ffVqdS)Nrvcs|] }|dkr|VqdSr}Nrarrararbrro+debugdag..events..rr)list parentrevs)r_)revsrlograrbeventss"zdebugdag..eventsr6branchesc3sd}D]A}r |dd}||kr d|fV|}d|tdd|DffVrF|}|rF|D] }d||ffVq.revinfoss rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratios) readsize largestblk rddensity srchunksrrrr}slrev chainid chainlen prevrev deltatype compsize uncompsize chainsize chainratio lindist extradist extraratios7%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f) rXchainidchainlenprevrevrrrr chainratiolindist extradist extraratios*readsize largestblock readdensity srchunkss %10d %10d %9.5f %8d)readsize largestblock readdensitysrchunksN)r'rr openrevlogr\startlength _generaldeltar rrrrP IndexErrorfloatrrW deltautil slicechunkr) rYrZrrrrwithsparsereadrr chainbasesrXcompuncomprrr chainbaser basestartrevstart lineardistrrrrrrr revschunkblkendblksizerrarrbdebugdeltachains )        rsdebugdirstate|debugstatesnodatess+do not display the saved mtime (DEPRECATED)sdatessdisplay the saved mtimesdatesortssort by saved mtimes9display dirstate-v2 tree nodes that would not exist in v1s [OPTION]...c Ks|d }|ddurd}|d}|rdd}nd}t|jjj|dd }|j|d |D]@}|\}} } } } | d kr@d } n|rEd } ntdt| } t | } | d@rZd} n d| d@t j @} | d| | | | |fq0|jD]}| td|j||fqvdS)z)show the contents of the current dirstatedatesnodatesNTdatesortcSs|\}}}}}||fSrra)entryfilename_state_mode_sizemtimerararbkeyfuncszdebugstate..keyfuncr)rrYr}sunset sset z%Y-%m-%d %H:%M:%S i slnks%3ois%c %s %10d %s%s scopy: %s -> %s )r rr@_map debug_itersortrgstrftime localtimer strtolocalr;umaskrWrrcopied)rYrZrrrrentriesrrstatemodesizertimestrrkrararb debugstates0      rsdebugdirstateignorepatternshashcKsB|jjr|jjj}d}|j| d}|t|ddSdS)z^show the hash of ignore patterns stored in dirstate if v2, or nothing for dirstate-v2 Nr)r@_use_dirstate_v2rdocket tree_metadatarWbinasciihexlify)rYrZrrhash_len hash_bytesrararbdebugdirstateignorepatternshashs  rdebugdiscoveryoldsuse old-style discoverynonheadss/use old-style discovery with non-heads includedrevs&restrict discovery to this set of revs)rwseeds12323s)specify the random seed use for discovery)rws local-as-revsrws+treat local has having these revisions only)rwsremote-as-revsrws4use local as remote, with only these these revisionss[--rev REV] [OTHER]r~c$ sbt}d}d}ttd|s:td|\}}t |} t dt |n'dgf}t |d|gtfdd } | tjd < }|jd |_|rt |d|gtfd d } | tjd <d idr|ffdd } n |ffdd } tj||dd\} } d}d}|jrtjfdd}ntj}|$td}| || \}}Wdn1swYWdn1swYt|}t|}t}||@}||@}||@|@}d}d|}d|}d|}d|}d|}t |t |t |ks@Jd||}d|} d|}!||@}"||@}#|j!d<t |d<t |d <t |d!<t |d"<t |d#<t |d$<t |t |d%<t |d&<t |t |d'<t |d(<t |d)<t |d*<t |d+<t |d,<t |d-<t | d.<t |!d/<t |"d0<t |#d1<|"|j#dOit$|%d2|%d3|%d4|%d5|%d6|%d7|%d8|%d9|%d:|%d;|%d<|%d=|%d>|%d?|%d@|%dA|%dB|%dC|%dD|%dE|%dF|%dG|%dH|%dI|%dJj&r|%dKdL't(dMdN|D|)dS)Paruns the changeset discovery protocol in isolation The local peer can be "replaced" by a subset of the local repository by using the `--local-as-revs` flag. Int he same way, usual `remote` peer can be "replaced" by a subset of the local repository using the `--local-as-revs` flag. This is useful to efficiently debug pathological discovery situation. The following developer oriented config are relevant for people playing with this command: * devel.discovery.exchange-heads=True If False, the discovery will not start with remote head fetching and local head querying. * devel.discovery.grow-sample=True If False, the sample size used in set discovery will not be increased through the process * devel.discovery.grow-sample.dynamic=True When discovery.grow-sample.dynamic is True, the default, the sample size is adapted to the shape of the undecided set (it is set to the max of: , len(roots(undecided)), len(heads(undecided) * devel.discovery.grow-sample.rate=1.05 the rate at which the sample grow * devel.discovery.randomize=True If andom sampling during discovery are deterministic. It is meant for integration tests. * devel.discovery.sample-size=200 Control the initial size of the discovery sample * devel.discovery.sample-size.initial=100 Control the initial size of the discovery for initial change s local_as_revssremote_as_revsrrscomparing with %s Ns not (::(%s))cSrrar)remote_filtered_revsrarb remote_funcKz#debugdiscovery..remote_funcsdebug-discovery-remote-filtercrrrar)local_filtered_revsrarb local_funcYrz"debugdiscovery..local_funcsdebug-discovery-local-filterrcst|ds t|}tj|dd\}}}t|}dsF dd t dd|Dj j d |}fd d |D}||fS) NryT)forcerMrsunpruned common: %s rcsrfrrrxrrararbrmrjz/debugdiscovery..doit..s heads(::%ln)csh|]}|qSrarar~clnoderarbrrrz/debugdiscovery..doit..)r; safehasattrrlocallegacypeerrr8findcommonincomingsetr rrjrrUrr) pushedrevs remoteheadsremotecommon_inhds)rrrZrYr rbdoitbs    zdebugdiscovery..doitcsHd}|rt|}fdd|D}tj||d\}}}||fS)Ncg|]}|qSrarr~rZrarbrz{z0debugdiscovery..doit..) ancestorsofrM)rrevranger0findcommonheads)rrrnodesrranyr)rrZrYrarbrws   )rrc3s dVd<dS)Noutput) pushbuffer popbufferra)rrYrarbmay_capture_outputsz*debugdiscovery..may_capture_outputzdebug-discoverysall()s::%lns roots(::%ld)s not ::%lds heads(%ld)s roots(%ld)snot (::%ln or %ln::)selapsedsnb-common-headssnb-common-heads-localsnb-common-heads-remotesnb-common-heads-bothsnb-common-rootss nb-head-localsnb-head-local-missingsnb-head-remotesnb-head-remote-unknownsnb-revssnb-revs-commonsnb-revs-missingsnb-missing-headssnb-missing-rootss nb-ini_undsnb-ini_und-headssnb-ini_und-rootssnb-ini_und-commonsnb-ini_und-missings#elapsed time: %(elapsed)f seconds s-round-trips: %(total-roundtrips)9d sheads summary: s, total common heads: %(nb-common-heads)9d s2 also local heads: %(nb-common-heads-local)9d s3 also remote heads: %(nb-common-heads-remote)9d s1 both: %(nb-common-heads-both)9d s* local heads: %(nb-head-local)9d s2 common: %(nb-common-heads-local)9d s2 missing: %(nb-head-local-missing)9d s+ remote heads: %(nb-head-remote)9d s3 common: %(nb-common-heads-remote)9d s3 unknown: %(nb-head-remote-unknown)9d s$local changesets: %(nb-revs)9d s+ common: %(nb-revs-common)9d s, heads: %(nb-common-heads)9d s, roots: %(nb-common-roots)9d s, missing: %(nb-revs-missing)9d s- heads: %(nb-missing-heads)9d s- roots: %(nb-missing-roots)9d s' first undecided set: %(nb-ini_und)9d s- heads: %(nb-ini_und-heads)9d s- roots: %(nb-ini_und-roots)9d s. common: %(nb-ini_und-common)9d s/ missing: %(nb-ini_und-missing)9d scommon heads: %s rcsrfrrr rararbrrjz!debugdiscovery..ra)*r'r unfilteredrandomseedr}rEget_unique_pull_pathrrrr hidepasswordrr frozensetr* filtertable_repofilteredr  addbranchrevsr strict_format contextlibcontextmanagerr;nullcontextmanagertimedcmrheadsrrPelapsedrr strkwargsrverboserjrr)$rYrZ remoteurlrunfi local_revs remote_revsrrrrr remoterevs _checkout localrevsrr#trr heads_common heads_remote heads_localheads_common_localheads_common_remoteheads_common_bothr roots_commonmissing heads_missing roots_missinginitial_undecidedheads_initial_undecidedroots_initial_undecidedcommon_initial_undecidedmissing_initial_undecidedra)rrrrrZrYrbdebugdiscoverys I                                         rNis debugdownloadr spathcKspt|||}|}|rt|dt}z|t}|r%|||t}|sW|r.|dSdS|r7|ww)z4download a resource using Mercurial logic and configrdN)urlmodr _chunksizerrWr )rYrZr:outputrfhdestrrararb debugdownloads        rTdebugextensionsc Kst|}t|}t}|d|}t|tddD]\}}t |}d} t |dr5t |j } n t tddr>tj} |rCg} nt |dd } t |d d} ||js[|jrc|d d |n(|d d ||sp|| vrv|dn| s|tdn | d} |d| ||jo| dtd| pd |jr|tdddg||j|d||jo| dtd|j| dd||jo| dtd| pd q|dS)z(show information about active extensionsrUrrYN__file__oxidizedF testedwithrwbuglinknamerrkrs (untested!) r}s (%s!) ssources location: %s s bundled: %s noyes)bundleds testedwiths tested with: %s sverrsbuglinks bug reporting: %s )r'rrr;rrroperator itemgetterismoduleinternalr fsencoderVr sys sysexecutablerrrr6rWrr condwriter formatlistr) rYrZrextshgverrextnameextmod isinternal extsource exttestedwith extbuglinklasttestedversionrararbdebugextensionss^             rps debugfilesetrs#apply the filespec on this revisions all-filess3test files from all revisions and working directorys show-matchers(print internal representation of matcherps show-stages$print parsed tree at the given stagesNAMEs+[-r REV] [--all-files] [OPTION]... FILESPECcKs6ddlm}|jt|}t||dd}dtjfdt j fdt j fg}dd |D}t }|j r<|d s<|d|d d gkrI||n|d D]} | |vr\ttd | qM||d t |} |D]$\} } | | } | |vr|d s| dkr|d | |t | dqkt } |dr|D]} || }| || |jq|ds|dur|d}| |jjt|t|jddd| |jn | || |j|||}|ds|ddur|j r| dt!"|dt#| D]} || sq|d| qdS)z'parse and apply a fileset specificationr)filesetrNparsedanalyzed optimizedcSh|]\}}|qSrararxrrkrararbrprzdebugfileset.. show_stagerinvalid stage name: %s* %s: rs all_filesT)subreposunknownignoreds show_matcher * matcher: r)$rssymbolsr'rrr-r identityranalyzeoptimizerr6addrrrTrparserW prettyformatrsubstaterXr@walkr/matchallr matchfilesetrRrrD prettyreprr)rYrZexprrrsr8stages stagenames showalwaysrtreerkrr_r"wctxrrararb debugfilesetCsl "         rsdebug-repair-issue6528s to-reports1build a report of affected revisions to this files from-reports+repair revisions listed in this report filesparanoids3check that both detection methods do the same thingcKsrt|dddg|d}|d}|d}|d}tj|jvr,d}tt|tj ||||||ddS)afind affected revisions and repair them. See issue6528 for more details. The `--to-report` and `--from-report` flags allow you to cache and reuse the computation of affected revisions for a given repository across clones. The report format is line-based (with empty lines ignored): ``` ,... ``` There can be multiple broken revisions per filelog, they are separated by a comma with no spaces. The only space is between the revision(s) and the filename. Note that this does *not* mean that this repairs future affected revisions, that needs a separate fix at the exchange level that was introduced in Mercurial 5.9.1. There is a `--paranoid` flag to test that the fast implementation is correct by checking it against the slow implementation. Since this matter is quite urgent and testing every edge-case is probably quite costly, we use this method to test on large repositories as a fuzzing method of sorts. to_report from_reportdry_runparanoids9can only repair revlogv1 repositories, v2 is not affected)rrrrN) rcheck_incompatible_argumentsr r+REVLOGV1_REQUIREMENTrrTrrHrepair_issue6528)rYrZrrrrrrrararbdebug_repair_issue6528s$2       r debugformatc  st|}tddtjDttdfdd}|d|}|r+dd}ntj}| d| d td| d |j rK| d | d tjD]i}| | |}| |}||krld } d} n||jkrvd} d} nd} d} |jd||j|j| d|jdd||| d|j|krd} nd} |j|j dd||| d|j|j dd||jdd| d qS|dS)zdisplay format information about the current repository Use --verbose to get extra information about current config value and Mercurial default.css|]}t|jVqdSr)rPr)rxfvrararbrszdebugformat..sformat-variantcsddt|S)Ns%s:rrgr^maxvariantlengthrarbmakeformatnamesz#debugformat..makeformatnamercSst|dr|S|r dSdS)Ns startswithr\r[)r;r valuerararb formatvalues z debugformat..formatvaluers repos config defaultrs!formatvariant.name.mismatchconfigs!formatvariant.repo.mismatchconfigs"formatvariant.name.mismatchdefaults"formatvariant.repo.mismatchdefaultsformatvariant.name.uptodatesformatvariant.repo.uptodaterZrZsrepos %3ssformatvariant.config.specialsformatvariant.config.defaultsconfigs %6sr~s %7ssformatvariant.defaultN)r'rrpr9allformatvariantrPrisplainrrr6rfromrepo fromconfigdefaultrWrrer) rYrZrrrrr repovalue configvalue namelabel repolabel configlabelrarrb debugformats^               rs debugfsinfos[PATH].cCs|d||dt|pd|dt|rdpd|dt|p*d|dt|r7dp8d|d t|rEdpFdd}z#tjd |d }t |j r\dp]d}Wd n1shwYWn t ywYnw|d |d S)z2show information detected about current filesystems path: %s smounted on: %s s (unknown)s exec: %s r\r[s fstype: %s s symlink: %s s hardlink: %s s .debugfsinfo)prefixdirNscase-sensitive: %s ) rr;getfsmountpoint checkexec getfstype checklink checknlinkr' namedtempfilefscasesensitiverOSError)rYr casesensitiverkrararb debugfsinfo6s, rsdebuggetbundleHsheadsid of head nodesIDCscommonsid of common nodetypebzip2sbundle compression type to usesTYPEsREPO FILE [-H|-C ID]...c Kst|}t|||}|dstdi}|r#dd|D|d<|r.dd|D|d<d|d <|jdi|}|d d  } d dddd} | | } | t j vrZtt dt |||| dS)zretrieves a bundle from a repo Every ID must be a full-length hex node id string. Saves the bundle to the given file. s getbundles.getbundle() not supported by target repositorycSg|]}t|qSrarrhrararbrzjrz"debuggetbundle..rcSrrarrhrararbrzlrr3N bundlecapsdebugrrsHG10UNsHG10BZsHG10GZsHG20)snonersgzipsbundle2s)unknown bundle type specified with --type)r)r'rrrcapablerrT getbundler lowerr bundletypesr writebundle) rYrepopathrrrrrZr[bundle bundletypebtypesrararbdebuggetbundleNs*     rs debugignores[FILE]cOs.|jj}|s|dt|dStj|d|d}tj|dd}|D]n}t |}d} d} |dkrX||rB|} |j |} nt |D]} || rW| } |j | } nqG| r| |krj|td||n |td||| f| \} } }|td | | |fq&|td ||q&dS) adisplay the combined ignore pattern and information about ignored files With no argument display the combined ignore pattern. Given space separated file names, shows if the given file is ignored and if so, show the ignore rule (file and line number) that matched it. rN)patsT)legacyrelativevaluers%s is ignored s1%s is ignored because of containing directory %s s#(ignore rule in %s, line %d: '%s') s%s is not ignored )r@_ignorerWr'bytereprr/match getuipathfnrr;normpath_ignorefileandliner#finddirsr)rYrZrrignoreruipathfnrknfr~ ignoredatar ignorefilelinenorrararb debugignore~sJ      r debugindexc Kst|}t|d||}|jrt}nt}d}|D] }t|||}| d|}| dd |d |f|D]E} || } | | } | |dd| |dd || |d d || |dd || d |d d|| d| dq<|dS)z'dump index data for a storage primitiver  rev linkrev %s %s p2 nodeidr+rs%6d slinkrevs%7d nodes%s rr,rkrrN)r'rrr debugflagrrrPrrrljustrArrWlinkrevr) rYrZrrstoreshortfnidlenryrrXrrArararb debugindexs4      r debugindexdotcKst|}t|d||}|d|D]/}||}||}|d||d|f|d|j krC|d||d|fq|ddS)z(dump an index DAG as a graphviz dot filers digraph G { s %d -> %d rrs} N) r'rrrrrrArWrXnullid)rYrZrrr_ryrpprararb debugindexdots    rsdebugindexstatscCsb|j|jd|jj}t|dsttdt | D] \}}| d||fq!dS)z)show stats related to the changelog indexrsstatss+debugindexstats only works with native codes%s: %d N) rUshortestrr\r;r rrTrrstatsrcrW)rYrZr\rr&rararbdebugindexstatss r debuginstallc" Kst|}d}|d|}||ddtjd}z tttjWnt yA}zt |}|d7}WYd}~nd}~ww| |dd|d}t td r]tjttj}n ttd d rftj}|d td tjprtd|dtdtt|dtddtjdd|dtd|ptdz ddlm}|jWn tyd}Ynwt t!j"}t!j#r|$d|dtd|j%t&|ddddd|vr|'td d|vr|'td!|'td"|durd#nd$t (} |d%td&| )d'd|d(td)d'*| )d'ddd} t tj+t,d r5tjtt} n ttd d r?tj} |d*td+t-j-|d,td-| pUtdt-j-d.v} | }t-j-d/vpe| } | pj|} | rd}z2| rdd0l.m/}m0}m1}m2}t3|t3|t3|t3|f|rdd1lm4}m5}t3|t3|fWnt6y}zt |}|d7}WYd}~nd}~ww| |d2d3|t j7j89}|d4td5|j%t&d6d7|Dd8dd9d|d:td;|j%t&d|j%d?d@|Dd8dd9dd#}t j=rdA}|'tdB||j>t?t j=dCt@A}|dDdE|p=dF| | dFtdG|rt@BdH\}}|rd}zt@j@C|Wnt6yz}z t |}d}WYd}~nd}~ww| |dId3|nd}| |dJtdK|| | dLtdMdN|s|d7}| | dFtdO|D}t E|}tFG|d}|dPtdQ|tFH|}| | o|dRkdStdT| o|dRko|| | o|dRkdUtdV| o||s|dRkr|d7}d}d}z|I}WntJjKy(}z |jL}|d7}WYd}~nd}~ww| |dWtdX|| |dYtdZ|tMMD]\}} t| d[d}!|!durW||!||7}qA| | dFtd\|sl|j>|d]| |d^td_||N|S)`z;test Mercurial installation Returns 0 on success. rrsencodingschecking encoding (%s)... Nrs encodingerrors. %s (check that your locale is properly set) rVrWFs pythonexes checking Python executable (%s) sunknownspythonimplementations$checking Python implementation (%s) s pythonverschecking Python version (%s) s%d.%d.%drKs pythonlibschecking Python lib (%s)... )rustextssnispythonsecuritys&checking Python security support (%s) sprotocolrk,)rfmtsepstls1.2sT TLS 1.2 not supported by Python install; network connections lack modern security sV SNI not supported by Python install; may have connectivity issues with some servers schecking Rust extensions (%s) missings installedshgvers checking Mercurial version (%s) +s hgverextras%checking Mercurial custom build (%s) shgmodulepolicyschecking module policy (%s) s hgmoduless#checking installed modules (%s)... )srust+cs rust+c-allow)csallow)base85bdiffmpatchosutil)rVr@sextensionserrors %s s compenginess-checking registered compression engines (%s) cs|]}|VqdSrr^rlrararbrrjzdebuginstall..s compenginerscompenginesavails,checking available compression engines (%s) css |] }|r|VqdSr) availablerrlrararbrrscompenginesservers>checking available compression engines for wire protocol (%s) cSsg|] }|r|qSra)wireprotosupportrrlrararbrzz debuginstall..s availables"checking "re2" regexp engine (%s) )re2s templatedirsschecking templates (%s)... rws no template directories found smap-cmdline.defaultsdefaulttemplateerrorsdefaulttemplateschecking default template (%s) sdefaulttemplatenotfounds template '%s' not found r~s5 (templates seem to have been installed incorrectly) seditorschecking commit editor... (%s) svis vinotfoundsf No commit editor set and can't find %s in PATH (specify a commit editor in your configuration file) seditornotfoundsV Can't find editor '%s' in PATH (specify a commit editor in your configuration file) susernameschecking username (%s) s usernameerrorsJchecking username... %s (specify a username in your configuration file) debuginstallsno problems detected )problemssproblemss1%d problems detected, please check your install! )Or'rrrrWrcodecsrSsysstr LookupErrorrD forcebytestrrer;r osrdirnamerbrVr rcrdrsysbytesplatformpython_implementation version_inforr__doc__ ImportErrorrr3supportedprotocolshassnirrfrrrrrjmodules__name__r%cextrrrrrrVr@ Exception compengines_enginesr%rAsupportedwireengines SERVERROLE_re2rboolr7 templatedirtry_open_template frommapfile geteditor expandpathrC shellsplitfindexeusernamerrTmessagerr)"rYrrrrJinst pythonlibrsecurityrh hgmodulesrustandcrnopurerrrrrVr@rwirecompenginesrrrfpeditor editorbincmdpathr#rmrmodhandlerrararbrs                                     rs debugknowns REPO ID...cOsbt|}t|||}|dstd|dd|D}|dd dd|DdS) ztest whether node ids are known to a repo Every ID must be a full-length hex node id string. Returns a list of 0s and 1s indicating unknown/known. sknowns*known() not supported by target repositorycSrrarrhrararbrz/rzdebugknown..rrwcSsg|]}|rdp dqS)10rarxrkrararbrz0rN) r'rrrrrrTknownrWrj)rYridsrrZrrararb debugknown$s   "r7sdebuglabelcompletesLABEL...cGst||g|RdS)zEbackwards compatibility with old bash completion scripts (DEPRECATED)N)debugnamecomplete)rYrZr[rararbdebuglabelcomplete3sr9s debuglocksLsforce-free-locksfree the store lock (DANGEROUS)Wsforce-free-wlocks'free the working state lock (DANGEROUS)sset-locks set the store lock until stoppedSs set-wlocks(set the working state lock until stoppedc sF|dr |jd|dr|jd|ds |dr"dSg}zV|drDz ||dWntjyCtt dw|d rcz || dWntjybtt d wt |ru t d Wt |dSWt |nt |wtd}fd d }|||jd|j 7}|||jd|j7}|S)ashow or modify state of locks By default, this command will show which locks are held. This includes the user and process holding the lock, the amount of time the lock has been held, and the machine name where the process is running if it's not local. Locks protect the integrity of Mercurial's data, so should be treated with care. System crashes or other interruptions may cause locks to not be properly released, though Mercurial will usually detect and remove such stale locks automatically. However, detecting stale locks may not always be possible (for instance, on a shared filesystem). Removing locks may also be blocked by filesystem permissions. Setting a lock will prevent other commands from changing the data. The command will wait until an interruption (SIGINT, SIGTERM, ...) occurs. The set locks are removed when the command exits. Returns 0 if no locks are held. force_free_lockslockforce_free_wlockswlockr set_wlockFswlock is already heldset_lockslock is already helds&ready to release the lock (y)? $$ &Yesc sz|d}Wn tjyd}Ynw|r|nczI||}|tj}t|j}| |}d|vrU| d\}} |t krLd|pGd| f}n d|pPd| |f} d|d||fWdSty|} z | jtjkrrWYd} ~ nd} ~ ww d|dd S) NF:suser %s, process %ssNonesuser %s, process %s, host %ss%-6s %s (%ds) rs %-6s free r)rLockHeldreleaselstatstatST_MTIMEr;r#st_uidreadlockrsocket gethostnamerrerrnoENOENT) r<rmethodrstagerlockerhostpidrmnowrYrarbreports>        zdebuglocks..report)r svfsrir<rrrrBrTrrrP promptchoicerCrg)rYrZrlocksheldrUrarSrb debuglocks9s@ -      "rZsdebugmanifestfulltextcachesclearsclear the cachesadds)add the given manifest nodes to the cachesNODErac sfdd}|dr*|}|jdd WddS1s%wY|rs;j}|d}|D]&}z |||} Wntjy\} z tjt | dd d} ~ ww| q; WddS1snwY|}t |s| t d dS| t d t |fd } |D]!} || } t | }| |d 7} | t dt| t|fq|jdj}| t dt| t|fdS)z@show, clear or amend the contents of the manifest fulltext cachecs6jd}z|jWStytd}t|w)NrwsOCurrent revlog implementation doesn't appear to have a manifest fulltext cache ) manifestlog getstorage_fulltextcacheAttributeErrorrrrT)r_rrrarbgetcaches   z,debugmanifestfulltextcache..getcacher^T)clear_persisted_dataNrwsCheck your manifest node idhints cache empty sFcache contains %d manifest entries, in order of most to least recent: rsid: %s, size %s smanifestfulltextcaches%total cache data size %s, on-disk %s )r rr^r[r\rSrrrTbytesrrPrWrpeekrr; bytecount_openerrEst_size)rYrZrrr_cacherrrrBrm totalsizerrrondiskrarrbdebugmanifestfulltextcaches^           rldebugmergestatecOs |jr.t|}|}|}|s|sn|s|dn|||r)|dn|dt|}|ds;d|d<tj |}| d|}| | d}| rd|jd fd |jd ffD]*\} } } | |j| d |jt| d |jrt|j| kr|j|j| dq`|| d} | r;|D]} | | j| d|j| }| j|d d|d tjtjfvr| j|d d| j|dd| j|dd| j|dd| j|dd| j|dd| j|ddn|d tjtjfvr| j|d d| j|dd | d!}t|| D]\}}| |j|d"|j|d#q |q| | d!}tt|D]-\} }| |vrXqMt|D]\}}| |j| d$|j|d"|j|d#q]qM||d%S)&zpprint merge state Use --verbose to print out information about whether v1 or v2 merge state was chosen.sno version 2 merge state s!v1 and v2 states match: using v2 s$v1 and v2 states mismatch: using v1 templates{if(commits, "", "no merge state found ")}{commits % "{name}{if(label, " ({label})")}: {node} "}{files % "file: {path} (state \"{state}\") {if(local_path, " local path: {local_path} (hash {local_key}, flags \"{local_flags}\") ancestor path: {ancestor_path} (node {ancestor_node}) other path: {other_path} (node {other_node}) ")}{if(rename_side, " rename side: {rename_side} renamed path: {renamed_path} ")}{extras % " extra: {key} = {value} "}"}{extras % "extra: {file} ({key} = {value}) "}rmscommitsslocalrrrr^rrZsfiles)r)r) local_keyrN) local_pathrK) ancestor_pathr ) ancestor_noder) other_pathrT) other_node) local_flags) renamed_path) rename_sidesextrasrYr)fileN)r6 mergestatemodr_readrecordsv1_readrecordsv2r _v1v2matchr'rrrrnestedactiverrrr_labelsrPrrMERGE_RECORD_UNRESOLVEDMERGE_RECORD_RESOLVEDMERGE_RECORD_UNRESOLVED_PATHMERGE_RECORD_RESOLVED_PATHrextrasrcr allextras)rYrZr[rms v1records v2recordsr fm_commitsrr label_indexfm_filesrkr fm_extrasrr&rrararbdebugmergestates                        rsdebugnamecompletesNAME...cst}t|jD]\}}|dkr|||q |dd|Dt}|s0dg}|D]|fdd|Dq2|d t ||ddS)z:complete "names" - tags, open branch names, bookmark namesrycss |] \}}}}|s|VqdSrra)rxtagr3tipclosedrararbrl s  z$debugnamecomplete..rwc3s|] }|r|VqdSr)rr r`rarbru srN) rr'rnamesr listnames branchmap iterbranchesrWrjr)rYrZr[rrns completionsrarrbr8b s  r8s debugnodemapsdump-news1write a (new) persistent binary nodemap on stdouts dump-disksdump on-disk data on stdoutschecks-check that the data on disk data are correct.smetadatas-display the on disk meta data for the nodemapc Ks|dr%|}|j}t|jdr|j}nt|j}||dS|drJ|}|j}t |}|durH|\}}||dddSdS|drl|}|j}t |}|durj|\}}t ||j|SdS|dr|}|j}t |}|dur|\}}|d|j |d|j |d t |j|d |j|d |j|jd |j}|d |dSdSdS)z!write and inspect on disk nodemapdump_newnodemap_data_all dump_diskNcheckr suid: %s s tip-rev: %d s tip-node: %s sdata-length: %d sdata-unused: %d Y@sdata-unused: %2.3f%% )r$rUr;r r\rrGpersistent_datarWpersisted_data check_datauidtip_revrtip_node data_length data_unused) rYrZrr8rrnm_datar unused_percrararb debugnodemapz sL     rrflagss markers flagsrecord-parentss+record parent information for the precursorsdisplay markers relevant to REV exclusives0restrict display to markers only relevant to REVindexsdisplay index of the markerdeletes#delete markers specified by indicess[OBSOLETED [REPLACEMENT ...]]c s6t|}fdd|drig}|dD]}z |t|Wqty6tjtd|tddw rBt td t j|}|td|Wd d S1sbwYd S|d ur|d rwtd i}t|d p||d <tfd d|D}  } z|d} zjzK|d} | rt| } nd } |} d }|dr| vrt d| }tdd|D}jj| | | |d|| ||d| Wnty}z t tdt|d }~wwW| n| wW| d S| w|d rBt|d }fdd|D}t t!j"||dd}|j#dddnt!"}|}dd}|d rh|drht!"}t$|fd d}|%d|}t&|D]"\}}||s}qr|'|dr|nd }t(j)|||d!qr|*d S)"zccreate arbitrary obsolete marker With no arguments, displays the list of obsolescence markers.cs>zt|}t|jjkrt|WStytdw)Ns>changeset references must be full hexadecimal node identifiers)rrP nodeconstantsnodelen TypeErrorr InputError)rirrrarb parsenodeid s z"debugobsolete..parsenodeidrsinvalid index value: %rsuse integers for indicesras6cannot delete obsmarkers in the middle of transaction.s deleted %i obsolescence markers Nrs+cannot select revision when creating markersuserc3s|]}|VqdSrra)rxsucc)rrarbr rjz debugobsolete..rsdatesrecord_parentss2cannot used --record-parents on unknown changesetscsrrrrrararbr rjr)rArr rYsbad obsmarker input: %scrrarr~rrarbrz. rz!debugobsolete..r)r exclusivecSs|jSr)_datarrararbrW4 szdebugobsolete..rYcSdS)NTrarrararbrW9 rcs|vSrrar) markersetrarbrW= )r\)+r'rr rr} ValueErrorrrrcurrenttransactionrTrr)deleteobsmarkersobsstorerWr fromlocalr#tuplerrBrr$rAcreater rDrrCrrrr" getmarkersrrr enumeraterrrr)rYrZ precursor successorsrindicesr&rr succsrtrrprecrArrrr markerstoiter isrelevantrryrindra)rrrZrb debugobsolete s                     rs debugp1copiessrevision to debugs[-r REV]cKLt|}tj||ddd}|D] \}}|d||fqdS)z$dump copy information compared to p1rNr %s -> %s )r'rr/r-r p1copiesrcrWrYrZrr8dstsrcrararb debugp1copiesP rs debugp2copiescKr)z$dump copy information compared to p2rNrr)r'rr/r-r p2copiesrcrWrrararbr^ rsdebugpathcompletefsfullscomplete an entire pathsnormalsshow only normal filesr)sshow only added filesr*sshow only removed filess FILESPEC...c sfdd}d}dr|d7}dr|d7}dr!|d 7}|s*d g}tt}}|D]}|||p:d \} } || || q3|||d fd dt|D|d dS)a)complete part or all of a tracked path This command supports shells that offer path name completion. It currently completes only files already known to the dirstate. Completion extends only to the next path segment unless --full is specified, in which case entire paths are used.cs4j}tjtjt|}jtj }|jkr$| |s$ggfStj |r.|d7}|t |d}tj dk}|rD| tj d}t |}d}tt}} | j|j} } t|D]6\} } | |r| j|vr|rv| dtj } |r}| | q_| tj |}|dkr| | d|q_| | q_|| fS)N/fullr)r@rrrrjrrRrootr'osseprisdirrPreplacerrrrfind)r acceptabler@rrootdirfixpathsspeclen fullpathsrdirsadddiraddfilerkrNri)rrZrarbcomplete s8   z#debugpathcomplete..completerwnormalsnmr2rr3rqrsnmarrc3s|] }|VqdSr)pathtor)cwdrZrarbr roz$debugpathcomplete..N)rRrrrWrjr) rYrZspecsrrrrrrrkrra)rrrZrbdebugpathcompletel s&   $rsdebugpathcopiess#hg debugpathcopies REV1 REV2 [FILE]) inferrepoc Os\t||}t||}t|||}tt|||D] \} } |d| | fqdS)z!show copies between two revisionsrN)r/r-rrr pathcopiesrcrW) rYrZr]r^rrctx1ctx2rrrrararbdebugpathcopies s  rs debugpeerc Csddi}||St|i|}z=|du}|}|td||td|r2tdntd|td|rCtdntdW|n|wWddS1s_wYdS) z+establish a connection to a peer repository)sdevelsdebug.peer-requestTNsurl: %s s local: %s r\r[s pushable: %s ) configoverriderrrcanpushrWrr:r )rYr overridesrrrrararb debugpeer s  ""rsdebugpickmergetools check for files in this revision changedeletes!emulate merging change and deletes [PATTERN]...c Osht|}i}|dr|d|d<|dt|d||dtjd}|dur8|dt||dd }|rJ|d t|t ||d }t |||}|d } | |D]>} || } |j sr|jd dntt||| | d| v| \} } Wdn1swY|d| | fqcWddS1swYdS)afexamine which merge tool is chosen for specified file As described in :hg:`help merge-tools`, Mercurial examines configurations below in this order to decide which merge tool is chosen for specified file. 1. ``--tool`` option 2. ``HGMERGE`` environment variable 3. configurations in ``merge-patterns`` section 4. configuration of ``ui.merge`` 5. configurations in ``merge-tools`` section 6. ``hgmerge`` tool (for historical reason only) 7. default tool for fallback (``:merge`` or ``:prompt``) This command writes out examination result in the style below:: FILE = MERGETOOL By default, all files known in the first parent context of the working directory are examined. Use file patterns and/or -I/-X options to limit target files. -r/--rev is also useful to examine files in another context without actual updating to it. With --debug, this command shows warning messages while matching against ``merge-patterns`` and so on, too. It is recommended to use this option with explicit file patterns and/or -I/-X options, because this option increases amount of output per file according to configurations in hgrc. With -v/--verbose, this command shows configurations below at first (only if specified). - ``--tool`` option - ``HGMERGE`` environment variable - configuration of ``ui.merge`` If merge tool is chosen before matching against ``merge-patterns``, this command can't show any helpful information, even with --debug. In such case, information above is useful to know why a merge tool is chosen. stool)uis forcemergeswith --tool %r sdebugmergepatternssHGMERGENswith HGMERGE=%r rsmergeswith ui.merge=%r rrT)rrs%s = %s )r'r notenoi18nrrrenvironr configr/r-rrrsilentr;r1r _picktoolisbinaryrrW)rYrZrrrhgmergeuimerger8r changedeleterfctxtooltoolpathrararbdebugpickmergetool sF 5      "rs debugpushkeysREPO NAMESPACE [KEY OLD NEW]c Ost|i|}z_|rB|\}}}|} | d||||d} Wdn1s+wY|t| d| W|St t | |D]\} } | dt | t | fqLW|dS|w)zaccess the pushkey key/value protocol With two args, list the keys in the given namespace. With five args, set a key to new if it currently is set to old. Reports success or failure. spushkey)s namespaceskeyrsnewNrs%s %s )rrcommandexecutor callcommandresultrr'rr rrlistkeysrWrD escapestr) rYr namespacekeyinfortargetr$oldnewrmr_rr&rararb debugpushkey0 s6     rs debugpvecsA Bc Cst||}t||}t|}t|}||krd}n||kr$d}n ||kr+d}n||Br1d}|td||td||td|j|jf|tdt|j|jt|j |j | ||fdS) N=><|sa: %s sb: %s sdepth(a): %d depth(b): %d s.delta: %d hdist: %d distance: %d relation: %s ) r/r-r&ctxpvecrWr_depthabs_hamming_vecdistance) rYrZr`rcacbrpbrelrararb debugpvecU s0    rs&debugrebuilddirstate|debugrebuildstatesrevision to rebuild tosminimalsEonly rebuild files that are inconsistent with the working copy parentc  st||}|?|jd}|dr6t|}t}||}||} fdd| D} || B}| ||WddS1sLwYdS)arebuild the dirstate as it would look like for the given revision If no revision is specified the first current parent will be used. The dirstate will be set to the files of the given revision. The actual working directory content or existing dirstate information such as adds or removes is not considered. ``minimal`` will only rebuild the dirstate status for files that claim to be tracked but are not in the parent manifest, or that exist in the parent manifest but are not in the dirstate. It will not change adds, removes, or modified files that are in the working copy parent. One use of this command is to make the next :hg:`status` invocation check the actual file content. Nminimalcsh|] }|js|qSra) get_entryr2r4r@rarbr rz'debugrebuilddirstate..) r/r-rr@r rrBr`rebuildr) rYrZrXrr8 changedfiles manifestfiles dirstatefiles manifestonlydsonly dsnotaddedrar!rbdebugrebuilddirstateq s !  "r)sdebugrebuildfncaches only-datas*only look for wrong .d files (much faster)cKs"t|}t|||ddS)zrebuild the fncache files only_dataN)r'rr)rebuildfncacher rRrararbdebugrebuildfncache s r+s debugrenames[-r REV] [FILE]...c Ost|}t||d}t|||}||D]2}||}|| }| |} |rC| t d| |dt |dfq| t d| qdS)zdump rename informationrs%s renamed from %s:%s rrs%s not renamed N)r'rr/r-r rrfilelogrenamedfilenoderrWrr) rYrZrrr8rrrorrararb debugrename s  &r0sdebugrequires|debugrequirementscCs"t|jD] }|d|qdS)z#print the current repo requirementsrN)rr+rW)rYrZr_rararbdebugrequirements sr1 debugrevlogddumpsdump index datacE sJ t|}t|d||}|drt|}|dd}t}t|D]s}| |} | dkr2|} | |} | |} | |\} } | |}||}|t| |8}||z |||}Wn tynd}Ynw|d|| | |||||| || || || |||t|| fq%dS|j}|j}g}d}|tj@r|d|tj@rd }|d |sd g}d}d}d}d}d}d}td d }d}d}d}d}d}d} g}!g}"g}#gd}$gd}%gd}&tdd }'gd}(i})i}*dd}+t|}t|D]?}| |\} } | |},|dkr)|+| ||$| tkr2|d7}||}-|,tkru|!d|"|||#|-|-dkr\|d7}|d7}n|d7}|dd7<|+|-|%|+|-|'dn|!|!|,d|"|,}.||}/|"|.|#|/|.|-|-dkr|d7}|d7}ne||r|+|-|&|d7}||}0||0d7<|+|-|'|0nA|+|-|(|,|dkr|d7}|,| kr|d7}n'|,| kr| d7} n|,| kr|d7}n|,| kr|d7}n |,tkr|d7}t|dr| ||d}1n |j! ||d}1|1r-t"|1dd}2nd}2|2|)vr|:r|5|:}>ddfdd}?dBfdd }@dd}A|%d||%d d!&||d"|@|:}B|?|:}C|%d#|C||%d$|B|A|||%d%|B|A||||%d#|C||%d&|B|A|||%d'|B|A||||%d(|B|A||||%d)|B|A|||t'|D]}0|d*|0|B|A||0|q|%d+|B|A|3||%d,|C|:|%d)|B|A|6|7|:t'|D]}0|d*|0|B|A|8|0|:q|%d+|B|A|9|:d-d.}D|d"|%d/|C|t'|)D]}2||D|2||B|A|)|2|q|%d0|C|:t'|)D]}2||D|2||B|A|*|2|:q|d"|?t$|;|<|=|>}B|%d1|B|;|%d2|B|<|%d3|B|=|%d4|B|>|dkrx|d"|%d5t(|$|%d6t(|%|%d7t(|&t'|'D]}0|0dkrq|%d8|0ft(|'|0q|%d9t(|(|3dkr!|d"|@|3}B|@|3d:}C|%d;|B|A||3|dkr|%d<|C|A|||%d=|C|A| ||%d>|C|A|4||r#|%d?|B|A||3|%d@|B|A||3|%dA|B|A||3dSdSdS)Cz'show data and statistics about a revlogr2r4se# rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen rr}s:%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d %11d %5d %8d FsinlineTs generaldeltas(none)cSrNrrararararbrW$ rzdebugrevlog..NrrcSsgdS)Nr6rararararbrW; rcSsH|ddus ||dkr||d<||dkr||d<|d|7<dS)NrrrNra)rrrararbaddsize@ s  zdebugrevlog..addsizers_getsegmentforrevsemptyNrNs%%%dd s%%%dd %s(%%5.2f%%%%) cstt|SrrPstr)rp) basedfmtstrrarbdfmtstr szdebugrevlog..dfmtstrcstt|d|fS)Nrr9)rppadding) basepcfmtstrrarbpcfmtstr szdebugrevlog..pcfmtstrcSs |r |dt||fS|dfS)Ndr)r)rr|rararbpcfmt szdebugrevlog..pcfmts format : %d s flags : %s rrsrevisions : s merges : s normal : s empty : s text : s delta : s snapshot : s lvl-%-3d : s deltas : srevision size : cSs<|dkrd|S|ttjvrdt||fSdt|S)Nr8s %s : s 0x%s (%s) : s 0x%s : )r'rstring ascii_lettersr) chunktyperararb fmtchunktype s  z!debugrevlog..fmtchunktypeschunks : schunks size : savg chain length : smax chain length : smax chain reach : scompression ratio : s4uncompressed data size (min/max/avg) : %d / %d / %d s4full revision size (min/max/avg) : %d / %d / %d s4inter-snapshot size (min/max/avg) : %d / %d / %d s5 level-%-3d (min/max/avg) : %d / %d / %d s4delta size (min/max/avg) : %d / %d / %d r sdeltas against prev : s where prev = p1 : s where prev = p2 : s other : sdeltas against p1 : sdeltas against p2 : sdeltas against other : r))r'rrrr rPrWrr deltaparentrrrrawsizerrZeroDivisionErrorr_format_version _format_flagsr,FLAG_INLINE_DATArFLAG_GENERALDELTAr defaultdictrr issnapshot snapshotdepthr;r _getsegmentforrevs_revlogrdsumrprrjrr)ErYrZrrr_numrevstsr3rXdbasecbaseclenrrrsrAformatr&rgdelta nummergesnumempty numemptytext numemptydeltanumfullnumsemi numsnapdepthnumprevnump1nump2numother nump1prev nump2prev chainlengthsr chainspansdatasizefullsizesemisize snapsizedepth deltasizechunktypecountschunktypesizesr7rrbaseaddrrevaddrdepthsegmentrD numdeltasnumoprev totalrawsize fulltotal semitotal snaptotal deltatotalrj avgchainlen maxchainlen maxchainspan compratior<r?rArfmt2rEra)r;r>rb debugrevlog sF                                                              rdebugrevlogindexformats revlog formatsFORMATs[-f FORMAT] -c|-m|FILEc Ksdt|}t|d||}|dd}|dvr ttd||jr&t }nt }d}|D] }t || |}|dkr_|j rO|dd|d |fn,|d d|d |fn|d kr{|j rq|d d|n |d d||D]}| |} |dkrz|| } Wnty|j|jg} Ynw|j r|d||||||||| || d|| d fq}|d||||| || d|| d fq}|d kr/||} |j r|d|||||||||||| d| d || f q}|d|||||||| d| d || fq}dS)z#dump the contents of a revlog indexrrr)rrsunknown format %drs* rev offset length linkrev %s %s p2 rr+rrs? rev flag offset length size link p1 p2 %s s- rev flag size link p1 p2 %s s% 6d % 9d % 7d % 7d %s %s %s s% 6d % 7d %s %s %s s+% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d %s s!% 6d %04x % 8d % 6d % 6d % 6d %s N)r'rrrr rrTrrrrrPrr6rrrjustrArrrWrrrrrrH) rYrZrrr_rZrrryrrprrararbdebugrevlogindex4 s          rs debugrevspecoptimizes/print parsed tree after optimizing (DEPRECATED)s show-revss(print list of result revisions (default)sshow-sets+print internal representation of result sets no-optimizeds"evaluate tree without optimizationsverify-optimizedsverify optimized resultsREVSPECc st|}ddddfdfddfdtjfdtjfd tjfg}|d r/|d d }|d r>|d r>tt ddd|D}t }t }j rg|dsg| d| ddg|drg| d |drv|drvtt d|ddgkr| |n|dD]}||vrtt d|q| |di} d } tj|t|d} |D]2\}} | | | |<} ||vs||vr| | kr|ds|dkrՈd|t| d| } q|d rt| d|} t| d |}|ds|dd urj rdt| ddt|dt| } t|}| |kr+dSjdddjd d!dtd | |}|D]N\}}}}}|d"vrc| ||D] }jd#|d$dqV|d%vr{|||D] }jd&|d'dqn|d(kr| ||D] }d)|qqDd*St| }||}|ds|dd urj rd+t|d|d,sd S|D] }d-|qd S).aparse and apply a revision specification Use -p/--show-stage option to print the parsed tree at the given stages. Use -p all to print tree at every stage. Use --no-show-revs option with -s or -p to print only the set representation or the parsed tree respectively. Use --verify-optimized to compare the optimized result with the unoptimized one. Returns 1 if the optimized result differs. s revsetaliasrtcS|SrrarrararbrW rzdebugrevspec..sexpandedcst|jSr)r. expandaliasesrDraliasesrYrarbrW ss concatenatedrurvs no_optimizedNr}sverify_optimizeds1cannot use --verify-optimized with --no-optimizedcSrwrararxrararbr rzdebugrevspec..ryrs'cannot use --optimize with --show-stagerrzrSr{rsshow_sets* analyzed set: s* optimized set: rs --- analyzed s diff.file_arZs+++ optimized s diff.file_b)deleters-%d s diff.deleted)insertrs+%d s diff.insertedequals %d rs* set: s show_revss%d )r'rrbr. foldconcatrrrrTrrr6rrrr-lookupfnrWr makematcherrrDrrdifflibSequenceMatcher get_opcodes)rYrZrrrrr showchangedr treebystage printedtreerrkarevsbrevssmraloahiblobhir"funcrrarrb debugrevspec s -                    r debugservesshstdios*run an SSH server bound to process handleslogiofds$file descriptor to log server I/O to logiofilesfile to log server I/O toc Kst|}|dsttdd}|dr!|dr!ttd|drWz tt|ddd}Wn0tyV}z|j t j krAtt|dd d}WYd}~nd}~ww|drct |dd d}t j |||d }|dS) zrun a server with advanced settings This command is similar to :hg:`serve`. It exists partially as a workaround to the fact that ``hg serve --stdio`` must have specific arguments for security reasons. rs&only --sshstdio is currently supportedNrrs)cannot use both --logiofd and --logiofileabrwbsab)logfh)r'rrrTrrfdopenr}rrKESPIPEr r> sshserver serve_forever)rYrZrrrmrirararb debugserve,s&  " rsdebugsetparentss REV1 [REV2]cCs\t||}t||d}||||WddS1s'wYdS)amanually set the parents of the current working directory (DANGEROUS) This command is not what you are looking for and should not be used. Using this command will most certainly results in slight corruption of the file level histories withing your repository. DO NOT USE THIS COMMAND. The command update the p1 and p2 field in the dirstate, and not touching anything else. This useful for writing repository conversion tools, but should be used with extreme care. For example, neither the working directory nor the dirstate is updated, so file status may be incorrect after running this command. Only used if you are one of the few people that deeply unstand both conversion tools and file level histories. If you are reading this help, you are not one of this people (most of them sailed west from Mithlond anyway. So one last time DO NOT USE THIS COMMAND. Returns 0 on success. snullN)r/r-rr setparents)rYrZr]r^node1node2rararbdebugsetparents^s  "rs debugsidedatac Ks&t|}|ds|ds|dr&|dur tdtdd|}}n |dur2tdtdt|d||}t|d|}z | | |}Wnt yZt td|w|rt |}||d t||D]\}}|d |t|f|jr|d t|qrdSdS) zcdump the side data for a cl/manifest/file revision Use --verbose to dump the sidedata content.rrrNrrrRrs%d sidedata entries s entry-%04o size %d r)r'rr rrrrrr rIrSrrTrrcrrrPr6rDrN) rYrZrrXrr_rIr$rrararb debugsidedata{s2      rdebugssls[SOURCE]c Kstjs ttd|s|sttdd}td|||\}}t|}ddd}|j|vrNz|j t |j p;||jf}Wnt yMttdwttd d d l m}tjttjtjd d } zU| || d} |td|j |j| dd} | s|td|| s|tdn|tdn|tdW| d SW| d SW| d S| w)atest a secure connection to a server This builds the certificate chain for the server on Windows, installing the missing intermediates and trusted root via Windows Update if necessary. It does nothing on other platforms. If SOURCE is omitted, the 'default' path will be used. If a URL is given, that server is used. See :hg:`help urls` for more information. If the update succeeds, retry the original operation. Otherwise, the cause of the SSL error is likely another issue. s6certificate chain building is only possible on Windowss>there is no Mercurial repository here, and no server specifiedr~ri)shttpsssshsmalformed port number in URLs,only https and ssh connections are supportedr)win32N) ssl_version cert_reqsca_certsTs&checking the certificate chain for %s F)builds-certificate chain is incomplete, updating... sfailed. sdone. s$full certificate chain is available )r' iswindowsrrTrrEr'r:schemerQr}portrrrssl wrap_socketrI PROTOCOL_TLS CERT_NONEconnect getpeercertrcheckcertificatechainr ) rYrZsourcerrr: defaultportaddrrricertrrararbdebugssls^          rdebugbackupbundle)rwrecoverrws7brings the specified changeset back into the repositorys%hg debugbackupbundle [--recover HASH]c stttjjtjdd}|jddddt dd<d d <t fd d } d }|rNt|rM|td|d Sn|r\td}|j|ddn |tdd S|D]m}tj|t} tjd||  dd\} } z t| Wn)tjy} ztd| }tdt| j} |j|| dWYd } ~ qgd } ~ wwt|  d\} }| r͇fdd| D} |,zt !|| dd \}}WntjyYWd qgwWd n 1swYz|sW|qg|r"l#dV}t|rk|td|t$|| }t%&||| }t'|t(j)rNt(j*||dd| dn |+dd|  Wd Wd W|d SWd n 1svwYWd n 1swYnAt,t-.d t-/tj0| }|d!|1d"|j2r|d#d1d$| fnd%d&<t 3|d'}||||4W|qg|wd S)(alists the changesets available in backup bundles Without any arguments, this command prints a list of the changesets in each backup bundle. --recover takes a changeset hash and unbundles the first bundle that contains that hash, which puts that changeset back in your repository. --verbose will print the entire commit message and the bundle path for that backup. s strip-backups/*.hgcSs tj|Sr)rrgetmtimerrararbrWs z#debugbackupbundle..T)r$reverserwsbundleNsforcecsdr |d}|D]1}dur|krdSfdd|j|D}dr3t|dkr3q |d7}|||q dS)Ns newest_firstrcsg|] }|jkrdqS)T)rrrrarbrz sz6debugbackupbundle..display..s no_mergesrNr)r rrUrArPshow)rchlist displayercountrrA)limitrrZrarbdisplays   z"debugbackupbundle..displayrs%s already exists in the repo sgRecover changesets using: hg debugbackupbundle --recover Available backup changesets:sstatus.removedrZsno backup changesets found rr)default_branchess" warning: unable to open bundle %ss (missing parent rev %s) rarcsg|]}|qSrar)rxrX)rrarbrz9sz%debugbackupbundle..sunbundlesUnbundling %s sbundle:)rr:z%a %H:%M, %Y-%m-%ds %s 2r s8{label('status.modified', node|short)} {desc|firstline} rnF)5rfilterrrisfileglobr<rjrr'rrgetlimitr r/ isrevsymbolrDrrrelpathrrRrEr'rrrrrrr-rr getremotechangesrrrmrrnrr r applybundlerorrgrrrrr6changesetdisplayerr )rYrZrrbackupsr recovernoderbackuprrexrbrcheckoutr cleanupfnrrkrq backupdaterra)rrrrZrbdebugbackupbundles         &  $ rsdebugsubsrevision to checks[-r REV] [REV]cCs\t||d}t|jD]\}}|d||d|d|d|dqdS)Nspath %s s source %s rs revision %s r)r/r-rrrcr)rYrZrXr8rr&rararbdebugsubns rs debugshellcCs"ddl}||d}|j|ddS)zrun an interactive Python interpreter The local namespace is provided with a reference to the ui and the repo instance (if available). rN)rYrZ)r)codeinteract)rYrZrimported_objectsrararb debugshell{s rsdebugsuccessorssetssclosests#return closest successors sets onlys[REV]c Osi}t}t}t||D]I}||}|d||tj|||d|dD],} | rO|d||| d| ddD]} |d||| q@|d q(q dS) a}show set of successors for revision A successors set of changeset A is a consistent group of revisions that succeed A. It contains non-obsolete changesets only unless closests successors set is set. In most cases a changeset A has a single successors set containing a single successor (changeset A replaced by A'). A changeset that is made obsolete with no successors are called "pruned". Such changesets have no successors sets at all. A changeset that has been "split" will have a successors set containing more than one successor. A changeset that has been rewritten in multiple different ways is called "divergent". Such changesets have multiple successor sets (each of which may also be split, i.e. have multiple successors). Results are displayed as follows:: Here rev2 has two possible (i.e. divergent) successors sets. The first holds one element, whereas the second holds three (i.e. the changeset has been split). rclosest)rris rrNrr)rdrrrrWr"successorssetsr) rYrZrrrictx2strnode2strrXr8succssetrrararbdebugsuccessorssetss$&    rsdebugtagscachecCst|}|d}|D]4}||}|j|dd}|r-t|}||s,|d7}n |dur4d}nd}|d|t||fqdS) z/display the contents of .hg/cache/hgtagsfnodes1s.hgtagsF)computemissings (unknown node)Nrsinvalids %d %s %s ) tagsmodhgtagsfnodescacher$ryrgetfnoderhasnoderW)rYrZriflogr_rtagsnodetagsnodedisplayrararbdebugtagscaches   rs debugtemplatesapply template on changesetsDsdefinesdefine template keywords KEY=VALUEs&[-r REV]... [-D KEY=VALUE]... TEMPLATEc Ksd}|dr|durttdt||d}i}|dD]-}zdd|ddD\}}|r5|d kr7t|||<WqtyLttd |w|jrw| d } t |} | t | d t | | } | | krw|d t | d |durt||} tj||| d} |jr| \}}|ddt||ddt||| |dSt|||}|jr|j\}}|ddt||ddt||D]}|j||fit|q|dS)zparse and apply a template If -r/--rev is given, the template is processed as a log template and applied to the given changesets. Otherwise, it is processed as a generic template. Use --verbose to print the parsed tree. NrXrOdefinecsrrrrlrararbrrjz debugtemplate..rrrs malformed keyword definition: %ss templatealiasrs * expanded: ) resourcess* keywords: %s rs* functions: %s )r RepoErrorrrrrrrTr6rbr7rrrrrrtemplateresources maketemplatersymbolsuseddefaultrrjrrW renderdefaultr>rr'r5r )rYrZtmplrrpropsrrr&rrnewtreetresr>kwdsfuncsrr_rararb debugtemplatesT           r sdebuguigetpasssprompts prompt textsTEXTs [-p TEXT]cCs(||}|dur d}|d|dS)zshow prompt to type passwordNs response: %s )getpassrrYpromptr_rararbdebuguigetpasss rs debuguipromptcCs||}|d|dS)zshow plain promptr N)rrrrararb debuguiprompt)s rsdebugupdatecachesc Ost|,||jtjdWdn1swYWddSWddS1s3wYdS)z'warm all known caches in the repository)cachesN)rr updatecachesr? CACHES_ALL)rYrZrrrararbdebugupdatecaches7sPrsdebugupgradereposextra optimization to performsrunsperforms an upgradesbackups&keep the old repository content aroundrs select the changelog for upgradersselect the manifest for upgradesfilelogssselect all filelogs for upgradecKs tj||f|t||d|S)a0upgrade a repository to use different features If no arguments are specified, the repository is evaluated for upgrade and a list of problems and potential optimizations is printed. With ``--run``, a repository upgrade is performed. Behavior of the upgrade can be influenced via additional arguments. More details will be provided by the command output when run without ``--run``. During the upgrade, the repository will be locked and no writes will be allowed. At the end of the upgrade, the repository may not be readable while new repository data is swapped in. This window will be as long as it takes to rename some directories inside the ``.hg`` directory. On most machines, this should complete almost instantaneously and the chances of a consumer being unable to access the repository should be low. By default, all revlogs will be upgraded. You can restrict this using flags such as `--manifest`: * `--manifest`: only optimize the manifest * `--no-manifest`: optimize all revlog but the manifest * `--changelog`: optimize the changelog only * `--no-changelog --no-manifest`: optimize filelogs only * `--filelogs`: optimize the filelogs only * `--no-changelog --no-manifest --no-filelogs`: skip all revlog optimizations )runrr)r9 upgraderepor)rYrZrrrrrararbdebugupgraderepo>s. rs debugwalks[OPTION]... [FILE]...c st|}td||}|jr|dt|dtd |}|s(dSdd}| ddr;tj dkr;d d}d t d d |Dt fd d |Df}|D]}||| |||rddpedf} |d| qSdS)z&show how files match on given patternsNrrcSrrrarrararbrW}rzdebugwalk..rsslashrcSs t|Sr)r;rrrararbrW sf %%-%ds %%-%ds %%scSrrargrxrrararbrzrzdebugwalk..csg|] }t|qSra)rPrrrrarbrzrXsexactrwr)r'rr/rr6rrDrrr configboolrrprexactrWrstrip) rYrZrrrrcrkrrrrarrb debugwalkqs,  rsdebugwhyunstablec Csjt|t||D](}d}|dr!ddd|dDd}|d|d||d|d fq d S) z$explain instabilities of a changesetrwsdivergentnodesrcss$|] }d||fVqdS)s%s (%s)N)rphasestr)rxr8rararbrs  z#debugwhyunstable..s %s: %s%s %s s instabilitysreasonrN)r" whyunstabler/r-r rjrW)rYrZrXrdnodesrararbdebugwhyunstables  r"s debugwireargs))rwthreerwr#)rwfourrwr$)rwfiverwr%sREPO [OPTIONS]... [ONE [TWO]]c Ost|}t|||}zRtjD]}||d=qi}t|D] \}}|r)|||<qt|}|j|i|} |j|i|} | d| | | krX| d| W| dSW| dS| w)Nrr) r'rrrr remoteoptsrr5 debugwireargsrWrDr ) rYrvalsrrZoptr[rr&res1res2rararbr's&     r'ccsd}g}d}|D]M}|}|sq |drq |ds+|r$||fV|}g}d}q |s4ttdt|t|}||krO|rO|d|7<q |||}q |r`||fVdSdS)Nr#rsindented line outside of blockr})rrrrTrrPlstripr)rR activeaction blocklines lastindentrrrararb_parsewirelangblockss6     r1sdebugwireprotolocalsshs!start an SSH server for this repopeers(construct a specific version of the peer noreadstderrs%do not read from stderr of the remotesnologhandshakes,do not log I/O related to the peer handshakec* s^ t|}|dr|sttd|dr'|ddvr'tjtdtdd|r4|dr4ttd|r?|td tt|j }d }d }d }d }d } |drt d |j d d g} t jtt j| t jt jt jdd}|j}|j}|j}|js|ddkrtj||jddd}tj||jddd}tj||jddd}d} |d } |ddkr|tdtj|| ||||d | d} n|ddkr|tdd } n|tdtj|| ||||| d} n~|r^t|}|jdkrttd|\} }dd i}|jr||d!dd"d#d$|j rd|d%d&<|ddkr*d"|d'<t!j"||fi|} |ddkrE|tdd } n |drUttd(|dt#j||| d)} nttd*d }|D]&\}}|d+vr|s}ttd,d-$d.d/|D}t%&|}|||d0kr|'qi|d1kr|sttd2|'qi|(d3r| sttd4|)d5d6d6}i} |D]6}|*)d5d6}t+|d6kr|d}d-}n|\}}|(d7rt%,|d8d }nt%&|}|| |<q|d ur|-|| fqi|.td9|d:| vrdt/| d:d;2}| d:=| j0||fit1| \}}|.td<t%2||.td=t%2|Wd n 1s]wYqi| 3}|4|| 5}Wd n 1s|wY|.td>t%j6|dd?d@qi|dAkr|d urttdBg}qi|dCkr|.tdDt+|| d usJt7| 8|D]\}}|.tdE|t%2|fqd }qi|(dFr| sttdG|)d5d?} t+| dHkrttdI| d6d \}!i}"d }#g}$|D]k}|*}t9:dJ|}%|%r6t;|%?|t+dMd }&|$-|&qttdN|||!} |$rd-$dOd/|$D}#t!j@At;| |#|"}'fdPdQ|'_Bz | /|'}|=}#WntjCjDy}ztE|dRdSdQWYd }~qid }~ww|jFGdT}(|(dUkr|tdVt%j6tHI|#dd?d@qi|dWkr| d usJ| Jqi|dXkr|r|sttdY|J|=|=qi|dZkr1|s+ttd[|Kqi|d\krF|s@ttd]|Kqi|(d^rgtL|)d5d6d6})|s`ttd_|=|)qi|(d`rtL|)d5d6d6})|sttda|=|)qittdb||d urttdc| r| J|r|Md Sd S)dasend wire protocol commands to a server This command can be used to issue wire protocol commands to remote peers and to debug the raw data being exchanged. ``--localssh`` will start an SSH server against the current repository and connect to that. By default, the connection will perform a handshake and establish an appropriate peer instance. ``--peer`` can be used to bypass the handshake protocol and construct a peer instance using the specified class type. Valid values are ``raw``, ``ssh1``. ``raw`` instances only allow sending raw data payloads and don't support higher-level command actions. ``--noreadstderr`` can be used to disable automatic reading from stderr of the peer (for SSH connections only). Disabling automatic reading of stderr is useful for making output more deterministic. Commands are issued via a mini language which is specified via stdin. The language consists of individual actions to perform. An action is defined by a block. A block is defined as a line with no leading space followed by 0 or more lines with leading space. Blocks are effectively a high-level command with additional metadata. Lines beginning with ``#`` are ignored. The following sections denote available actions. raw --- Send raw data to the server. The block payload contains the raw data to send as one atomic send operation. The data may not actually be delivered in a single system call: it depends on the abilities of the transport being used. Each line in the block is de-indented and concatenated. Then, that value is evaluated as a Python b'' literal. This allows the use of backslash escaping, etc. raw+ ---- Behaves like ``raw`` except flushes output afterwards. command ----------- Send a request to run a named command, whose name follows the ``command`` string. Arguments to the command are defined as lines in this block. The format of each line is `` ``. e.g.:: command listkeys namespace bookmarks If the value begins with ``eval:``, it will be interpreted as a Python literal expression. Otherwise values are interpreted as Python b'' literals. This allows sending complex types and encoding special byte sequences via backslash escaping. The following arguments have special meaning: ``PUSHFILE`` When defined, the *push* mechanism of the peer will be used instead of the static request-response mechanism and the content of the file specified in the value of this argument will be sent as the command payload. This can be used to submit a local bundle file to the remote. batchbegin ---------- Instruct the peer to begin a batched send. All ``command`` blocks are queued for execution until the next ``batchsubmit`` block. batchsubmit ----------- Submit previously queued ``command`` blocks as a batch request. This action MUST be paired with a ``batchbegin`` action. httprequest --------------------------- (HTTP peer only) Send an HTTP request to the peer. The HTTP request line follows the ``httprequest`` action. e.g. ``GET /foo``. Arguments of the form ``: `` are interpreted as HTTP request headers to add to the request. e.g. ``Accept: foo``. The following arguments are special: ``BODYFILE`` The content of the file defined as the value to this argument will be transferred verbatim as the HTTP request body. ``frame `` Send a unified protocol frame as part of the request body. All frames will be collected and sent as the body to the HTTP request. close ----- Close the connection to the server. flush ----- Flush data written to the server. readavailable ------------- Close the write end of the connection and read all available data from the server. If the connection to the server encompasses multiple pipes, we poll both pipes and read available data. readline -------- Read a line of output from the server. If there are multiple output pipes, reads only the main pipe. ereadline --------- Like ``readline``, but read from the stderr pipe, if available. read -------- ``read()`` N bytes from the server's main output pipe. eread --------- ``read()`` N bytes from the server's stderr pipe, if available. Specifying Unified Frame-Based Protocol Frames ---------------------------------------------- It is possible to emit a *Unified Frame-Based Protocol* by using special syntax. A frame is composed as a type, flags, and payload. These can be parsed from a string of the form: ``request-id`` and ``stream-id`` are integers defining the request and stream identifiers. ``type`` can be an integer value for the frame type or the string name of the type. The strings are defined in ``wireprotoframing.py``. e.g. ``command-name``. ``stream-flags`` and ``flags`` are a ``|`` delimited list of flag components. Each component (and there can be just one) can be an integer or a flag name for stream flags or frame flags, respectively. Values are resolved to integers and then bitwise OR'd together. ``payload`` represents the raw frame payload. If it begins with ``cbor:``, the following string is evaluated as Python code and the resulting object is fed into a CBOR encoder. Otherwise it is interpreted as a Python byte string literal. r2s --localssh requires a repositoryr3)rawssh1sinvalid value for --peers!valid values are "raw" and "ssh1"ras/cannot specify --localssh with an explicit paths (waiting for commands on stdin) Ns-Rrs --sshstdior)stdinstdoutstderrbufsizer5iT)logdatarursssh://localserverr4r6s.creating ssh peer for wire protocol version 1 )autoreadstderrsusing raw connection to peer s)creating ssh peer from handshake results shttps*only http:// paths are currently supported useragentsMercurial debugwireprotorzF)r< logdataapis) loggingfh loggingname loggingoptsrBr? sendaccepts'--peer %s not supported with HTTP peers)openers$unsupported connection configuration)r5raw+s!cannot call raw/raw+ on this peerrwcsrr)r-rrararbrOrjz!debugwireproto..rEsflushscannot call flush on this peerscommands6cannot send commands unless peer instance is availablerrseval:rssending %s command sPUSHFILErbs result: %s sremote output: %s r rN)bprefixrs batchbeginsnested batchbegin not alloweds batchsubmits#sending batch with %d sub-commands sresponse #%d: %s s httprequest s+cannot use httprequest without an HTTP peerrKsDinvalid httprequest: expected format is "httprequest s^([a-zA-Z0-9_-]+): (.*)$s BODYFILE srbsframe s#unknown argument to httprequest: %scsrfr)rdr4rararbrrjcs tSr)r'rrarMrarbrWrz debugwireproto..rcSsdSrrararararbrWrz Content-Typezapplication/mercurial-cbors cbor> %s scloses readavailables(readavailable not available on this peersreadlines#readline not available on this peers ereadlines$ereadline not available on this peersread sread not available on this peerseread s eread not available on this peersunknown action: %ssunclosed "batchbegin" request)Nr'rrrTr interactiverWrr1rrChgcmdr subprocessPopenrapply tonativestrPIPEr7r8r9r6r;makeloggingfileobjectr2 sshv1peermakepeerrEr:rauthinforrrOrDrrjrD unescapestrflushrrr-rPevalpythonliteralrrr _callpushr5r rrrrNr _submitbatchrerstrurlgrouprr=makeframefromhumanstringurlreqrequest get_methodurlerrurlerrorr headersr r@ decodeallr readliner}kill)*rYrZrrblocksprocr7r8r9rDr[r:r=rurS openerargsbatchedcommandsr;linesrcommandrfieldsr$rrRresrQrmrychunkr^httppathrbbodyframesrframereqctrrarHrbdebugwireprotos( L                                                        rv)NFFFFr5rFr)NN)r~)r)ra)rw)FNT) __future__rrrrr/rrKrr_rr r%rYrIrrErBrKrcrgi18nrrrrrrr'r r rr r r rrrrrrrrrrrrrrrrlockmodrrrzr r!r"r#r$r%r&r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6rr7r8r9r:rOr;r<rQr=r> interfacesr?utilsr@rArBrCrDrE revlogutilsrFrrGrHrIrCtablerrl_tablercrlrrrrrrrrrr'r?rLrSrQrPrvrdebugrevlogoptsrr formatteroptsrrrr&rNrPrTrpr dryrunoptsrrrrrrrrrr7r9rZrl templateoptsrr8r commitopts2rrrwalkoptsrr mergetooloptsrrrr)r+r0r1rrrrrrrlogoptsrrrrrr rrrrrr"r'r1rvrarararbs   6        # )     '      <  1 $   c > A 0 G  1 $  -   ] = l '   <  K$ !  `l!d $H    3 8 " *