o ]Lb@sddlmZddlZddlZddlZddlZddlmZddlm Z m Z m Z ddl m Z ddlmZmZmZmZmZmZmZmZmZmZmZm Z mZmZmZm Z m!Z!m"Z"ddl#m$Z$m%Z%dd l&m'Z'e"j(Z(Gd d d e)Z*Gd d d e*Z+Gddde)Z,Gddde,Z-Gddde*Z.Gddde.Z/Gddde,Z0Gddde0Z1Gddde.Z2Gddde0Z3Gddde/Z4d d!Z5d"d#Z6d$d%Z7Gd&d'd'e.Z8Gd(d)d)e0Z9Gd*d+d+e.Z:Gd,d-d-e)Z;dS).)absolute_importN)_)hexnullrevshort)getattr)dagopencodingerrorfilesetmatch mergestatemetadataobsoletepatchpathutilphasespycompatrepoviewscmutilsparsesubrepo subrepoutilutil)dateutil stringutil) timestampc@seZdZdZddZddZeeZddZ dd Z d d Z d d Z ddZ ddZddZddZddZeddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zdfd-d.Zd/d0Zd1d2Zd3d4Z d5d6Z!d7d8Z"d9d:Z#d;d<Z$d=d>Z%d?d@Z&dAdBZ'dCdDZ(dEdFZ)dGdHZ*edIdJZ+dKdLZ,dMdNZ-dgdPdQZ.dRdSZ/dTdUZ0 , , , V W , ,dhdXdYZ1 , , , , , , , , ,didZd[Z2d\d]Z3d^d_Z4 , , W W W Wdjd`daZ5dkdbdcZ6dddeZ7d,S)lbasectxaIA basectx object represents the common logic for its children: changectx: read-only context that is already present in the repo, workingctx: a context that represents the working directory and can be committed, memctx: a context that represents changes in-memory and can also be committed.cCs ||_dSN_reposelfrepor%3/usr/lib/python3/dist-packages/mercurial/context.py__init__? zbasectx.__init__cC t|Sr)rnoder#r%r%r& __bytes__B zbasectx.__bytes__cCdt|jt|fSNz<%s %s>type__name__strr+r%r%r&__repr__Gzbasectx.__repr__cCs4zt|t|ko|j|jkWStyYdSwNF)r1_revAttributeErrorr#otherr%r%r&__eq__Js  zbasectx.__eq__cC ||k Srr%r9r%r%r&__ne__Pr(zbasectx.__ne__cC ||jvSr _manifestr#keyr%r%r& __contains__Sr(zbasectx.__contains__cC ||Sr)filectxrAr%r%r& __getitem__Vr(zbasectx.__getitem__cC t|jSr)iterr@r+r%r%r&__iter__Yr(zbasectx.__iter__cC|S)zBuilds a manifest that includes the given status results, if this is a working copy context. For non-working copy contexts, it just returns the normal manifest.)manifest)r#statusr%r%r&_buildstatusmanifest\szbasectx._buildstatusmanifestcCs|S)zfThis internal method provides a way for child objects to override the match operator. r%)r#r:r r%r%r& _matchstatusbszbasectx._matchstatusc sd}|dur||kr||}|||dur#||}gg}} g} g} |j|j|j} } }t| j||d}t|D]Z\}}|vrQqH|dur[| |qH|\\}}\}}|durm| |qH|durw| |qH||kr| |qH||j j j vr| |qH|| ||r| |qH| |qH| r‡fdd| D} fdd|D}fdd| D} t|| | | | || S)z.build a status with respect to another contextN)r cleanc$g|]}|vrr|r|qSr%r%.0fnr mf1r%r& z(basectx._buildstatus..crPr%r%rQrTr%r&rVrWcsg|]}|vr|qSr%r%rQ) deletedsetr%r&rV)revrMdeletedunknownignoredsetdiffr iteritemsappendr! nodeconstantswdirfilenodeidscmprrL)r#r:sr listignored listclean listunknownmf2modifiedaddedremovedrOr[r\r]drSvaluenode1flag1node2flag2r%)rXr rUr& _buildstatushsR              zbasectx._buildstatuscCst||jjSr)rstater!uir+r%r%r&substatezbasectx.substatecCs|j|dSNr)rvr#subpathr%r%r&subrevzbasectx.subrevcC|jSr)r7r+r%r%r&rZz basectx.revcCr}r)_noder+r%r%r&r*r~z basectx.nodecCr)r)rr*r+r%r%r&rr-z basectx.hexcCr}rr?r+r%r%r&rKr~zbasectx.manifestcCr}r) _manifestctxr+r%r%r& manifestctxr~zbasectx.manifestctxcCr}rr r+r%r%r&r$r~z basectx.repocCstj|Sr)r phasenamesphaser+r%r%r&phasestrr|zbasectx.phasestrcCs|tjkSr)rrpublicr+r%r%r&mutabler|zbasectx.mutableNcCstj||||dS)N)badfn)r r )r#cwdexprrr%r%r& matchfilesetzbasectx.matchfilesetcC|t|jdvS)z!True if the changeset is obsoletesobsoleterZobsmodgetrevsr!r+r%r%r&rzbasectx.obsoletecCr)z True if the changeset is extinctsextinctrr+r%r%r&extinctrzbasectx.extinctcCr)z:True if the changeset is not obsolete, but its ancestor isorphanrr+r%r%r&orphanrzbasectx.orphancCr)zTrue if the changeset tries to be a successor of a public changeset Only non-public and non-obsolete changesets may be phase-divergent. sphasedivergentrr+r%r%r&phasedivergentzbasectx.phasedivergentcCr)zIs a successor of a changeset with multiple possible successor sets Only non-public and non-obsolete changesets may be content-divergent. scontentdivergentrr+r%r%r&contentdivergentrzbasectx.contentdivergentcCs|p |p |S)zTTrue if the changeset is either orphan, phase-divergent or content-divergent)rrrr+r%r%r& isunstableszbasectx.isunstablecCs>g}|r |d|r|d|r|d|S)zreturn the list of instabilities affecting this changeset. Instabilities are returned as strings. possible values are: - orphan, - phase-divergent, - content-divergent. rsphase-divergentscontent-divergent)rrarr)r# instabilitiesr%r%r&rs   zbasectx.instabilitiescCr})z)return contexts for each parent changeset_parentsr+r%r%r&parentszbasectx.parentscC |jdSNrrr+r%r%r&p1r(z basectx.p1cCs$|j}t|dkr |dS|jtS)Nr)rlenr!r)r#rr%r%r&p2s  z basectx.p2c Csd|jvr z|j|WStyt|jpd|tdwd|jvs+||vr;||j vr;|j ||j |fS|j j }z||j j|\}}W||fStybt|jp\d|tdw)Nr@sNonesnot found in manifest_manifestdelta)__dict__r@findKeyErrorr ManifestLookupErrorrrfilesrflagsr! manifestlog _changesetrK)r#pathmflr*flagr%r%r& _fileinfo s,     zbasectx._fileinfocCs||dSr)rr#rr%r%r&filenode!r|zbasectx.filenodecCs(z||dWStjyYdSw)Nr)rr LookupErrorrr%r%r&r$s z basectx.flagscCs t|Sr)rcomputechangesetcopiesr+r%r%r&_copies* zbasectx._copiescCrrrr+r%r%r&p1copies.r(zbasectx.p1copiescCrrxrr+r%r%r&p2copies1r(zbasectx.p2copiesTcCstj|||dS)z>return a subrepo for the stored revision of path, never wdir()) allowcreater)r#rrr%r%r&sub4rwz basectx.subcCst|||Sr)r nullsubrepo)r#rpctxr%r%r&nullsub8r|zbasectx.nullsubcCstj||ddS)z]return a subrepo for the stored revision, or wdir if this is a wdir context. T) allowwdirrrr%r%r& workingsub;zbasectx.workingsubglobFc Cs4|j}|s |}tj|j||||||j|||d S)N)auditorctx listsubreposr)r!getcwdmatchmodr root nofsauditor) r#patsincludeexcludedefaultrrrrr%r%r&r As z basectx.matchc CsD|dur|}|dur|j|}tj|j|||||||||| d S)z;Returns a diff generator for the given contexts and matcherN)r changesopts losedatafnpathfncopycopysourcematch hunksfilterfn)rr!rr_) r#ctx2r rrrrrrrr%r%r&r_[s"  z basectx.diffcC |jSr)r@dirsr+r%r%r&rzr(z basectx.dirscCs |j|Sr)r@hasdir)r#dirr%r%r&r}r-zbasectx.hasdirc s||}|j|}d} t|tst|trd} ||}}|j|}|||}tggggggg} ||| ||||} | rLt| j| j | j ggg| j } |rt ||D]D\} z| } Wn tyjd} Ynwt|} | j| | |||dd}dD]}t| |t||}}|fdd|Dq~qT| j| j | j | j| j| j| j | S)areturn status of files between two nodes or node and working directory. If other is None, compare this node with working directory. ctx1.status(ctx2) returns the status of change from ctx1 to ctx2 Returns a mercurial.scmutils.status object. Data can be accessed using either tuple notation: (modified, added, removed, deleted, unknown, ignored, clean) or direct attribute access: s.modified, s.added, ... FTN)r r]rOr\r)rjrkrlr[r\r]rOc3s|] }d|fVqdS)s%s/%sNr%rRfrzr%r& sz!basectx.status..)r! isinstance changectx narrowmatchrNrrLrsrjrlrkrO itersubreposr{rr subdirmatcherrextendsortr[r\r])r#r:r rfrgrhrctx1rreversedrrrev2submatchrekrfilessfilesr%rr&rLsX              zbasectx.statuscCstd|j)z)Get a mergestate object for this context.z"%s does not implement mergestate())NotImplementedError __class__r#rOr%r%r&rszbasectx.mergestatecCs6t|dkp||kp|p| Srx)rrbranchr closesbranchrr+r%r%r&isemptyszbasectx.isemptyrTNNNrFNN) NNNNNNNNN)NNFFFFF)8r2 __module__ __qualname____doc__r'r,r strmethod__str__r4r;r=rCrFrIrMrNrs propertycachervr{rZr*rrKrr$rrrrrrrrrrrrrrrrrrrrrrr r_rrrLrrr%r%r%r&r7s B       e rcsVeZdZdZdKfdd ZddZddZeZed d Z ed d Z e d dZ eddZ eddZddZddZddZddZddZddZdd Zd!d"Zefd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Z d7d8Z!d9d:Z"d;d<Z#d=d>Z$dLd@dAZ%dMdCdDZ&dEdFZ'dGdHZ(dIdJZ)Z*S)NrzA changecontext object makes access to data related to a particular changeset convenient. It represents a read-only context already present in the repo.Tcs&tt||||_||_||_dSr)superrr'r7r_maybe_filtered)r#r$rZr*maybe_filteredrr%r&r's zchangectx.__init__cCs(zt|jWStyt|YSwr)hashr7r8idr+r%r%r&__hash__s    zchangectx.__hash__cCs |jtkSr)r7rr+r%r%r& __nonzero__ r(zchangectx.__nonzero__cCs(|jr|j}n|j}|j|Sr)rr! unfiltered changelogchangelogrevisionrZr"r%r%r&rs zchangectx._changesetcCrr)rreadr+r%r%r&r@rzchangectx._manifestcCs|jj|jjSr)r!rrrKr+r%r%r&rrwzchangectx._manifestctxcCrr)r readdeltar+r%r%r&r rzchangectx._manifestdeltacCsz|j}|jr |j}n|j}||j\}}|tkr't||||ddgSt||||ddt||||ddgS)NFr) r!rrr parentrevsr7rrr*)r#r$clrrr%r%r&r$s zchangectx._parentscCs"|j}|j|j|j|j|j|jfSr)rrKuserdater descriptionextrar#cr%r%r& changeset4szchangectx.changesetcC|jjSr)rrKr+r%r%r& manifestnode?zchangectx.manifestnodecCrr)rr r+r%r%r&r Brzchangectx.usercCrr)rrr+r%r%r&rErzchangectx.datecCrr)rrr+r%r%r&rHrzchangectx.filescCs0t|}||||t|Sr)r^rdifference_update filesadded filesremovedsorted)r#rjr%r%r& filesmodifiedKs zchangectx.filesmodifiedcCj|jj}d}|jjdkrd}n|jjdd}|dkrd}n|dkr$d}|dur3|r1t|}|Sg}|SNTschangeset-sidedataF experimentalscopies.read-fromschangeset-onlys compatibility)rrr!filecopiesmoderuconfigrcomputechangesetfilesadded)r#rcompute_on_nonesourcer%r%r&rQ  zchangectx.filesaddedcCrr)rrr!rrur rcomputechangesetfilesremoved)r#rr"r#r%r%r&rdr$zchangectx.filesremovedcs|jj}|jj}d}|jjdkrd}n|jjdd}|dkr"d}n|dkr*d}}|dur?|r9tt|j \}}n|dur?i}|durEi}||fSr) rrrr!rrur rrr)r#rrr"r#rr%r&rws$  zchangectx._copiescCrr)rrr+r%r%r&rrzchangectx.descriptioncCst|jjdSNbranch)r tolocalrrgetr+r%r%r&rzchangectx.branchcCs d|jjvSNscloserrr+r%r%r&rr-zchangectx.closesbranchcCr)z#Return a dict of extra information.r,r+r%r%r&rzchangectx.extracC|j|jS)zReturn a list of byte tag names)r!nodetagsrr+r%r%r&tagszchangectx.tagscCr.)z%Return a list of byte bookmark names.)r! nodebookmarksrr+r%r%r& bookmarksr1zchangectx.bookmarkscCs*|j}|jr |j}n|j}||jSr)r!rrr fast_rankr7)r#r$r r%r%r&r4s   zchangectx.fast_rankcCs|jj|j|jSr)r! _phasecacherr7r+r%r%r&rr*zchangectx.phasecCs|jt|jdvS)Nsvisible)r7r filterrevsr!r+r%r%r&hiddenr*zchangectx.hiddencCdSr6r%r+r%r%r& isinmemoryzchangectx.isinmemorycs"jjj}fdd|DS)zreturn list of changectx contexts for each child changeset. This returns only the immediate child changesets. Use descendants() to recursively walk children. cg|]}j|qSr%r rRxr+r%r&rVz&changectx.children..)r!rchildrenrrr%r+r&r?szchangectx.childrenccs*|jj|jgD]}|j|Vq dSr)r!r ancestorsr7)r#ar%r%r&r@szchangectx.ancestorsccs*|jj|jgD]}|j|Vq dS)zrRecursively yield all children of the changeset. For just the immediate children, use children() N)r!r descendantsr7)r#rmr%r%r&rBszchangectx.descendantsNcCs&|dur ||}t|j||||dS)z&get a file context from this changesetN)fileidrfilelog)rrEr!)r#rrCrDr%r%r&rEs   zchangectx.filectxFc s |j}|dur |jdj}|jj|j|}|s|jjjnbt|dkr)|dnW|jj ddD] }z t |j|}Wn t j yFYq1w||vrQn q1|jj|j||r|jjtdtt|jt|fdfdd t|D|jS) zreturn the "best" ancestor context of self and c2 If there are multiple candidates, it will show a message and check merge.preferancestor configuration before falling back to the revlog ancestor.Nrrsmergespreferancestors(note: using %s as ancestor of %s and %s rc3s(|]}|krtdt|VqdS)s: alternatively, use --config merge.preferancestor=%s N)rrrRnancr%r&rsz%changectx.ancestor..)rrr!rcommonancestorsheadsrbnullidrru configlistr revsymbolr RepoLookupErrorr*ancestorrLrrjoinr)r#c2warnn2cahsrrr%rGr&rNs<     zchangectx.ancestorcCs|jj|j|jS)z.True if this changeset is an ancestor of other)r!r isancestorrevr7r9r%r%r& isancestorof szchangectx.isancestorofcs.fdd}tj|}j|S)Generates matching file names.cs4tfddjDrdStddS)Nc3s&|]}|kp|dVqdS)/N) startswith)rRrerSr%r&rs$z.changectx.walk..bad..sno such file in rev %s)anyrvbadr)rSmsgr r#rYr&r[szchangectx.walk..bad)rbadmatchr!rr@walk)r#r r[mr%r]r&r_s zchangectx.walkcCrDr)r_r#r r%r%r&matchesr(zchangectx.matchesrNNr)+r2rrrr'rr__bool__rrr@propertyrrrrrr rrrrrrrrrrr0r3r4rr7r9r?r@rBrErNrUr_rb __classcell__r%r%rr&rsX       "   -rc@seZdZdZeddZeddZeddZedd Zed d Z d d Z e Z ddZ e e ZddZddZddZddZddZddZeddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Z d2d3Z!d4d5Z"d6d7Z#d8d9Z$d:d;Z%dd?Z'd@dAZ(dBdCZ)dDdEZ*dFdGZ+dHdIZ,dJdKZ-dLdMZ.dNdOZ/dPdQZ0dRdSZ1dTZ2dUdVZ3dpdXdYZ4dZd[Z5d\d]Z6dqd^d_Z7d`daZ8dbdcZ9dddeZ:dfdgZ;dhdiZdndoZ?dWS)t basefilectxaPA filecontext object represents the common logic for its children: filectx: read-only access to a filerevision that is already present in the repo, workingfilectx: a filecontext that represents files from the working directory, memfilectx: a filecontext that represents files in-memory, cCr.r)r!file_pathr+r%r%r&_filelog)r1zbasefilectx._filelogcCs8d|jvr |jSd|jvr||jS|j|jS)N _changectx_descendantrev)rrkrZ_adjustlinkrevrlrjlinkrev_filerevr+r%r%r& _changeid-s    zbasefilectx._changeidcCs&d|jvr |j|jS|j|jS)N_fileid)rrjlookuprqrkrrir+r%r%r& _filenode8s zbasefilectx._filenodecCr.r)rjrZrsr+r%r%r&ro?r1zbasefilectx._filerevcCr}rrir+r%r%r& _repopathCrzbasefilectx._repopathcCs$z|jWdStjyYdSwNTF)rsr rr+r%r%r&rGs zbasefilectx.__nonzero__cCs6z d||jfWStjyd|YSw)Ns%s@%ss%s@???)rrkr rr+r%r%r&r,Qs zbasefilectx.__bytes__cCr.r/r0r+r%r%r&r4Yr5zbasefilectx.__repr__cCs.z t|j|jfWStyt|YSwr)rrirsr8rr+r%r%r&r\s   zbasefilectx.__hash__cCs@zt|t|ko|j|jko|j|jkWStyYdSwr6)r1rirsr8r9r%r%r&r;bs   zbasefilectx.__eq__cCr<rr%r9r%r%r&r=lr(zbasefilectx.__ne__cCr}r)ror+r%r%r&filerevor~zbasefilectx.filerevcCr}r)rsr+r%r%r&rrr~zbasefilectx.filenodecCr.r)rkrrir+r%r%r&_flagsur1zbasefilectx._flagscCr}r)rxr+r%r%r&ryr~zbasefilectx.flagscCr}r)rjr+r%r%r&rD|r~zbasefilectx.filelogcCr}r)rpr+r%r%r&rZr~zbasefilectx.revcCr.r)rjrnror+r%r%r&rnr|zbasefilectx.linkrevcCrr)rkr*r+r%r%r&r*r(zbasefilectx.nodecCrr)rkrr+r%r%r&rr(zbasefilectx.hexcCrr)rkr r+r%r%r&r r(zbasefilectx.usercCrr)rkrr+r%r%r&rr(zbasefilectx.datecCrr)rkrr+r%r%r&rr(zbasefilectx.filescCrr)rkrr+r%r%r&rr(zbasefilectx.descriptioncCrr)rkrr+r%r%r&rr(zbasefilectx.branchcCrr)rkrr+r%r%r&rr(zbasefilectx.extracCrr)rkrr+r%r%r&rr(zbasefilectx.phasecCrr)rkrr+r%r%r&rr(zbasefilectx.phasestrcCrr)rkrr+r%r%r&rr(zbasefilectx.obsoletecCrr)rkrr+r%r%r&rr(zbasefilectx.instabilitiescCrr)rkrKr+r%r%r&rKr(zbasefilectx.manifestcCr}r)rkr+r%r%r&rr~zbasefilectx.changectxcCr}r_copiedr+r%r%r&renamedr~zbasefilectx.renamedcCs|jo|jdSrryr+r%r%r& copysourcezbasefilectx.copysourcecCr}rr r+r%r%r&r$r~zbasefilectx.repocCr)r)rdatar+r%r%r&sizer-zbasefilectx.sizecCr}rrtr+r%r%r&rr~zbasefilectx.pathcCs&zt|WStyYdSwr6)rbinaryr~IOErrorr+r%r%r&isbinarys  zbasefilectx.isbinarycC d|vS)Nxrr+r%r%r&isexecr-zbasefilectx.isexeccCrNlrr+r%r%r&islinkr-zbasefilectx.islinkcCr8)zwhether this filectx represents a file not in self._changectx This is mainly for merge code to detect change/delete conflicts. This is expected to be True for all subclasses of basectx.Fr%r+r%r%r&isabsentszbasefilectx.isabsentFcCs|jr||S|jdurtd|jdur9|jjr%|j|j|S| d| kr9|j|j|S| | ksG| dkrQ|j|j|SdS)Vcompare with other file context returns True if different than fctx. Ns;filectx.cmp() must be reimplemented if not backed by revlogrT) _customcmprdrsr ProgrammingErrorr!_encodefilterpatsrjr~rrr#fctxr%r%r&rds   zbasefilectx.cmpNcCs |j}|j}|j}|}||kr|St|dd}d} |dur0dd|jdD} d}n|g} |durA|j| ||d}} ||vr| durQ|j| ||d} |j} |j } | D])} |durf| |krfdS| | }| |dvr| ||d | kr| SqY|S) a|return the first ancestor of introducing If the linkrev of the file revision does not point to an ancestor of srcrev, we'll walk down the ancestors until we find one introducing this file revision. :srcrev: the changeset revision we search ancestors from :inclusive: if true, the src revision will also be checked :stoprev: an optional revision to stop the walk at. If no introduction of this file content could be found before this floor revision, the function will returns "None" and stops its iteration. _ancestrycontextNcSg|]}|qSr%rZrRpr%r%r&rV z.basefilectx._adjustlinkrev..T inclusiver) r!rrrrnrrr@rsrirreadfastr))r#srcrevrstoprevr$r rlkr memberanciterancrevsfnoderrAacr%r%r&rms8    zbasefilectx._adjustlinkrevcCs0||krdS|j|d}|durdS||kS)zBTrue if a filectx has been introduced after a given floor revisionTrNF)rn _introrev)r# changelogrevintrorevr%r%r&isintroducedafter's  zbasefilectx.isintroducedaftercCrJ)areturn the rev of the changeset which introduced this file revision This method is different from linkrev because it take into account the changeset the filectx was created from. It ensures the returned revision is one of its ancestors. This prevents bugs from 'linkrev-shadowing' when a file revision is used by multiple changesets. )rr+r%r%r&r0s zbasefilectx.introrevcCsxd}t|}d|vr|j}n d|vr|j}|dur#|j|d|dSd|vr8|j|j|d}|dur6||_|S|S)a? Same as `introrev` but, with an extra argument to limit changelog iteration range in some internal usecase. If `stoprev` is set, the `introrev` will not be searched past that `stoprev` revision and "None" might be returned. This is useful to limit the iteration range. NrprkT)rrrlr)varsrprkrZrmrlrn)r#rtoprevattrsrr%r%r&r;s  zbasefilectx._introrevcCs*|}||kr |S|j||dS)zzReturn filectx having identical contents, but pointing to the changeset revision where this filectx was introduced)changeid)rrZrEr)r#rr%r%r& introfilectxXs zbasefilectx.introfilectxcCslt|j|||d}dt|vsdt|vr#||_t|dd|_|Sdt|vr4|j|_t|dd|_|S)z@create parent filectx keeping ancestry info for _adjustlinkrev()rCrDrprkrNrl)rEr!rrZrlrr)r#rrCrDrr%r%r&_parentfilectx`s  zbasefilectx._parentfilectxc sxjjjj}fdd|D}j}|r3|d|d|dj|dffdd|DS)Ncs$g|]}|jjjkr|fqSr%r!rbrJ)rRr*riflr#r%r&rVts z'basefilectx.parents..rrcs g|] \}}}|||qSr%)r)rRrrlr+r%r&rV )rirjrrsr{insertr!rh)r#rplrr%rr&rps & zbasefilectx.parentscCs |dSr)rr+r%r%r&rr-zbasefilectx.p1cCs2|}t|dkr|dSt|j|jd|jdS)Nrrr)rrrEr!rirjr#rr%r%r&rs zbasefilectx.p2cstfddfdd}}t|dddurDjj}|dur7|jdd| Dd d }n |j|gd d }||_ t j ||||d S) aDReturns a list of annotateline objects for each line in the file - line.fctx is the filectx of the node where that line was last changed - line.lineno is the line number at the first appearance in the managed file - line.text is the data on that line (including newline character) cs j|Sr)r!rh)r=r+r%r&s z&basefilectx.annotate..csJj}sfdd|D}|D]}d|jvr"||_q|S)Ncs g|] }|kr|qSr%rrrr%r&rVrz9basefilectx.annotate..parents..rj)rprrrrj)rrr)followgetlogrr&rs z%basefilectx.annotate..parentsrNcSrr%rrr%r%r&rVrz(basefilectx.annotate..Tr)skiprevsdiffopts) r lrucachefuncrrr!rrrZr@rrr annotate)r#rrrrbaser rr%)rrr#r&rs  zbasefilectx.annotateccsbi}|}|r d}nd} |d|D] }||||f<q|s&dS|t|}|Vq rx)rrnrpopmax)r# followfirstvisitrcutparentr%r%r&r@szbasefilectx.ancestorscCs|j||S)zReturns `data()` after running repository decoding filters. This is often equivalent to how the data would be expressed on disk. )r! wwritedatarr~r+r%r%r& decodeddatarzbasefilectx.decodeddata)FNr)FNNr)@r2rrrrrjrprsrorurrdr,r rrr4rr;r=rwrrxrrDrZrnr*rr rrrrrrrrrrKrr{r|r$rrrrrrrrdrmrrrrrrrrrr@rr%r%r%r&rg s         5   2 rgc@sleZdZdZ    dddZeddZdddZd d Zd d Z d dZ ddZ eddZ ddZ dS)rEz^A filecontext object makes access to data related to a particular filerevision convenient.NcCsv||_||_|dus|dus|dusJd|||f|dur"||_|dur)||_|dur0||_|dur9||_dSdS)z`changeid must be a revision number, if specified. fileid can be a file revision or node.Ns.bad args: changeid=%r, fileid=%r, changectx=%r)r!rirjrprkrq)r#r$rrrCrDrr%r%r&r's$  zfilectx.__init__cCs4z|j|jWStjy|j|jYSwr)r!rpr FilteredRepoLookupErrorrr+r%r%r&rks zfilectx._changectxcCst|j|j||j|dS)zMopens an arbitrary revision of the file without opening a new filelog)rCrDrrEr!rirj)r#rCrr%r%r&rEszfilectx.filectxcCr.r)rjrawdatarsr+r%r%r&r!r|zfilectx.rawdatacCr.)zlow-level revlog flags)rjrror+r%r%r&rawflags$r1zfilectx.rawflagscCs\z|j|jWStjy-|jjdddkrYdStjt dt |jt ddw)Nscensorspolicysignorerscensored node: %ss"set censor.policy to ignore errors)hint) rjrrsr CensoredNodeErrorr!rur Abortrrr+r%r%r&r~(sz filectx.datacCr.r)rjrror+r%r%r&r3r|z filectx.sizec Csz|j|j}|s dS||kr|S|}|j}|jD]}z |||kr/WdSWq!t j y:Yq!w|S)a#check if file was actually renamed in this changeset revision If rename logged in file revision, we report copy for changeset only if file revisions linkrev points back to the changeset in question or both changeset parents contain different file revisions. N) rjr{rsrZrnrrkrrr r)r#r{namerrr%r%r&rz6s  zfilectx._copiedcs jj}fdd|DS)Ncs"g|] }tjj|jdqSrrr<r+r%r&rVSsz$filectx.children..)rjr?rsrr%r+r&r?Ps zfilectx.children)NNNNr)r2rrrr'rrkrErrr~rrzr?r%r%r%r&rEs"       rEcsFeZdZdZ      dDfdd ZddZdd ZeeZ d d Z e Z e d d Z e ddZe ddZddZddZddZddZddZddZddZd d!Zd"d#Zd$d%ZeZeZeZd&d'Zd(d)Zd*d+Zd,d-Z d.d/Z!d0d1Z"d2d3Z#d4d5Z$d6d7Z%d8d9Z&d:d;Z'dd?Z)dEdBdCZ*Z+S)FcommittablectxzA committablectx object provides common functionality for a context that wants the ability to commit, e.g. workingctx or memctx.rNcstt||d|_d|_||_|rt||_|r||_ |r#||_ i|_ |r-| |_ |dur9t ||j d<|j dsFd|j d<dSdS)Nr'sdefault)rrr'r7r_textr parsedate_date_user_status_extrarr fromlocalr)r#r$textr rrrrrr%r&r']s$    zcommittablectx.__init__cCst|jddS)Nr+)bytesrr+r%r%r&r,zrzcommittablectx.__bytes__cCs|jjjdSrr!rbwdirhexr+r%r%r&r}r|zcommittablectx.hexcCr8NTr%r+r%r%r&rr:zcommittablectx.__nonzero__cCrr)r!rLr+r%r%r&rrzcommittablectx._statuscCs |jjSr)r!ruusernamer+r%r%r&r zcommittablectx._usercCs(|jj}|dd}|durt}|S)Nsdevels default-date)r!ru configdatermakedate)r#rurr%r%r&rs  zcommittablectx._datecCdSrr%ryr%r%r&r{r:zcommittablectx.subrevcCrrr%r+r%r%r&rr:zcommittablectx.manifestnodecCs|jp|jjSr)rr!rurr+r%r%r&r rzcommittablectx.usercCr}r)rr+r%r%r&rr~zcommittablectx.datecCr}r)rr+r%r%r&rr~zcommittablectx.descriptioncCst|jj|jj|jjSr)rrrjrkrlr+r%r%r&rszcommittablectx.filescCrr)rrjr+r%r%r&rjrzcommittablectx.modifiedcCrr)rrkr+r%r%r&rkrzcommittablectx.addedcCrr)rrlr+r%r%r&rlrzcommittablectx.removedcCrr)rr[r+r%r%r&r[rzcommittablectx.deletedcCst|jdSr&)r r(rr+r%r%r&rr}zcommittablectx.branchcCs d|jvSr+rr+r%r%r&rr(zcommittablectx.closesbranchcCr}rrr+r%r%r&rr~zcommittablectx.extracCr8r6r%r+r%r%r&r9r:zcommittablectx.isinmemorycCgSrr%r+r%r%r&r0r:zcommittablectx.tagscCs$g}|D] }||q|Sr)rrr3)r#brr%r%r&r3s zcommittablectx.bookmarkscCs.t|jj}|D] }t||}q |Sr)rnewcommitphaser!rurrr)r#rrr%r%r&rs zcommittablectx.phasecCr8r6r%r+r%r%r&r7r:zcommittablectx.hiddencCrrr%r+r%r%r&r?r:zcommittablectx.childrencCsPd|jvrz|j|WStyYdSwz||WSty'YdSw)Nr@r)rr@rr _flagfuncOSErrorrr%r%r&rs    zcommittablectx.flagscCs|jd|S)z1return the "best" ancestor context of self and c2r)rrN)r#rPr%r%r&rNrwzcommittablectx.ancestorccsD|jD]}|Vq|jjdd|jDD]}|j|VqdS)NcSrr%rrr%r%r&rVrz,committablectx.ancestors..)rr!rr@)r#rrAr%r%r&r@s zcommittablectx.ancestorscCr8)aQPerform post-commit cleanup necessary after committing this ctx Specifically, this updates backing stores this working context wraps to reflect the fact that the changes reflected by this workingctx have been committed. For example, it marks modified and added files as normal in the dirstate. Nr%)r#r*r%r%r& markcommittedszcommittablectx.markcommittedFTcCr8r6r%)r#missingmergerr%r%r&dirtyr:zcommittablectx.dirty)rNNNNNFTT),r2rrrr'r,rr rrrrdrrrrr{rr rrrrjrkrlr[rrrrrrr9r0r3rr7r?rrNr@rrrfr%r%rr&rYs^      rcs:eZdZdZ dAfdd ZddZdd Zd d Zed d Z dBddZ fddZ ddZ eddZ ddZdBddZdCddZdDddZdDd d!Zd"d#Z    $   dEd%d&Zd'd(Zd)d*Zd+d,ZdFd-d.Zed/d0Zed1d2Zd3d4Zfd5d6Zd7d8Zd9d:Zd;d<Zd=d>Z dGd?d@Z!Z"S)H workingctxayA workingctx object makes access to data related to the current working directory convenient. date - any valid date string or (unixtime, offset), or None. user - username string, or None. extra - a dictionary of extra values, or None. changes - a list of file lists as returned by localrepo.status() or None to use the repository status. rNc s^d}|rd|vrz|j}Wntyttdwtt|j|||||||ddS)Nr'sbranch name not in UTF-8!r) dirstaterUnicodeDecodeErrorr rrrrr'rrr%r&r' s    zworkingctx.__init__ccs*|jj}|D] }||jr|VqdSrr!r get_entrytracked)r#rmrr%r%r&rIs zworkingctx.__iter__cCs|jj|jSrrrAr%r%r&rCr}zworkingctx.__contains__cCs |jjjSrrr+r%r%r&r"r(zworkingctx.hexcsHjj}|djjjkr|dd}jfdd|DS)Nrrcs&g|]}tjj||ddqS)Fr )rr!rrZrEr#unfir%r&rV,s z'workingctx._parents..)r!rrrbrJrrr%rr&r%s    zworkingctx._parentscCs|dur |jjj}|jj}|W|||}|j|}|r6|D]}||vr5|||vr5||||q!||jjjkrXt| D]\}}||vrW||vrW|d|qEWddSWddS1skwYdSr) r!rbrJr parentchange setparentsrrcopiesitems)r#p1nodep2noderrrrrer%r%r&r3s(      "zworkingctx.setparentscs|jtt||Sr)r@rrrrrr%r&rFszworkingctx._fileinfocs|jjj|}t|dkr |dfdd}|S|\}}||}|||fdd}|S)Nrrcs||}|Srrr) copiesgetmanr%r&funcUs  z'workingctx._buildflagfunc..funccsT||}|||}}}||kr|S||kr"|S||kr(|SdSNrr)rfl1fl2fla)rm1m2mar%r&r`s ")r!rrr)rrrKrN)r#rrrrpar%)rr r r rr&_buildflagfuncKs    zworkingctx._buildflagfunccC|jj|jSr)r!rflagfuncr r+r%r%r&rmrwzworkingctx._flagfunccCs"z||WStyYdSwr)rrrr%r%r&rqs   zworkingctx.flagscCt|j|||dS)z-get a file context from the working directory)rrD)workingfilectxr!r#rrDr%r%r&rEws zworkingctx.filectxFTcCspt|jD]}||j|drdSq|r|p7|o%||kp7|p7|p7| p7|o7| S)z-check whether a working directory is modified)rT) rrvrrrrrrjrkrlr[)r#rrrrer%r%r&r}s  zworkingctx.dirtyc s^|j|jj|jj}fdd}g}|jjj}|D]|}t|tj |z||}Wnt yK| t d||||Yqw|dd} | dkrn|j| krn| t d|d|jd ||ft|jst|js| t d ||||q|s| t d ||q|WdS1swYdS) Nct|SrpathtorrOrdsprefixr%r&rz workingctx.add..%s does not exist! suislarge-file-limitrso%s: up to %d MB of RAM may be required to manage this file (use 'hg revert %s' to cancel the pending addition) ri@Bs:%s not added: only files and symlinks supported currently s%s already tracked! )r!wlockrurwvfslstatr checkportableosrrOrrQrra configbytesst_sizestatS_ISREGst_modeS_ISLNK set_tracked) r#listrruuipathrejectedrrstlimitr%rr&addsJ         $zworkingctx.addcs|j3|jjfdd}g}|D]}|s.|jjtd||||q|WdS1s;wYdS)Ncrrrrrr%r&rrz#workingctx.forget..s%s not tracked! )r!rr set_untrackedrurQrra)r#rrr(r)rr%rr&forgets   $zworkingctx.forgetc Csz |jj|}Wn*ty3}z|jtjkr|jjtd|jj |WYd}~dSd}~wwt |j sRt |j sR|jjtd|jj |dS|j|jj }|||||WddS1srwYdS)Nrs1copy failed: %s is not a file or a symbolic link )r!rrrerrnoENOENTrurQrrrr"r#r$r%rr&r)r#r#destr*errrr%r%r&rs,    "zworkingctx.copyrc CsD|j}|s |}t|j } tj|j||||||j|||| d S)N)rrrricasefs)r!rrfscasesensitiverrr r) r#rrrrrrrrr3r%r%r&r s" zworkingctx.matchcCs|r|jjjr |Sg}|D]1}||dkr9||}|dks/t|dks/d|vs/t|r9|jj d|q | |q |S)Nrri s*ignoring suspect symlink placeholder "%s" ) r!r _checklinkrr~rrrrudebugra)r#rsanerrmr%r%r&_filtersuspectsymlinks"   z workingctx._filtersuspectsymlinkc Cs|sggggfSg}g}g}g}|jd}t|D]c}zQ||vs3||||ks3||||r9||n2|durC||n(||} | j} | j} t | |} | durf| | | f} ||| fn||Wqt t fy|||Yqw||||fSr) rrrrdrarr$r!rreliable_mtime_ofrr)r#rmtime_boundaryrjr[rOfixuprrremoder file_mtime cache_infor%r%r& _checklookups:          zworkingctx._checklookupc s,|j}|s|s|jjjrzzd|jj}|jdN|jj|kr\|rOr4fdd}nj}|D] \}}|||q9|j}|jj ||r[|D]} | ||qSn|jj dWdn1smwYWn t j y}Yn wW|jdSW|jdS|jwdS)z1update dirstate for files that are actually cleanFcsj|dddS)NT p1_tracked wc_tracked) update_file)rpfdrr%r&rJsz-workingctx._poststatusfixup..s*skip updating dirstate: identity mismatch N)r! postdsstatusr_dirtyidentityrpendingparentchange set_cleancurrenttransactionwriterur7r LockErrorclearpostdsstatus) r#rLr< poststatusoldidnormalrpdftrpsr%rFr&_poststatusfixup:sB       zworkingctx._poststatusfixupc Csg}d|vr t|j}|jjj|||||d\}}}g} |rM|||\} } } } |j| |j| | r>|r>|j | | rM|rM|j dd| D| || | ru|j s`|j s`|j rrt|j|j|j|jggg|_|S||_|S)z7Gets the status from the dirstate -- internal use only.s.hgsub)r]rOr\css|]\}}|VqdSrr%)rRrrr%r%r&r~sz-workingctx._dirstatestatus..)rrvr!rrLr@rjrr[rOrValwaysr\r]rrkrlr) r#r r]rOr\subreposrdrer;r< modified2deleted2 clean_setr%r%r&_dirstatestatusis4       zworkingctx._dirstatestatusc Csi}i}|jj}|j|d}|j|d}t|t|B}|j}|jj D]\}} ||vsA||sBq5| |vrK| ||<q5| |vrS| ||<q5||fS)Nrr) r!rrrKr^rkrjrrr) r#rrr p1manifest p2manifest changedsetrdstsrcr%r%r&rs    zworkingctx._copiescCs ||jS)aLgenerate a manifest corresponding to the values in self._status This reuse the file nodeid from parent, but we use special node identifiers for added and modified files. This is used by manifests merge to see that files are different and by update logic to avoid deleting newly added files. )rMrr+r%r%r&r@s zworkingctx._manifestc Cs|}|d}|j}|jjj|jf|jjj|j ffD] \}}|D]}|||<z | |||Wq%t y>Yq%wq|j |j D] }||vrO||=qF|S)z9Builds a manifest that includes the given status results.r)rrKrrr!rb addednodeidrkmodifiednodeidrjsetflagrr[rl)r#rLrrffirrr%r%r&rMs&  zworkingctx._buildstatusmanifestcsR|||||}||j|jdd<||jdkr'tt|||||||}|S)aCbuild a status with respect to another context This includes logic for maintaining the fast path of status when comparing the working directory against its parent, which is to skip building a new manifest if self (working directory) is not comparing against its parent (repo['.']). N.)r\r9rjr!rrrs)r#r:rer rfrgrhrr%r&rss   zworkingctx._buildstatuscs&jdkrfdd}||_|S)aoverride the match method with a filter for directory patterns We use inheritance to customize the match.bad method only in cases of workingctx since it belongs only to the working directory when comparing against the parent changeset. If we aren't comparing against the working directory's parent, then we just use the default match object sent to us. rgcs>|vr|sjjdjj||fdSdSdS)Ns%s: %s )rr!rurQrr)rr\r:r#r%r&r[s z$workingctx._matchstatus..bad)r!r[)r#r:r r[r%rhr&rNs zworkingctx._matchstatuscCs(t|jjj|j|t|jdddS)rVTF)rXr\r])rr!rr_rrvrar%r%r&r_s zworkingctx.walkcs0|j|}|jjtfdd|DS)Nc3s |] }|jr|VqdSr)rrrrr%r&rsz%workingctx.matches..)r!rrrrbrar%rir&rbs zworkingctx.matchescCs|jjA||D] }|jjj|dddq|D] }|jjj|dddq |jj||jt |j|Wdn1sJwY|jj |j dS)NTrAF) r!rrrjrkrDrlr!_quick_access_changeid_invalidater aftercommitrMrL)r#r*rr%r%r&rs  zworkingctx.markcommittedcCs |r tj|jStj|jSr) mergestatemodrrOr!rrr%r%r&rszworkingctx.mergestate)rNNNNrrrrFFFr)#r2rrrr'rIrCrrrrrr rrrErr,r.rr r9r@rVr\rr@rMrsrNr_rbrrrfr%r%rr&rsV    "     )  , /%    rc@sFeZdZdZdddZddZeZddZd d Zd d Z d dZ dS)committablefilectxzA committablefilectx provides common functionality for a file context that wants the ability to commit, e.g. workingfilectx or memfilectx.NcCs>||_||_d|_d|_|_|dur||_|r||_dSdSr)r!rirprorsrjrk)r#r$rrDrr%r%r&r's  zcommittablefilectx.__init__cCr8rr%r+r%r%r&r(r:zcommittablefilectx.__nonzero__cCrJrrr+r%r%r&rn-r-zcommittablefilectx.linkrevcCs0|}|sdS||jjdj||jjjfSr)r|rkrr@r)r!rbrJrr%r%r&r{1s zcommittablefilectx.renamedcsfdd}j}j}jj}}|r|dg}n |||d||fg}|ddD] }||||||fq-fdd|DS) z5return parent filectxs, following copies if necessarycs|j|jjjSr)r@r)r!rbrJ)rrr+r%r&r?r*z,committablefilectx.parents..filenoderrrNcs0g|]\}}}|jjjkrj|||dqSr)r!rbrJr)rRrrFrr+r%r&rVOs z.committablefilectx.parents..)rirjrkrr{ra)r#rrrpclr{rpcr%r+r&r<s   zcommittablefilectx.parentscCrrr%r+r%r%r&r?Ur:zcommittablefilectx.childrenrc) r2rrrr'rrdrnr{rr?r%r%r%r&ros   rocseZdZdZd$fdd ZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZd%ddZd%ddZddZd d!Zd"d#ZZS)&rzrA workingfilectx object makes access to data related to a particular file in the working directory convenient.Ncstt|||||dSr)rrr')r#r$rrDrrr%r&r']zworkingfilectx.__init__cCrGr)rr!r+r%r%r&rk`rzworkingfilectx._changectxcCr.r)r!wreadrir+r%r%r&r~dr|zworkingfilectx.datacCrr)r!rcopiedrir+r%r%r&r|gr}zworkingfilectx.copysourcecCs|jj|jjSr)r!rrrir!r+r%r%r&rjrzworkingfilectx.sizecCrr)r!rrrir+r%r%r&rmr}zworkingfilectx.lstatc Csf|j\}}z|jj|jtj|fWSty2}z|j t j kr$||fWYd}~Sd}~wwr) rkrr!rrrir"ST_MTIMErr/r0)r#ttzr2r%r%r&rps zworkingfilectx.datecCrr)r!rexistsrir+r%r%r&rxyr}zworkingfilectx.existscCrr)r!rlexistsrir+r%r%r&ry|r}zworkingfilectx.lexistscCrr)r!rauditrir+r%r%r&rzr}zworkingfilectx.auditcCs ||S)r)rdrr%r%r&rds zworkingfilectx.cmpFcCs*|jjdd}|jjj|j||ddS)+wraps unlink for a repo's working directoryrsremoveemptydirs) ignoremissingrmdirN)r!ru configboolr unlinkpathri)r#r|r}r%r%r&removes zworkingfilectx.removecKs|jj|j||fd|i|S)wraps repo.wwritebackgroundclose)r!wwriterir#r~rrkwargsr%r%r&rMszworkingfilectx.writecCs|jj||jdS)zmarks this file a copy of `src`N)r!rrri)r#rar%r%r& markcopiedrzworkingfilectx.markcopiedcCs|jj}|j}|||jjddr@||r%||s%|j|ddt t t |D]}| |r=||dSq.dS||rQ||sS||dSdSdS)zsRemoves conflicting items in the working directory so that ``write()`` can be called successfully. rsmerge.checkpathconflictsT)forciblyN)r!rrirzrur~isdirrrmtreerr'rfinddirs isfileorlinkunlink removedirs)r#rrrr%r%r& clearunknowns"   zworkingfilectx.clearunknowncCs|jj|j||dSr)r!rsetflagsri)r#rr=r%r%r&rszworkingfilectx.setflagsrcr)r2rrrr'rrkr~r|rrrrxryrzrdrrMrrrrfr%r%rr&rYs&   rcsJeZdZdZfddZddZdIddZd d Zed d Z ed dZ ddZ ddZ ddZ ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*ZdJd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Z      dKd8d9Zd:d;Z dd?Z"d@dAZ# dLdBdCZ$dIdDdEZ%dMdGdHZ&Z'S)NoverlayworkingctxaWraps another mutable context with a write-back cache that can be converted into a commit context. self._cache[path] maps to a dict with keys: { 'exists': bool? 'date': date? 'data': str? 'flags': str? 'copied': str? (path or None) } If `exists` is True, `flags` must be non-None and 'date' is non-None. If it is `False`, the file was deleted. cstt|||dSr)rrr'rOr"rr%r&r's zoverlayworkingctx.__init__cCs||_|g|_t|ddS)N _manifest) _wrappedctxrrclearcachedproperty)r# wrappedctxr%r%r&setbaseszoverlayworkingctx.setbaseNcCs>|dur |jjj}||jksJ|j|j|g|_dSr)r!rbrJrr*rr)r#rrr%r%r&rs zoverlayworkingctx.setparentscCsb||r*|j|dr#|j|ddur|j|dS|j|Std||j|SNexistsdataNo such file or directory: %s)isdirty_cacherr~r rrr%r%r&r~s zoverlayworkingctx.datacCs|}|d}|j}|D]}|jjj||<||||q| D]}|jjj ||<||||q)| D]}||=q?|Sr) rrKrrrkr!rbrbrdrjrcrl)r#rrrrr%r%r&r@s   zoverlayworkingctx._manifestcfdd}|S)Ncsj|dS)Nflagsrrr+r%r&rr|z&overlayworkingctx._flagfunc..fr%)r#rr%r+r&rs zoverlayworkingctx._flagfunccCst|||Sr)rrkrjrlr+r%r%r&rszoverlayworkingctx.filescfddjDS)Ncs(g|]}j|dr|r|qSrr_existsinparentrr+r%r&rV  z.overlayworkingctx.modified..rkeysr+r%r+r&rj  zoverlayworkingctx.modifiedcr)Ncs(g|]}j|dr|s|qSrrrr+r%r&rV rz+overlayworkingctx.added..rr+r%r+r&rk rzoverlayworkingctx.addedcr)Ncs(g|]}j|ds|r|qSrrrr+r%r&rV rz-overlayworkingctx.removed..rr+r%r+r&rl rzoverlayworkingctx.removedcCRi}|j}|jD]}||sq ||d|j|d}|r&|||<q |SNcopiedr!rrrrr#rrrr#r%r%r&r   zoverlayworkingctx.p1copiescCrrrrr%r%r&r" rzoverlayworkingctx.p2copiescCr8rr%r+r%r%r&r9. r:zoverlayworkingctx.isinmemorycCs&||r |j|dS|j|S)Ndate)rrrrrr%r%r&filedate1 s zoverlayworkingctx.filedatecCs$|j|d|||||ddS)NT)rxrrrt) _markdirtyrr)r#roriginr%r%r&r7 s zoverlayworkingctx.markcopiedcCs||r |j|dSdSr)rrrr%r%r&copydata@ s zoverlayworkingctx.copydatacCsB||r|j|dr|j|dStd||j|S)Nrrr)rrr rrrrr%r%r&rF s zoverlayworkingctx.flagscCs$||jvr |j|dS||vS)Nr)rrrAr%r%r&rCQ s  zoverlayworkingctx.__contains__cCs(z|j|WdStjyYdSwrv)rr rrr%r%r&rV s  z!overlayworkingctx._existsinparentc sfdd}|d}tt|D]}d|d|}|vr&|||qj|gdd}t |}t|dkrnt|dkrN|d|krNdSfd d |D}|s[dSt d ||t|d |fdS) a$Replicates conflict checks done by wvfs.write(). Since we never write to the filesystem and never call `applyupdates` in IMM, we'll never check that a path is actually writable -- e.g., because it adds `a/foo`, but `a` is actually a file in the other commit. csLd|vrtd||ftd||f)Nrs*error: %s conflicts with symlink %s in %d.s+error: '%s' conflicts with file '%s' in %d.)rrr rrZ)r componentr+r%r&failh sz/overlayworkingctx._auditconflicts..failrWrspath)rrNcsg|]}|vr|qSr%r%)rRr`r+r%r&rV rYz5overlayworkingctx._auditconflicts..sberror: file '%s' cannot be written because '%s/' is a directory in %s (containing %d entries: %s)s, ) splitrxrangerrOr r'rrKr_r r)r#rr componentsrfrr mfilesr%r+r&_auditconflicts` s*    z!overlayworkingctx._auditconflictsrcKs8|dur td|||j|d|t|ddS)Nsdata must be non-NoneT)rxr~rr)r rrrrr)r#rr~rrr%r%r&rM s    zoverlayworkingctx.writecCs0d}|rd}n|r d}|j|dt|ddS)NrrrT)rxrr)rrr)r#rrr=rr%r%r&r s zoverlayworkingctx.setflagscCs|j|dddS)NF)rx)rrr%r%r&r rzoverlayworkingctx.removecCsZ||r(|j|dr!d|j|dvr!||j|dS|j|dS||S)zqexists behaves like `lexists`, but needs to follow symlinks and return False if they are broken. rrrr)rrrxstriprrr%r%r&rx s   zoverlayworkingctx.existscCs"||r |j|dS||S)z'lexists returns True if the path existsr)rrrrr%r%r&ry s  zoverlayworkingctx.lexistscCsF||r|j|drt|j|dStd||j|Sr)rrrr rrrrr%r%r&r s zoverlayworkingctx.sizec s|dur}t|dkr|ddf}|ddur$j|ddf}nj|dj|df}}fdd} |durEj}tj|||| |||||d S)zConverts this ``overlayworkingctx`` into a ``memctx`` ready to be committed. ``text`` is the commit message. ``parents`` (optional) are rev numbers. Nrrc sVj|dr)t|||j|ddj|dvdj|dvj|dSdS)Nrrrrrr)r memfilectxr$memctxrr+r%r&getfile s   z+overlayworkingctx.tomemctx..getfile)rrr reditor)rrr!rrrr) r#rrrrrr rrrr%r+r&tomemctx s.     zoverlayworkingctx.tomemctxcCs<|}||d<|j|||||dS)Ns amend_source)rrrrr )rrrrrrrr )r# precursorrr%r%r&tomemctx_for_amend s  z$overlayworkingctx.tomemctx_for_amendcCr>rrrr%r%r&r r(zoverlayworkingctx.isdirtycCsd|_i|_dSr) _mergestaterr+r%r%r&rO s zoverlayworkingctx.cleanc Csg}t||t||jfg|jD]-}|j|}z|j|}| |dkrA| |dkrA| |Wqt j yLYqw|D]}|j|=qO|S)zRemoves keys from the cache that are actually clean, by comparing them with the underlying context. This can occur during the merge process, e.g. by passing --tool :local to resolve a conflict. rr)r prefetchfilesr$rrZ matchfilesrrrr~rrar r)r#rrcache underlyingr%r%r&_compact s,     zoverlayworkingctx._compactcCsb|r|dur|j|p i}|d}|dur|j|}|||||d|j|<t|ddS)Nr)rrrrrr)rr)rr~rr)r#rrxr~rrrtoldentryr%r%r&r: s   zoverlayworkingctx._markdirtycCr)N)rrD)overlayworkingfilectxr!rr%r%r&rEO s zoverlayworkingctx.filectxFcCs"|s|jdurt|j|_|jSr)rrl memmergestater!rr%r%r&rT szoverlayworkingctx.mergestaterrmNNNNNN)NNrNr)(r2rrrr'rrr~rr@rrrjrkrlrrr9rrrrrCrrrMrrrxryrrrrrOrrrErrfr%r%rr&rsZ         0  > & rcseZdZdZd$fdd ZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZd%ddZd%d d!Zd"d#ZZS)&rzWrap a ``workingfilectx`` but intercepts all writes into an in-memory cache, which can be flushed through later by calling ``flush()``.Ncs,tt|||||||_||_||_dSr)rrr'r!_parentri)r#r$rrDrrr%r&r'^ s zoverlayworkingfilectx.__init__cC||kSrr~rr%r%r&rdd r}zoverlayworkingfilectx.cmpcCr}r)rr+r%r%r&rg r~zoverlayworkingfilectx.changectxcCr.r)rr~rir+r%r%r&r~j r|zoverlayworkingfilectx.datacCr.r)rrrir+r%r%r&rm r|zoverlayworkingfilectx.datecCrJr)ryr+r%r%r&rxp rzoverlayworkingfilectx.existscCr.r)rrxrir+r%r%r&rys r|zoverlayworkingfilectx.lexistscCr.r)rrrir+r%r%r&r|v r|z overlayworkingfilectx.copysourcecCr.r)rrrir+r%r%r&ry r|zoverlayworkingfilectx.sizecCs|j|j|dSr)rrri)r#rr%r%r&r| r*z overlayworkingfilectx.markcopiedcCrrr%r+r%r%r&rz r:zoverlayworkingfilectx.auditcCr.r)rrrir+r%r%r&r r|zoverlayworkingfilectx.flagscCs|j|j||Sr)rrri)r#rrr%r%r&r rzoverlayworkingfilectx.setflagsFcKs|jj|j||fi|Sr)rrMrirr%r%r&rM rrzoverlayworkingfilectx.writecCr.r)rrrir#r|r%r%r&r r|zoverlayworkingfilectx.removecCrrr%r+r%r%r&r r:z"overlayworkingfilectx.clearunknownrcr)r2rrrr'rdrr~rrxryr|rrrzrrrMrrrfr%r%rr&rZ s$  rcs:eZdZdZ d fdd Zd ddZed d ZZS) workingcommitctxzA workingcommitctx object makes access to data related to the revision being committed convenient. This hides changes in the working directory, if they aren't committed in this context. rNcstt|||||||dSr)rrr')r#r$rrr rrrr%r&r' s  zworkingcommitctx.__init__Fc sj|r fddjD}ng}tfddjjDfddjjDfddjjDggg|S)zReturn matched files only in ``self._status`` Uncommitted files appear "clean" via this context, even if they aren't actually so in the working directory. csg|] }|jvr|qSr%) _changedsetrr+r%r&rV z4workingcommitctx._dirstatestatus..cg|]}|r|qSr%r%rr r%r&rV rYcrr%r%rrr%r&rV rYcrr%r%rrr%r&rV rY)r@rrLrrjrkrl)r#r r]rOr\r%r]r&r\ sz workingcommitctx._dirstatestatuscCs,t|jj}||jj||jj|S)z/Return the set of files changed in this context)r^rrjupdaterkrl)r#changedr%r%r&r s zworkingcommitctx._changedset)rNNNrn) r2rrrr'r\rrrfr%r%rr&r s rcsifdd}|S)zCreate a filectxfn that caches based on the path. We can't use util.cachefunc because it uses all arguments as the cache key and this creates a cycle since the arguments include the repo and memctx. cs |vr ||||<|Srr%rrrr%r& getfilectx sz(makecachingfilectxfn..getfilectxr%)rrr%rr&makecachingfilectxfn srcr)zGiven a context return a memfilectx for ctx[path] This is a convenience method for building a memctx based on another context. c s2|}|}t|||||||dSN)rrr|)r|rr~rr)r$rrrr|rr%r&r sz"memfilefromctx..getfilectxr%)rrr%rr&memfilefromctx s  rcr)zGiven a patch (e.g. patchstore object) return a memfilectx This is a convenience method for building a memctx based on a patchstore. c s:|\}}}|durdS|\}}t|||||||dSr)rr)r$rrr~r=r|rr patchstorer%r&r sz$memfilefrompatch..getfilectxr%)rrr%rr&memfilefrompatch s rcsbeZdZdZdZ     dfdd ZdddZdd Zed d Z ed d Z ddZ Z S)raNUse memctx to perform in-memory commits via localrepo.commitctx(). Revision information is supplied at initialization time while related files data and is made available through a callback mechanism. 'repo' is the current localrepo, 'parents' is a sequence of two parent revisions identifiers (pass None for every missing parent), 'text' is the commit message and 'files' lists names of files touched by the revision (normalized and relative to repository root). filectxfn(repo, memctx, path) is a callable receiving the repository, the current memctx object and the normalized path of requested file, relative to repository root. It is fired by the commit function for every file in 'files', but calls order is undefined. If the file is available in the revision being committed (updated or added), filectxfn returns a memfilectx object. If the file was removed, filectxfn return None for recent Mercurial. Moved files are represented by marking the source file removed and the new file added with copy information (see memfilectx). user receives the committer name and defaults to current repository username, date is the commit date in any format supported by dateutil.parsedate() and defaults to current date, extra is a dictionary of metadata or is left empty. TNc sttj|||||| dd_d_fdd|D}|\} } fdd| | fD_tt|}|_i_ t |t j rDt |}nt|sLt|}t|_| rd| jg_jjdSdS)Nrcsg|] }|p jjjqSr%rrr+r%r&rV1 rz#memctx.__init__..cr;r%r rr+r%r&rV3 r>)rrr'r7rrrr^_filesrvrr filestorercallablerr _filectxfnr!rsavecommitmessage) r#r$rrr filectxfnr rrrrrrrr+r&r' s(     zmemctx.__init__cCs||j||S)zpget a file context from the working directory Returns None if file doesn't exist and should be removed.)rr!rr%r%r&rEE rzmemctx.filectxcC |j|Szcommit context to the repor! commitctxr+r%r%r&commitK rz memctx.commitcCsn|jd}|}|jjD] }|jjj||<q|jjD] }|jjj ||<q|jj D] }||vr4||=q+|S)z;generate a manifest based on the return values of filectxfnr) rrKrrrjr!rbrcrkrbrl)r#rrrr%r%r&r@O s     zmemctx._manifestc s||jd}|tkr|fdd}nfdd}ggg}}}|jD]}||s:||q.||rD||q.||q.t|||ggggS)z?Calculate exact status from ``files`` specified at constructionrc|vp|vSrr%rman1man2r%r&rm z memctx._status..c|vSrr%rrr%r&ro  rrKrrZrrrarrLr#rmanagingrjrkrlrr%rr&rc s        zmemctx._statuscCs$|jdtkr|jdgS|jS)Nrr)rrZrr+r%r%r&r| s zmemctx.parents)NNNNNr) r2rrr_returnnoneformissingfilesr'rErrr@rrrfr%r%rr&r s   &  rcsReZdZdZ   dfdd ZddZdd Zd d Zdd d ZddZ Z S)rzpmemfilectx represents an in-memory file to commit. See memctx and committablefilectx for more details. FNcsDtt|||d|||_|rd|_n |rd|_nd|_||_dS)aQ path is the normalized file path relative to repository root. data is the file content as a string. islink is True if the file is a symbolic link. isexec is True if the file is executable. copied is the source file path if current file was copied in the revision being committed, or None.Nrrr)rrr'_datarx _copysource)r#r$rrr~rrr|rr%r&r' s zmemfilectx.__init__cCr}r)rr+r%r%r&r| r~zmemfilectx.copysourcecCrrrrr%r%r&rd r}zmemfilectx.cmpcCr}rrr+r%r%r&r~ r~zmemfilectx.datacCs|j|j=dS)r{N)rkrirr%r%r&r szmemfilectx.removecKs ||_dS)rNrr#r~rrr%r%r&rM rzmemfilectx.write)FFNr) r2rrrr'r|rdr~rrMrfr%r%rr&r s  rcsleZdZdZ      dfdd ZddZeddZdd d Zd d Z ed dZ e ddZ Z S)metadataonlyctxaLike memctx but it's reusing the manifest of different commit. Intended to be used by lightweight operations that are creating metadata-only changes. Revision information is supplied at initialization time. 'repo' is the current localrepo, 'ctx' is original revision which manifest we're reuisng 'parents' is a sequence of two parent revisions identifiers (pass None for every missing parent), 'text' is the commit. user receives the committer name and defaults to current repository username, date is the commit date in any format supported by dateutil.parsedate() and defaults to current date, extra is a dictionary of metadata or is left empty. Nc s4|dur|}tt|||||d|_d|_||_||_|dur+| }n fdd|D}|dd}t |dkrM| t t |dks@|\} } |_ |j \} } | |jjjkrl| | krltd| |jjjkr}| | kr}td||_i|_|r||j|g|_|j|jdSdS)Ncsg|] }|dur|qSrr%rr$r%r&rV sz,metadataonlyctx.__init__..rz=can't reuse the manifest: its p1 doesn't match the new ctx p1z=can't reuse the manifest: its p2 doesn't match the new ctx p2)rrrr'r7r _originalctxr _manifestnoderrrarrrr!rbrJ RuntimeErrorrrrvrr) r#r$ originalctxrrr rrrrrmp1mp2rrr&r' s<       zmetadataonlyctx.__init__cCr}r)rr+r%r%r&r r~zmetadataonlyctx.manifestnodecCs|jj|jSr)r!rrr+r%r%r&r r1zmetadataonlyctx._manifestctxcCs|jj||dS)N)rD)rrErr%r%r&rE r}zmetadataonlyctx.filectxcCrrrr+r%r%r&r rzmetadataonlyctx.commitcCrr)rrKr+r%r%r&r@ rzmetadataonlyctx._manifestc s||jd}|tkr|fdd}nfdd}ggg}}}|jD]}||s:||q.||vrD||q.||q.t|||ggggS)zjCalculate exact status from ``files`` specified in the ``origctx`` and parents manifests. rcrrr%rrr%r&r rz)metadataonlyctx._status..crrr%rrr%r&r rrrr%rr&r s        zmetadataonlyctx._statusrr)r2rrrr'rrerrErr@rrrfr%r%rr&r s$0   rc@sReZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ dS)arbitraryfilectxzAllows you to use filectx-like functions on a file in an arbitrary location on disk, possibly not in the working directory. NcCs||_||_dSr)r!ri)r#rr$r%r%r&r') s zarbitraryfilectx.__init__cCsZd|vp d|v}|s%t|tr%|jr%t||j| S||kSr) rrrr!filecmprdrwjoinr~)r#rsymlinksr%r%r&rd. szarbitraryfilectx.cmpcCr}rrtr+r%r%r&r9 r~zarbitraryfilectx.pathcCr8rr%r+r%r%r&r< r:zarbitraryfilectx.flagscC t|jSrrreadfilerir+r%r%r&r~? r-zarbitraryfilectx.datacCrrrr+r%r%r&rB r-zarbitraryfilectx.decodeddatacCst|jdSr)rrrir+r%r%r&rE r}zarbitraryfilectx.removecKs|rJt|j|dSr)r writefilerirr%r%r&rMH szarbitraryfilectx.writer) r2rrrr'rdrrr~rrrMr%r%r%r&r$ s   r)< __future__rr/rrr"i18nrr*rrrrrr r r r r rrrlrrrrrrrrrrrrutilsrr dirstateutilsrrobjectrrrgrErrrorrrrrrrrrrrr%r%r%r&s^   P @.>~*@^&8,4n