o ]Lb.@sddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z mZmZmZddlmZddlmZddlmZmZmZmZmZmZmZmZm Z mZm!Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(dd l)m*Z*m+Z+m,Z,ej-r|dd lm.Z/ndd lm0Z/e 1d Z2e 3d Z4e/j5Z5ej6dddGddde7Z8ddZ9dddZ:ddZ;ddZdd Z?Gd!d"d"e7Z@dd#d$ZAdd%d&ZBd'd(ZCd)d*ZDd+d,ZEd-d.ZFd/d0ZGd1d2ZHdd3d4ZId5d6ZJd7d8ZKd9d:ZLddd?ZNd@dAZOddBdCZPddFdGZQdHdIZRdJdKZSddLdMZTdNdOZUdPdQZVdRdSZW ddVdWZX ddXdYZdZd[ZYdd\d]ZZd^d_Z[d`daZ\dbdcZ]Gdddedee7Z^     ddfdgZ_ddhdiZ`ddkdlZadmdnZbdodpZcdqdrZdddsdtZeddudvZfddwdxZgddydzZhd{d|Zid}d~ZjdddZkddZlGddde7ZmGddde7ZnGddde7ZoddZpGddde7ZqddZrddZsGddde7ZtgdZuddgZvddZwe'xZydZzdddZ{ddZ|dddZ}ddZ~ddZddZddZddZddZdS))absolute_importN_)binhexnullrevshortwdirrev)getattr)attr)copiesencodingerrormatchobsoleteobsutilpathutilphasespolicypycompat requirements revsetlangsimilarsmartseturlutilvfs)hashutilprocutil stringutil) scmwindows)scmposixparsersrevlogTF)slotsreprc@seZdZdZejeedZejeedZ ejeedZ ejeedZ ejeedZ ejeedZ ejeedZddZddZdS)statuszStruct with a list of files per status. The 'deleted', 'unknown' and 'ignored' properties are only relevant to the working copy. )defaultccs>|jV|jV|jV|jV|jV|jV|jVdSN)modifiedaddedremoveddeletedunknownignoredcleanselfr33/usr/lib/python3/dist-packages/mercurial/scmutil.py__iter__Qs zstatus.__iter__cCsdtdd|DS)NzXcss |] }tt|VqdSr))rsysstrr pprint).0vr3r3r4 ^sz"status.__repr__..)tupler1r3r3r4__repr__Zszstatus.__repr__N)__name__ __module__ __qualname____doc__r ibFactorylistr*r+r,r-r.r/r0r5r<r3r3r3r4r'As r'ccst|j|}|t|j|t}|jD]}||jvr'||=||qtt|D] \}}|| |fVq/|D] }|| ||fVq>dS)zfind subrepos in ctx1 or ctx2N) dictfromkeyssubstateupdatesetaddsortedr iteritemssubnullsub)ctx1ctx2subpathsmissingsubpathctxr3r3r4 itersubreposas   rTcCsjg}|r|D]}||}|tjkr|s||q|r,|tdt|dS|tddS)zjReport no changes for push/pull, excluded is None or a list of nodes excluded from the push/pull. s0no changes found (ignored %d secret changesets) sno changes found N)phasersecretextinctappendr'rlen)uirepoexcluded secretlistnrSr3r3r4nochangesfound{s r_c Csd}d}zz|WWS|tjy\}z=d}|jtjkr.tdt|j}ntd|j}|td|j pBt |j |f|jsQ|tdWYd}~ncd}~wtj y}zd}|td|j pst |j t|jfWYd}~n8d}~wtjy}z%t|tjrd }|td ||jr|td |jWYd}~nd}~wtjy}zT|td |jd |jd}t|tdrt|}|dur|dn&t|ts|d|fn|s|tdn |dtt |WYd}~nd}~wtjy6}z|td|WYd}~nd}~wtjyH|tdYnstjyu}z |jdurZ|j}|jdurc|j}|| WYd}~nJd}~wtj!y}z |j"WYd}~Sd}~wt#y}z8|td t |t |$d}|d$vr|tdn|d$vr|tdWYd}~nd}~wt%j&j'y}zd}|td t |WYd}~nd}~wt%j&j(y7}z8d}z|j)jd}Wnt*t+fy|j)}Ynwt|tj,r!t-|}|tdt |WYd}~nd}~wt.t/fy}zNt%0|drV|jrV|jd tj1krVn3t2|ddrt2|dddurz|tdt|jt |j fn|td t|jnWYd}~n,d}~wt3y|td Ynt4y}z d!}|j5}WYd}~nd}~ww|6d"d#r|S|S)$zcall func() with global exception handling return func() if no exception happens. otherwise do some error handling and return an exit code accordingly. does not handle all exceptions. s%timed out waiting for lock held by %rslock held by %rsabort: %s: %s s(lock might be very busy) Nsabort: could not lock %s: %s s abort: %s s(%s) s abort: %srr s %r s empty string s %r sabort: file censored %s s6abort: working directory revision cannot be specified s mpatch bdiffs((did you forget to compile extensions?) szlibs"(is your Python install correct?) dsabort: error: %s sargsstrerrorfilenamesabort: %s: '%s' sabort: out of memory uisdetailed-exit-code)7 tracebackrLockHelderrno ETIMEDOUTrrbytestrlockerdescr forcebytestrrgLockUnavailabler strtolocalrf RepoError isinstanceRepoLookupErrorhint ResponseErrorargstypesysbytesbytesellipsisCensoredNodeErrorWdirUnsupportedErrordetailed_exit_codecoarse_exit_codeformat WorkerError status_code ImportErrorsplitrurlerr httperrorurlerrorreasonAttributeError IndexErrorunicode unitolocalIOErrorOSError safehasattrEPIPEr MemoryError SystemExitcode configbool)rZfuncrrinstrmsgmr3r3r4 callcatchs            $  $   rcCs|dvr ttd|dD]}||vr!ttdt|qz t|ttdty6Ynw||krFttd|dS)N)tip.nullsthe name '%s' is reserved):rd s%r cannot be used in a namescannot use an integer as a names)leading or trailing whitespace in name %r)r InputErrorrrrnint ValueErrorstrip)r[lblkindcr3r3r4 checknewlabel s&   rcCs,d|vsd|vrttdt|dS)zFCheck that the filename f is an acceptable filename for a tracked filerrds)'\n' and '\r' disallowed in filenames: %rN)rrrrrnfr3r3r4 checkfilename"srcCsht|t|\}}|s|r2t|}|r0d|t|f}|r%t||t d|dSdSdS)zECheck if filename f is portable and warn or abort depending on configs%s: %s warning: %s N) rcheckportabilityalertrcheckwinfilenamer shellquoterrwarnr)rZrabortrrr3r3r4 checkportable+s   rcCsj|dd}|}t|}tjp|dk}|p|dk}|dur1|s1|s1|dks1ttd|||fS)z_check if the user's config requests nothing, a warning, or abort for non-portable filenamesrisportablefilenamessabortwarnNsignores,ui.portablefilenames value is invalid ('%s')) configlowerr parseboolr iswindowsr ConfigErrorr)rZvallvalbvalrrr3r3r4r8s    rc@seZdZddZddZdS)casecollisionauditorcCs>||_||_d|}tt|d|_||_t|_ dS)Nr) _ui_abortjoinrHrrr _loweredfiles _dirstate _newfiles)r2rZrdirstateallfilesr3r3r4__init__Hs   zcasecollisionauditor.__init__cCsx||jvrdSt|}||jvr.||jvr.td|}|jr$t||j td||j ||j |dS)Ns&possible case-folding collision for %sr) rrrrrrrr StateErrorrrrI)r2rflrr3r3r4__call__Ss     zcasecollisionauditor.__call__N)r=r>r?rrr3r3r3r4rGs rc s|j}|rt|d}|js|sdSt|jt|f}n |js"dS}t}|j|}|sXtfdd|j|BD}|rXt }|D] } | d| qE| }||j|<|S)abuild hash of filtered revisions in the current repoview. Multiple caches perform up-to-date validation by checking that the tiprev and tipnode stored in the cache file match the current repository. However, this is not sufficient for validating repoviews because the set of revisions in the view may change without the repository tiprev and tipnode changing. This function hashes all the revs filtered from the view (and, optionally, all obsolete revs) up to maxrev and returns that SHA-1 digest. sobsoleteNc3s|] }|kr|VqdSr)r3r8rmaxrevr3r4r:zzfilteredhash..s%d;) changelogrgetrevs filteredrevshash frozenset_filteredrevs_hashcachegetrJrsha1rGdigest) r[r needobsoleteclobsrevskeyresultrevssrevr3rr4 filteredhash`s(     rc#s:fdd}ttjdd|rdurfdd}nd}|dur*|r*g}||tjd|d D]h\}}}|d |vrg|Vtj|d d } tjtj| d rX| V|r`|d q2g|dd<q2|rg} |D]&} tj|| } ||| rtj| rt | d|D]} | Vqqm| | qm| |dd<q2dS) zyield every hg repository under path, always recursively. The recurse flag will only control recursion into repo working dirscs|jkr|dSr))rg)err)pathr3r4 errhandlers zwalkrepos..errhandlersamestatNcs6t|tfdd|D}|s|| S)Nc3s|]}|VqdSr)r3)r8 lstdirstat)dirstatrr3r4r:z,walkrepos..adddir..)osstatanyrX)dirlstdirnamer)r)rr4adddirs  zwalkrepos..adddirFT)topdownonerrors.hgspatches) r rrwalksortrisdirremoveislink walkreposrX)r followsym seen_dirsrecurserrrootdirsfilesqrootnewdirsdfnamehgnamer3)rrr4rsB         rcCs |}|dur|jjS|S)z)Return binary node id for a given basectxN)noder[ nodeconstantswdirid)rSrr3r3r4binnodes rcCs|}|dur tS|S)z]Return integer for a given basectx that can be used in comparison or arithmetic operationN)rr )rSrr3r3r4intrevsrcCs|}t|jt|t|S)zzFormat changectx as '{rev}:{node|formatnode}', which is the default template provided by logcmdutil.changesettemplater)r[ formatrevnoderZrr)rSr[r3r3r4formatchangeidsrcCs |jrt}nt}d|||fS)zAFormat given revision and node depending on the current verbositys%d:%s) debugflagrr )rZrrhexfuncr3r3r4rsrc Cs|dr |dd}z |j|}Wn`tjyu|jdd}|rtddi}|j|<|j |gdd}g}|D]}|j |}t ||rQ| |q=t |dkre|dWdYSWd1sowYw|dur|dS|j||S) Nxr experimentalrevisions.disambiguatewithin)r r Tuserr) startswith unfilteredr _partialmatchrAmbiguousPrefixLookupErrorrZrconfigoverrideanyrevsrrrXrYr)r[prefixrrevsetconfigoverridesrmatchesrr3r3r4resolvehexnodeidprefixs@         rcCsNzt|}|dkr|dddks|t|krWdSWdSty&YdSw)z@Checks if the given prefix may be mistaken for a revision number0rrFT)rrYr)r[rir3r3r4 mayberevnums$ rcst|d}fdd}j}jdd}|rd}|dur%|d}|dur9j|gdd }|dur9||d<||vrt}d} |durO|d } | s~t t d r~|j } t | d rd| } t | t|} |D]} | | qn|dur~| |d <| durt| |} |d| } || St|t|dD].} g}|d| } |D]}|}| |d| kr||qt|dkr|| Sqz |||WStjytw) zFind the shortest unambiguous prefix that matches hexnode. If "cache" is not None, it must be a dictionary that can be used for caching between calls to this method. rcsjjddrt|rd|S|St}tt|t|dD]}|d|}t|s2|Sq!dS)zDisambiguate against revnums.r srevisions.prefixhexnoder rN)rZrrrrangerY)rhexnodelengthrr[r3r4 disambiguates   z-shortesthexnodeidprefix..disambiguater r NsdisambiguationrevsetTrsdisambiguationnodetreenodetree get_cindex)maxrrrZrrrrrrrr#indexr$r#rYinsertshortestrrXr LookupErrorrv)r[r minlengthcacher"rrrrr#r&rr rrr otherhexnoder3r!r4shortesthexnodeidprefixs^             r-cCs(zt||WdStjyYdSw)zChecks if a symbol exists in the repo. See revsymbol() for details. Raises error.AmbiguousPrefixLookupError if the symbol is an ambiguous nodeid prefix. TF) revsymbolrrv)r[symbolr3r3r4 isrevsymbolOs  r0c Cst|tsd|t|f}t|z|dvr||WSz-t|}d||kr)tt|j}|dkr6||7}|dksB||krD|t krDt||WWStj yRtt t fy]Ynwt|d|j jkrzt|}|j|}||WWStjyttfyYnwz|j||}|j|}||WWStyYnwt||}|dur|j|}||WSttd|tjy|dYStj tjtjfyt||w)zReturns a context given a single revision symbol (as string). This is similar to revsingle(), but accepts only a single revision symbol, i.e. things like ".", "tip", "1234", "deadbeef", "my-bookmark" work, but not "max(public())". sCsymbol (%s of type %s) was not a string, did you mean repo[symbol]?)rrr%drNsunknown revision '%s')rur|rzrProgrammingErrorrrrYrr FilteredIndexError OverflowErrorrrnodelenrrFilteredLookupError TypeErrorr)names singlenodeKeyErrorrrvrrFilteredRepoLookupError_filterederror)r[r/rrlrrr3r3r4r.\sn                 r.cCsx|jdr,|}t||}|rt|||}ntd|}td}tj ||dStd}|||jf;}t |S)zbuild an exception to be raised about a filtered changeid This is extracted in a function to help extensions (eg: evolve) to experiment with various message variants.visibleshidden revision '%s's'use --hidden to access hidden revisionsrws+filtered revision '%s' (not in '%s' subset)) filternamerrr.rr_getfilteredreasonrrr<)r[changeidunfilteredreporSrrwr3r3r4r=s    r=rcCsB|s |dkr ||St||g|d}|sttd||S)Nr) localaliassempty revision set)revrangerrrlast)r[revspecr(rEr>r3r3r4 revsingles  rIcCst|}|o |ddvS)Nr)srangesrangepres rangepostsrangeall)rparse)rHtreer3r3r4 _pairspecs rLcs|s ddfSt|}|sttd|}|}||kr.s#empty revision on one side of rangerr) rFrrrfirstrGrYallrL)r[rr>rNsecondr3rMr4revpairs   rQcCs>g}|D]}t|trtd|}||q|j|d|dS)aExecute 1 to many revsets and return the union. This is the preferred mechanism for executing revsets using user-specified config options, such as revset aliases. The revsets specified by ``specs`` will be executed via a chained ``OR`` expression. If ``specs`` is empty, an empty result is returned. ``specs`` can contain integers, in which case they are assumed to be revision numbers. It is assumed the revsets are already formatted. If you have arguments that need to be expanded in the revset, call ``revsetlang.formatspec()`` and pass the result as an element of ``specs``. Specifying a single revset is allowed. Returns a ``smartset.abstractsmartset`` which is a list-like interface over integer revisions. r1T)rrE)rurr formatspecrXr)r[specsrEallspecsspecr3r3r4rFs    rFccs |V||kr |d9}q)NTr2r3) windowsize sizelimitr3r3r4increasingwindowss rZcs&sgS|jfdd}|S)axIterate over files and the revs in a "windowed" way. Callers most commonly need to iterate backwards over the history in which they are interested. Doing so has awful (quadratic-looking) performance, so we use iterators in a "windowed" way. We walk a window of revisions in the desired order. Within the window, we first walk forwards to gather data, then in the desired order (usually backwards) to display it. This function returns an iterator yielding contexts. Before yielding each context, the iterator will first call the prepare function on each context in the window in forward order.c3st}d}tD]?}g}t|D]}t|d}|dur"d}n||qt|D] }|}||q,|D]}|Vq<|rIdSq dS)NFT)iterrZrxrangenextrXrJ)it stopiterationrXnrevsrrrSchangemakefilematcherpreparerr3r4iterates(     zwalkchangerevs..iterate) __getitem__)r[rrcrdrer3rar4walkchangerevs s rgcCsP|}t|dkr |S|jjr|d|tgS|dt|dkr&gS|S)zReturn list of meaningful (or all if debug) parentrevs for rev. For merges (two non-nullrev revisions) both parents are meaningful. Otherwise the first parent revision is considered meaningful if it is not the preceding revision. rr)parentsrYrZr rrr)r[rSrhr3r3r4meaningfulparents5s rics|dur|}n |jdd}|dkr|}nt|}|dur'ttd||r;|dkr;|jfddS|j dd rFd dSt j S) aReturn a function that produced paths for presenting to the user. The returned function takes a repo-relative path and produces a path that can be presented in the UI. Depending on the value of ui.relative-paths, either a repo-relative or cwd-relative path will be produced. legacyrelativevalue is the value to use if ui.relative-paths=legacy If forcerelativevalue is not None, then that value will be used regardless of what ui.relative-paths is set to. Nrisrelative-pathsslegacys)ui.relative-paths is not a boolean ('%s')cs |Sr)r3rcwdpathtor3r4g zgetuipathfn..sslashcS|Sr)r3rr3r3r4rni) rZrr rrrrgetcwdrmrr localpath)r[legacyrelativevalueforcerelativevaluerelativerr3rkr4 getuipathfnFs$  rwcsfddS)zBCreate a new uipathfn that treats the file as relative to subpath.cst|Sr)) posixpathrrrRuipathfnr3r4rnpz subdiruipathfn..r3ryr3ryr4subdiruipathfnnr|cCst|p |dp |dS)zChecks if any patterns, including --include and --exclude were given. Some commands (e.g. addremove) use this condition for deciding whether to print absolute or relative paths. includeexclude)boolr)patsoptsr3r3r4anypatsssrc Cs|tjst|Sg}|D]0}t|d\}}|dur6zt|}Wn tjy-|g}Ynw|r6||q | |q |S)ziExpand bare globs when running on windows. On posix we assume it already has already been done by sh.N) r expandglobsrCmatchmod _patsplitglobrerextendrX)rretkindpatrpatglobbedr3r3r4 expandpats|s    rr3relpathcs|duri}|s|dkrt|pg}tddfdd}|dur'|}j||d|d||d |d }|rAg}||fS) zReturn a matcher and the patterns that were used. The matcher will warn about bad matches, unless an alternate badfn callback is provided.NrTrtcs jd||fdS)Ns%s: %s )r[rZrrrrSrzr3r4bads zmatchandpats..badr~rsubrepos) listsubreposbadfn)rrwr[rralways)rSrrrr(rrrr3rr4 matchandpatss&   rcCst||||||ddS)z2Return a matcher that will warn about bad matches.rr)r)rSrrrr(rr3r3r4rsrcCstS)z8Return a matcher that will efficiently match everything.)rrrMr3r3r4matchallsrcCstj||dS)zAReturn a matcher that will efficiently match exactly these files.r)rexact)r[rrr3r3r4 matchfilesr}rcspt|st|j||S||}tj|j||g|dfdd|D}t|dkr4t ||dS)zWReturn a file name from `pat` pattern suitable for usage in followlines logic. rScsg|]}|r|qSr3r3)r8rrr3r4 z+parsefollowlinespattern..rr) rpatkindr canonpathrrrrrYr ParseError)r[rrrrSrr3rr4parsefollowlinespatterns   rcCs&|dd}|s dSt|j|S)z`return a vfs suitable to save 'orig' file return None if no special directory is configuredrisorigbackuppathN)rrwvfsr)rZr[origbackuppathr3r3r4 getorigvfss rcCst||}|dur||dS||}||r||rT|td||tt t |D]}| |rN|td||| |nq4||||rq||sq|td|||j|dd||S)acustomize where working copy backup files (.orig files) are created Fetch user defined path from config file: [ui] origbackuppath = Fall back to default (filepath with .orig suffix) if not specified filepath is repo-relative Returns an absolute path Ns.origscreating directory: %s sremoving conflicting file: %s s#removing conflicting directory: %s T)forcibly)rwjoinrrrnoterrreversedrCrfinddirs isfileorlinkunlinkmakedirsrmtree)rZr[filepathorigvfs origbackupdirrr3r3r4 backuppaths&      rc@s eZdZdZddZddZdS) _containsnodezEproxy __contains__(node) to container.__contains__ which accepts revscCs|jj|_|j|_dSr))rr_torev __contains__ _revcontains)r2r[ revcontainerr3r3r4rs  z_containsnode.__init__cCs|||Sr))rr)r2rr3r3r4rsz_containsnode.__contains__N)r=r>r?r@rrr3r3r3r4rs rc- s(|s|dusJ|s|sdSt|dsdd|D}ni}|D]\} } t| ts.| f} | || <q"|}||duri}|D]O\} } | D]H} | |vrPqIt| dkratd|  }n,t| dkrg}|D]}| |qkt d| |}|r|d }n|j }n| d}||| <qIqCd d | D}i}i}|r*i}|D]\} } | D]} | D] }||g| qqq|jfd d d ifdd|D]T}|}tfdd|D}|durtfdd||D}t||}nt||}||<||kr||g|q||kr)||g|q|dY}|j}g}|D]U\} }|| }|sHq:ddlm}|jdttj|t| t|f|d||| }t ||} |D]}!||!|f|!|| |!D] }"||"dfqqqq:|r|"||||D] \}#t#$|||#q|D] \}#t#%|||#q|j&dd}$t'(|t'j)rj*j+fdd }%g}&t,||%d D] \}'}(tfdd|'Dtfdd|(Df})|&|)q|&rt'j-||&||dnbt#.|rL|$rLt}|/D]}'|0|'q|rBddlm1}*t2||j*j+d }+|*3||||+|t#$||t#j4|n5ddlm1}*t dd|D},|,ry|*j5|j||,||dWddSWddSWddSWddS1swYdS) ado common cleanups when old nodes are replaced by new nodes That includes writing obsmarkers or stripping nodes, and moving bookmarks. (we might also want to move working directory parent in the future) By default, bookmark moves are calculated automatically from 'replacements', but 'moves' can be used to override that. Also, 'moves' may include additional bookmark moves that should not have associated obsmarkers. replacements is {oldnode: [newnode]} or a iterable of nodes if they do not have replacements. operation is a string, like "rebase". metadata is dictionary containing metadata to be stored in obsmarker if obsolescence is enabled. NsitemscSsi|]}|fdqS)r3r3r8r^r3r3r4 )sz cleanupnodes..rsmax(%ln)rsmax((::%n) - %ln)cSsg|] }|D]}|qqSr3r3r8nsr^r3r3r4rPz cleanupnodes..cs |Sr))r)r^unfir3r4rnZs zcleanupnodes..)rcs||Sr))rrrUr) newphasesr3r4rU]szcleanupnodes..phasec3s|]}|VqdSr)r3)r8prUr3r4r:bzcleanupnodes..c3s|] }|VqdSr)r)r8oldnoderr3r4r:ds  scleanup) bookmarkss"moving bookmarks %r from %s to %s s*parents(roots(%ln & (::%n))) - parents(%n)r scleanup-as-archivedcs|ddS)Nrr3)r)torevr3r4rnr{c3|]}|VqdSr)r3rrr3r4r:rc3rr)r3)r8rrr3r4r:r) operationmetadata)repaircss|] }|D]}|VqqdSr)r3rr3r3r4r:s)backup)6rritemsrur;rrYr]rHrrrCnullidvalues setdefaultrXrr%rhrU transaction _bookmarks nodebookmarksrcrrZdebugrrapply maybebytestrrrrdivergent2delete applychangesrretractboundaryadvanceboundaryrr isenabledcreatemarkersoptrrrJ createmarkerssupportinternalkeysrGrmin backupbundlearchived delayedstrip)-r[ replacementsrmovesrfixphase targetphaserreplsrvalueoldnodesnewnodesrnewnode allreplacedreproots allnewnodes toretract toadvance precursorsrS parentphaseoldphasenewphasetrbmarks bmarkchanges oldbmarksr deleterevs deletenodesnamebnodesmayusearchivedsortfuncrelsrrrelrrtostripr3)rrUrrr4 cleanupnodes s                   ,     KF$rc s,|duri}||d}z t|dpd}Wnty&ttdw|dks/|dkr6ttd|d}d}|d}t|jD]L} t | } |ds] | s]t | r| | } |j|| } t| |} z | | | | |ryd }WqEtjy|jtd || YqEwqEgfd d }t|}t||\}}}}}t||}|}||t|D],}|jjsɈ |s||vrtd ||}d}n td||}d}|jj||dqt|||||||}|st|||||D] }| vrd Sq|S)Nsdry_runs similarityrssimilarity must be a numberres$similarity must be between 0 and 100Y@rrs#skipping missing subrepository: %s cs&|vr |||dSr))rrrXrrrejectedr3r4rs  zaddremove..badfn adding %s sui.addremove.added removing %s sui.addremove.removed)label)rfloatrrrrrJrFr subdirmatcherrrrrLrreljoinr| addremover)rZr'badmatch_interestingfilesrHcopyrGverbose _findrenames _markchanges)r[matcherrrzrdry_run similarityrwctxrRsubmatchrL subprefix subuipathfnrrr+r.r-r, forgotten unknownsettoprintabsr'r renamesrr3rr4rsx           rcst||fddd}gt||\}}}}}|jjrHt||} | } | |t| D]} | | vr;td| } ntd| } |j | q.t |dd} t |||||||| }t |||||D] }|| vrqdSqfd S) z[Assert that files have somehow been operated upon. files are relative to the repo root.cs |Sr))rX)xyrr3r4rn rozmarktouched..rr r Trrr)rrrZrrHrrGrJrr'rwrrr)r[rrrr+r.r-r,rrrr r'rzr!rr3r%r4 marktoucheds,      r&cCsgggggf\}}}}}tj|jdd}|d}|j} |j|dd}| j|t|jdddd} t | D]@\} } | | } | j sK| | rK| | q4| jsV| sV| | q4| jra| ra| | q4| jrl| sl| | q4| jrt| | q4|||||fS)zWalk dirstate with matcher, looking for files that addremove would care about. This is different from dirstate.status because it doesn't care about whether files are modified or clean.T)cachedN) includeexactF)subreposr.r/full)r pathauditorrr narrowmatchrrJrFrrK get_entry any_trackedcheckrXr,r+)r[rr+r.r-r,r audit_pathrSr walkresultsr stentryr3r3r4r)s4         rc Csvi}|dkr9t||||D]*\}}} |jjs!||r!||s4|jtd||||| df|||<q|S)z.Find renames from removed files to added ones.rs7recording removal of %s as rename to %s (%d%% similar) re)r findrenamesrZrrr'r) r[rr+r,rrzr!oldnewscorer3r3r4rMs( rcCsj|d}|#||||t|D] \}}|||qWddS1s.wYdS)zmMarks the files in unknown as added, the files in deleted as removed, and the files in renames as copied.N)wlockforgetrIrrKr)r[r.r-r!rr6r5r3r3r4rds   "rcsBtr fdd}|Sidurtfdd}|S)Ncs<|}|}||vr||S|}||vr||SdSr))p1copiesp2copies)fnrrSr:r;rMr3r4 getrenamedrsz getrenamedfn..getrenamedcs|vr/i|<|}|D]}||}|||}|o#|d||<|kr.nq||vr;||Sz ||WStjyOYdSw)zlooks up all renames for a file (up to endrev) the first time the file is given. It indexes on the changerev and only parses the manifest if linkrev != changerev. Returns rename info for fn at changerev rev.rN)filelinkrevrenamedr copysourcerr))r<rrrlrr@endrevrcacher[r3r4r=s"    ) copiesmodusechangesetcentricalgorY)r[rDr=r3rCr4 getrenamedfnos   rHcs0t|r dd}|St||fdd}|S)NcSs>|r|}||t|St|Sr))r;r:rrGrJr)rS allcopiesr3r3r4copiesfns   zgetcopiesfn..copiesfncs6g}|D]}||}|r|||fq|Sr))rrrX)rSr r<renamer=r3r4rJs )rFrGrH)r[rDrJr3rLr4 getcopiesfns  rMc Cs|j|p|}||kr&|j|}|js|js$|s"|j|dSdSdS|j|jr\||kr\|jsG|td| ||| ||f|j|jsX|sZ| |gdSdSdS|sf| ||dSdS)zUpdate the dirstate to reflect the intent of copying src to dst. For different reasons it might not end with dst being marked as copied from src. sF%s has not been committed yet, so no copy data will be stored for %s. N) rcopiedr-r+tracked set_trackedquietrrrmrIr) rZr[rsrcdstdryrunrlorigsrcr3r3r3r4 dirstatecopys* rVc s|d}|j}t|}|||j|j||d}|jD] }|j|ddq |j D] }|j|ddq-|j D] }|j|ddq:t ||| |fddtD}t|D]\}} | |vss||vss||j sud} || |qa|dS) zMove the dirstate to newctx and adjust it as necessary. A matcher can be provided as an optimization. It is probably a bug to pass a matcher that doesn't match all the differences between the parent of the working copy and newctx. r)rT) p1_trackedFcsi|] \}}|||qSr3)r)r8rSrR oldcopiesr3r4rs z movedirstate..N)rrDr setparentsrrr'r*update_file_p1r+r,rF pathcopiesrGrrKr-r!_quick_access_changeid_invalidate) r[newctxroldctxdsr rrrSrRr3rXr4 movedirstates*       racCsRtj|vr%tt}}|D]}|tjvr||q||q||fS|dfS)zfilters the requirements into two sets: wcreq: requirements which should be written in .hg/requires storereq: which should be written in .hg/store/requires Returns (wcreq, storereq) N)requirementsmodSHARESAFE_REQUIREMENTrHWORKING_DIR_REQUIREMENTSrI)rwcstorerr3r3r4filterrequirementss    rgcCs tj|jvS)z;returns whether the repository is using treemanifest or not)rbTREEMANIFEST_REQUIREMENTrrMr3r3r4istreemanifests ricCsf|r||_t|j\}}|durt|j||dur"t|j|dS|jddr1|jddSdS)zwrites requirements for the repo Requirements are written to .hg/requires and .hg/store/requires based on whether share-safe mode is enabled and which requirements are wdir requirements and which are store requirements Nformatsusestorerequires)rrg writerequiresrsvfsrZr tryunlink)r[rwcreqstorereqr3r3r4writereporequirements s rqcCsP|dddd}t|D] }|d|q WddS1s!wYdS)NrkwT) atomictemp%s )rJwrite)openerrfprr3r3r4rl s  "rlc@s8eZdZddZddZddZddZed d Zd S) filecachesubentrycCsH||_d|_d|_|r"t|j|_|jr|j|_dSd|_dSdSr))r cachestat _cacheablerxr cacheable)r2rrr3r3r4r's zfilecachesubentry.__init__cCs|r t|j|_dSdSr))r{rxrrryr1r3r3r4refresh5szfilecachesubentry.refreshcCs|jdur|jSdSNT)rzr1r3r3r4r{9s zfilecachesubentry.cacheablecCsR|sdSt|j}|r|jdur||_|jsdS|j|kr'||_dSdS)NTF)r{rxrrrzry)r2newstatr3r3r4changed@s   zfilecachesubentry.changedc CsBzt|WSty }z|jtjkrWYd}~dSd}~wwr))rryrrlENOENT)rer3r3r4rUs  zfilecachesubentry.statN) r=r>r?rr|r{r staticmethodrr3r3r3r4rx&srxc@s&eZdZd ddZddZddZdS) filecacheentryTcCs&g|_|D] }|jt||qdSr))_entriesrXrx)r2pathsrrr3r3r4r_szfilecacheentry.__init__cCs|jD] }|r dSqdS)ztrue if any entry has changedTF)rrr2r3r3r3r4rds zfilecacheentry.changedcCs|jD]}|qdSr))rr|rr3r3r4r|ks  zfilecacheentry.refreshN)T)r=r>r?rrr|r3r3r3r4r^s  rc@sBeZdZdZddZddZddZdd Zdd d Zd dZ d S) filecacheaA property like decorator that tracks files under .hg/ for updates. On first access, the files defined as arguments are stat()ed and the results cached. The decorated function is called. The results are stashed away in a ``_filecache`` dict on the object whose method is decorated. On subsequent access, the cached result is used as it is set to the instance dictionary. On external property set/delete operations, the caller must update the corresponding _filecache entry appropriately. Use __class__..set() instead of directly setting . When using the property API, the cached data is always used if available. No stat() is performed to check if the file has changed. Others can muck about with the state of the ``_filecache`` dict. e.g. they can populate an entry before the property's getter is called. In this case, entries in ``_filecache`` will be used during property operations, if available. If the underlying file changes, it is up to external callers to reflect this by e.g. calling ``delattr(obj, attr)`` to remove the cached method result as well as possibly calling ``del obj._filecache[attr]`` to remove the ``filecacheentry``. cGs ||_dSr)r)r2rr3r3r4rs zfilecache.__init__csfddjDS)Ncsg|]}|qSr3)r)r8robjr2r3r4rrz+filecache.tracked_paths..r)r2rr3rr4 tracked_pathszfilecache.tracked_pathscCst)aUsed to compute the runtime path of a cached file. Users should subclass filecache and provide their own version of this function to call the appropriate join function on 'obj' (an instance of the class that its member function was decorated). )NotImplementedError)r2rrr3r3r4rszfilecache.joincCs ||_|j|_t|j|_|Sr))rr=snamerr{r)r2rr3r3r4rszfilecache.__call__NcCs|dur|S|j|jvsJ|j|j}|r"|r!|||_n||}t |d}|||_||j|j<|j|j|j<|jSr}) r__dict__ _filecacherrrrrrr)r2rrzr3rr3r3r4__get__s     zfilecache.__get__cCsP|j|jvr||}t|d}||j|j<n|j|j}||_||j|j<dS)NF)rrrrrrr)r2rrrcer3r3r4rHs    z filecache.setr)) r=r>r?r@rrrrrrHr3r3r3r4rps  rc Cs|jd|}|sttd|i}d}}z|dr<|dd}tjt |ddtj tj t |j d}|j }nt|j|}|D]:}d |vrV|d d \}} n|d }} t|}zt| |t||<WqEtjtjtjfyYqEwW|rz|Wn tyYnw|r|n|rz|Wn tyYnw|r|ww|r|jd krttd |t|jf|S)akGather a map of rev -> value dict from the specified source A source spec is treated as a URL, with a special case shell: type for parsing the output from a shell command. The data is parsed as a series of newline-separated records where each record is a revision specifier optionally followed by a space and a freeform string value. If the revision is known locally, it is converted to a rev, otherwise the record is skipped. Note that both key and value are treated as UTF-8 and converted to the local encoding. This allows uniformity between local and remote data sources. sextdatasunknown extdata source '%s'Nsshell:Tr`)shellbufsize close_fdsstdoutrl rrjrsextdata command '%s' failed: %s)rZrrAbortrr subprocessPopenr tonativestrclosefdsPIPErrropenrrrtolocalrIrr)rvr communicaterclose returncode explainexit) r[sourcerUdatarRproccmdr>kr9r3r3r4 extdatasourcesl          rc@sJeZdZdddZddZddZdd d Zdd d ZddZddZ dS)progressrjNcCs6||_d|_||_||_||_|dd|_||_dS)Nrsprogresssdebug)rZpostopicunittotalrr _updatebar)r2rZ updatebarrrrr3r3r4rs zprogress.__init__cCrpr)r3r1r3r3r4 __enter__szprogress.__enter__cCs |dSr))complete)r2exc_type exc_valueexc_tbr3r3r4__exit__s zprogress.__exit__cCsN|dusJ|r ||_||_||j|j||j|j|jr%||dSdSr))rrrrrr _printdebug)r2ritemrr3r3r4rGs zprogress.updatercCs||j|||dSr))rGr)r2steprrr3r3r4 increment&szprogress.incrementcCs0d|_d|_d|_||j|jd|j|jdS)Nrj)rrrrrr1r3r3r4r)szprogress.completec Cs|d}|jr d|j}|rd|}|jr.d|j|j}|jd|j||j|j||fdS|jd|j||j|fdS)Nrjrrs%s:%s %d/%d%s (%4.2f%%) s %s:%s %d%s )rrrrZrr)r2rrpctr3r3r4r/s  zprogress._printdebug)rjN)rrjN) r=r>r?rrrrGrrrr3r3r3r4r s     rcCs|ddp |ddS)zDhelper function to know if a repo should be created as general deltarj generaldeltasusegeneraldeltarrZr3r3r4 gdinitconfig@srcCs |ddS)z=helper function to know if incoming delta should be optimisedrjrrrr3r3r4 gddeltaconfigHs rc@s2eZdZdZdZd ddZd ddZd d d ZdS) simplekeyvaluefilezA simple file with key=value lines Keys must be alphanumerics and start with a letter, values must not contain ' ' characterss __firstlineNcCs||_||_dSr))rr)r2rrrr3r3r4rVs zsimplekeyvaluefile.__init__Fc Cs|j|j}i}|r$|std}t||ddd||j<|d=z"tdd|D}|j|vr?td}t||j||W|St yZ}ztt |d}~ww)zRead the contents of a simple key-value file 'firstlinenonkeyval' indicates whether the first line of file should be treated as a key-value pair or reuturned fully under the __firstline key.sempty simplekeyvalue filerNr`css,|]}|r|ddddVqdS)Nr`=r)rr)r8liner3r3r4r:ns  z*simplekeyvaluefile.read..s%r can't be used as a key) r readlinesrrrCorruptedState firstlinekeyrDrGrr rq)r2firstlinenonkeyvallinesrr updatedictr3r3r4readZs*   zsimplekeyvaluefile.readcCsg}|dur |d||D]A\}}||jkr$d|j}t||dds3d}t||s>d}t|d|vrId }t||d ||fq|j|jd d d }| d |WddS1spwYdS)a Write key=>value mapping to a file data is a dict. Keys must be alphanumerical and start with a letter. Values must not contain newline characters. If 'firstline' is not None, it is written to file before everything else, as it is, not in a key=value formNrtskey name '%s' is reservedrrs1keys must start with a letter in a key-value files+invalid key name in a simple key-value filerds(invalid value in a simple key-value files%s=%s swbT)modersrj) rXrrrr3isalphaisalnumrrrur)r2r firstlinerrr9rrwr3r3r4ruys(      "zsimplekeyvaluefile.writer)F)r=r>r?r@rrrrur3r3r3r4rNs   r)s debugobsoletepullspushsserveunbundlerrcs,fddfdd|D}t|dS)a`Invokes the registered file prefetch functions, allowing extensions to ensure the corresponding files are available locally, before the command uses them. Args: revmatches: a list of (revision, match) tuples to indicate the files to fetch at each revision. If any of the match elements is None, it matches all files. cs,|rt|tjs Jt|ddStS)NcSsdSr)r3)r<rr3r3r4rnrqz1prefetchfiles.._matcher..)rur basematcherrrrrMr3r4_matcherszprefetchfiles.._matchercsg|] \}}||fqSr3r3)r8rr)rr3r4rsz!prefetchfiles..N)fileprefetchhooks)r[ revmatches revbadmatchesr3)rr[r4 prefetchfiless  rrjc sfdd}gfdd}|fdd}|tr%|fdd}ttjrKjd d rKgd fd d |fdd}|tr_|dd} |fdd} dSdS)zregister a callback to issue a summary after the transaction is closed If as_validator is true, then the callbacks are registered as transaction validators instead cstfdd|DS)Nc3s|]}|VqdSr))r)r8rtxnnamer3r4r:rz;registersummarycallback..txmatch..)r)sourcesrr3r4txmatchrz(registersummarycallback..txmatchcs\jtfdd}dt}r!||n||||S)zdecorator for report callbacks.cs.}r|dus J|}||dSr))filtered)rr[rArreporefr3r4wrappeds   z?registersummarycallback..reportsummary..wrappeds%02i-txnreport)rAweakrefrefrrY addvalidator addpostcloserX)rrnewcat) as_validator categoriesotrr[rr4 reportsummarys   z.registersummarycallback..reportsummarycs|jdd}|jdd}|jdd}|jdd}|s"|s"|rJd}|r,td|}td}r6td }|dus.reportchangegroupcsjt||}t|jdd}|r|jtd||r3td}r'td}|j|t|dSdS)Ns obsmarkersr3s%i new obsolescence markers sobsoleted %i changesets sobsoleting %i changesets )r getobsoletedrYrrrZr'r)r[r obsoleted newmarkersrrr3r4reportobsoleteds z0registersummarycallback..reportobsoletedr sevolution.report-instabilities))orphanr)sphase-divergentsphasedivergent)scontent-divergentscontentdivergentcs:|jj}i}D]\}}ttt|||||<q|Sr))rrrYrHrr)r[rcounts instabilityr)instabilitytypesr3r4getinstabilitycountss  z5registersummarycallback..getinstabilitycountscsD|}D]\}}|||}t||}|r|j|qdSr))getinstabilitymessagerZr)r[rnewinstabilitycountsrrdeltar)rroldinstabilitycountsr3r4reportnewinstabilitiess   z7registersummarycallback..reportnewinstabilitiescsl|jdt|}|}|t|krdStj||d}|r||||}}||kr2|}nd||f}t|d|}t|d|} |sS| sSt d|} n1|rc| rct d} | ||| f;} n!|rpt d } | ||f;} n| r}t d } | || f;} nd } t | |j | |jd d } |d|| } |jfdd| D}|rd} |j | t|dSdS)z3Report the range of new revisions pulled/unbundled. origrepolenN)starts%s:%ss%ld and draft()s%ld and secret()snew changesets %s s*new changesets %s (%d drafts, %d secrets) snew changesets %s (%d drafts) snew changesets %s (%d secrets) sentered unreachable conditions revduplicatesr3s(%d: + %ld) and obsolete()csg|]}|vr|qSr3r3rrr3r4rTrz@registersummarycallback..reportnewcs..s*(%d other changesets obsolete on arrival) )rrrYrrspansetrr%rrrr3rZr'r)r[r origrepolenrrminrevrrFdraftrVrerrormsg duplicatesobsadded extinctaddedr3rr4 reportnewcs+sH    z,registersummarycallback..reportnewcscs|jdt|g}|jdgD]\}\}}|tjkrq|fdd|Dq|s/dStd}r9td}|j|t|dS)zfReport statistics of phase changes for changesets pre-existing pull/unbundle. rsphasesc3s|] }|kr|VqdSr)r3)r8rrr3r4r:frzFregistersummarycallback..reportphasechanges..Ns%d local changesets published s&%d local changesets will be published ) rrrYrpublicrrrZr')r[r publishedrr5r6rrr r4reportphasechanges\s z3registersummarycallback..reportphasechangesN)_reportobsoletedsourcerrrrZr_reportnewcssource) r[rrrrrrrrr rr3)rrrrrrr[rr4registersummarycallbacks4      0rcCs|dkr td||fSdS)zfunction to return the message to show warning about new instabilities exists as a separate function so that extension can wrap to show more information like how to fix instabilitiesrs%i new %s changesets Nr)rrr3r3r4rosrcCs\t||ks |jjrddd|DSddd|d|D}td|t||fS)Nrcs|]}t|VqdSr)r r8hr3r3r4r:zrz nodesummaries..csrr)rrr3r3r4r:{rs%s and %d others)rYrZrrr)r[r maxnumnodesrNr3r3r4 nodesummariesxsrc Cs|dvrdS||}|}|D]-}|j||d}t|dkr>td} | |;} td} | t|t||f;} tj| | dqdS)z-check that no named branch has multiple heads)sstripsrepairN)closedrs'rejecting multiple heads on branch "%s"s %d heads: %sr@)r branchmap branchheadsrYrrrr) r[rrp accountclosedrAvisiblebmrheadsrrwr3r3r4enforcesingleheads  r!cCrp)zAllow extensions to wrap the sink returned by convcmd.convertsink() before it is used, whether or not the convert extension was formally loaded. r3)sinkr3r3r4wrapconvertsinksr#c s|s|S|jr|jdds|S|jdvr|St}|D]}zt|}Wn tjy/Yqw|t |q|s=|St ||}|sF|S|dkrd| d fdd|D}|j td||d |S) a(parse the user specs and unhide changesets whose hash or revision number is passed. hiddentype can be: 1) 'warn': warn while unhiding changesets 2) 'nowarn': don't warn while unhiding changesets returns a repo object with the required changesets unhidden r s directaccess)r?visible-hiddenrs, csg|] }t|qSr3)rrn)r8r>rr3r4rrz&unhidehashlikerevs..s=warning: accessing hidden changesets for write operation: %s r$)rArZrrHrrJrrrGgethashlikesymbols_getrevsfromsymbolsrrrrr)r[rS hiddentypesymbolsrUrKrrevstrr3rr4unhidehashlikerevss@     r*c Cst}|}|j}|j}t|}|jdd}|D]N}zt|} | |kr4|s)Wq| |vr2|| WqWn ty>Ynwzt ||}Wnt j t j fyUd}Ynw|durh| |} | |vrh|| q|S)zkparse the list of symbols and returns a set of revision numbers of hidden changesets present in symbolsr sdirectaccess.revnumsN)rHrrrYrZrrrIrrrr)rr) r[r(rrunficlrtiprev allowrevnumsrr^rr3r3r4r&s<    r&cCs|t|S)zSelect revisions reachable by a given bookmark If the bookmarked revision isn't a head, an empty set will be returned. )rformat_bookmark_revspec)r[markr3r3r4 bookmarkrevssr0cCsd|}td|||S)zOBuild a revset expression to select revisions reachable by a given bookmarksliteral:smancestors(bookmark(%s)) - ancestors(head() and not bookmark(%s)) - ancestors(bookmark() and not bookmark(%s)))rrR)r/r3r3r4r.sr.r)r)FNF)rN)rN)rVrW)FN)r3NFrN)NNFNT)r")rjF)r) __future__rrlrrrxrrri18nrrrrrr r rr thirdpartyr rcr rFrrrrrrrrrrrbrrrrrrutilsrrr rr! scmplatformr" importmodr# importrust rustrevlogtermsizerobjectr'rTr_rrrrrrrrrrrrrrr-r0r.r=rIrLrQrFrZrgrirwr|rrrrrrrrrrrr&rrrrHrMrVrargrirqrlrxrrrrrrrrrrhooksr_reportstroubledchangesetsrrrr!r#r*r&r0r.r3r3r3r4s    L     ~    $1   J C    * (  "   $  8 E#$ .  % 8YD3H  , 5#