^cddlZddlZddlZddlZddlZddlZddlZddlZddlZ ddl m Z ddl m Z mZmZddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddl!m"Z"m#Z#m$Z$m%Z%da&ej'Z'ej(Z(ej)Z)ej*Z*dZ+dZ,Gd d ej-Z.d Z/d Z0d Z1dZ2ddddZ3dZ4ddZ5dZ6GddZ7Gdde7Z8Gdde7Z9Gdde7Z:e8e9e:dZ;dS)N)_)binhexshort)cmdutilencodingerrorexchange logcmdutilmatchmergepathutilphasespycompatscmutil subrepoutilutilvfs)dateutilhashutilprocutilurlutilctjtj|}tj|}|js+tjtj|j}|S)zU get a path or url and if it is a path expand it and return an absolute path ) r urllocalpathr expandpathurlschemenormpathabspathpath)r! expandedpathus 3/usr/lib/python3/dist-packages/mercurial/subrepo.py_expandedabspathr%7sW'(=(=>>L L!!A 83}T\!&1122 Kcttjt|ddS)zEget a unique filename for the store hash cache of a remote repositoryr )rrsha1r%digest) remotepaths r$_getstorehashcachenamer,Bs8 x}-j99::AACC D DQrT JJr&ceZdZdZdZdS) SubrepoAbortzEException class used to avoid handling a subrepo error more than oncec|dd|_|dd|_tjj|g|Ri|dS)Nsubrepocause)popr0r1r Abort__init__)selfargskws r$r4zSubrepoAbort.__init__JsUvvi.. VVGT**  T/D///B/////r&N)__name__ __module__ __qualname____doc__r4r&r$r.r.Gs)OO00000r&r.cfd}|S)Nc |g|Ri|}n{#t$r}|d}~wtj$rZ}t|}|jdzt d|zz}t||j|tjd}~wwxYw|S)N s(in subrepository "%s"))hintr0r1) r.r r3 subrelpathmessagerr@sysexc_info)r5r6kargsresexr0errormsgfuncs r$decoratedmethodz-annotatesubrepoerror..decoratedmethodQs $t,d,,,e,,CC   H{    &&G T!A&@$A$AG$KK rws|~~    s  BBABBr<)rIrJs` r$annotatesubrepoerrorrKPs$" r&c|r#tdt|||fz}n"tdt|||fz}||dS)Ns subrepository sources for %s differ you can use (l)ocal source (%s) or (r)emote source (%s). what do you want to do?$$ &Local $$ &Remotes subrepository sources for %s differ (in checked out version) you can use (l)ocal source (%s) or (r)emote source (%s). what do you want to do?$$ &Local $$ &Remoter)rrA promptchoice)uisubdirtylocalremotemsgs r$ _updatepromptrTesz - $  __eV , - $  __eV , - ??3 " ""r&c|D]\}}}t|D]"\}}||kr||=n#||dkrd|D]{}|dkra|t d||z|||||dS)Ns.hghgrcs5warning: removing potentially hostile 'hgrc' in '%s' ) walk enumeratelowerbasenamewarnrjoinunlinkreljoin) rNrignoredirnamedirsnamesidfs r$ _sanitizerfxs # 44udOO  DAqwwyyF""G# << & & ( (F 2 2  4 4AwwyyG##%hhw'' ( 3;;w22333 444r&cp|dsd|vstj||kr$tjt d|zt j|j||j |r$tjt d|zdS)N~$+subrepo path contains illegal component: %ss$subrepo '%s' traverses symbolic link) startswithrrr r3rr pathauditorrootwvfsislink)repor!s r$_auditsubrepopathrqs t  0E0E0M0Mk < = = D   $H##D))) yMk!CDDtKLLLMMr&TF)hggitsvnc|ddds0tjtdtdt|d}|dd|z|s3tjtd |ztd|t vr$tjtd |zdS) NsubrepossallowedTssubrepos not enableds)see 'hg help config.subrepos' for detailsr@Fs %s:alloweds%s subrepos not allowedsunknown subrepo type %s) configboolr r3rSUBREPO_ALLOWED_DEFAULTSgettypes)rNkinddefaults r$ _checktyper~s ==j$ 7 7 k % & &?@@    '**477G ==md&:G D D k ( ) )D 0?@@     5k!677$>???r&cBddlm}|a|}t|||j|}t |j|d|r$|d|||df}t|d|||dd|S)z>return instance of the right subrepo class for subrepo in pathrhgrN) rrprqsubstater~rNsubrevr{)ctxr! allowwdir allowcreatehrpstates r$r0r0s B 88::DdD!!! L Etwa!!!7q3::d++U1X6 q?3eBQBi = ==r&cddlm}|a|}t|||j|}t |j|dd}|ddkrd}t|d|||d|fdS) z=return an empty subrepo in pctx for the extant subrepo in ctxrrrr&rrs(0000000000000000000000000000000000000000rT)rrrprqrr~rNr{)rr!pctxrrprrs r$ nullsubrepors B 88::DdD!!! L Etwa!!! F Qx5 q?4a&'94 @ @@r&ceZdZdZdZdZd(dZd(dZd)dZd Z d Z d Z d Z d Z d*dZdZdZdZdZdZdZdZdZdZdZdZdZd+dZdZd,dZdZd Zd!Z d"Z!d#Z"d$Z#d*d%Z$e%d&Z&e%d'Z'dS)-abstractsubrepoc^|j|_||_||_dS)zInitialize abstractsubrepo part ``ctx`` is the context referring this subrepository in the parent repository. ``path`` is the path to this subrepository as seen from innermost repository. N)rprN_ctx_path)r5rr!s r$r4zabstractsubrepo.__init__s'((**-  r&cdS)zAdd the hgwebdir entries for this subrepo, and any of its subrepos. ``serverpath`` is the path component of the URL for this repo. ``webconf`` is the dictionary of hgwebdir entries. Nr<r5 serverpathwebconfs r$ addwebdirpathzabstractsubrepo.addwebdirpaths  r&cdS)z returns true if the repository has not changed since it was last cloned from or pushed to a given repository. Fr<r5r!s r$ storecleanzabstractsubrepo.storecleans ur&Fct)a returns true if the dirstate of the subrepo is dirty or does not match current stored state. If ignoreupdate is true, only check whether the subrepo has uncommitted changes in its dirstate. If missing is true, check for deleted files. NotImplementedErrorr5 ignoreupdatemissings r$rPzabstractsubrepo.dirtys "!r&cr|||rtdt|zSdS)zreturn reason string if it is ``dirty()`` Returned string should have enough information for the message of exception. This returns None, otherwise. rrs)uncommitted changes in subrepository "%s"N)rPrrArs r$ dirtyreasonzabstractsubrepo.dirtyreasonsM ::<: A A ABBZFF   r&Ncd||d}|rtj||dS)z+raise Abort if subrepository is ``dirty()``TrrwN)rr r3)r5rr@rs r$ bailifchangedzabstractsubrepo.bailifchangedsA&&L$&OO  6+k555 5 6 6r&ct)zpcurrent working directory base state, disregarding .hgsubstate state and working directory modificationsrr5s r$ basestatezabstractsubrepo.basestates "!r&cdS)z7check if path is a subrepository within this repositoryFr<rs r$ checknestedzabstractsubrepo.checknestedsur&ct)zcommit the current changes to the subrepo with the given log message. Use given user and date if possible. Return the new state of the subrepo. r)r5textuserdates r$commitzabstractsubrepo.commit! "!r&ctjS)z6returns phase of specified state in the subrepository.)rpublicr5rs r$phasezabstractsubrepo.phase(s }r&ct)zTremove the subrepo (should verify the dirstate is not dirty first) rrs r$removezabstractsubrepo.remove,rr&ct)zTrun whatever commands are needed to put the subrepo into this state r)r5r overwrites r$rzzabstractsubrepo.get3s "!r&ct)z/merge currently-saved state with the new state.rrs r$rzabstractsubrepo.merge9!!r&ct)zhperform whatever action is analogous to 'hg push' This may be a no-op on some systems. rr5optss r$pushzabstractsubrepo.push=rr&c gSNr<r5rNr prefixuipathfn explicitonlyrs r$addzabstractsubrepo.addDs r&c^|jd|tdfzdS)Ns%s: %ssaddremove is not supportedrrNr[r)r5matcherrrrs r$ addremovezabstractsubrepo.addremoveGs.  Y&!,I*J*J!KKLLLqr&c dSNrr<)r5r fm fntemplaterrs r$catzabstractsubrepo.catKqr&c 6tjgggggggSr)rstatus)r5rev2rs r$rzabstractsubrepo.statusNs~b"b"b"b999r&c dSrr<)r5rNdiffoptsnode2r rrs r$diffzabstractsubrepo.diffQs r&cdSrr<)r5rNdestrs r$outgoingzabstractsubrepo.outgoingTrr&cdSrr<)r5rNsourcers r$incomingzabstractsubrepo.incomingWrr&ct)zreturn filename iteratorrrs r$fileszabstractsubrepo.filesZrr&ct)z9return file data, optionally passed through repo decodersrr5namedecodes r$filedatazabstractsubrepo.filedata^rr&cdS)zreturn file flagsr&r<)r5rs r$ fileflagszabstractsubrepo.fileflagsbssr&c,tj|S)z,Resolve the fileset expression for this repobadfn)matchmodnever)r5cwdexprrs r$ matchfilesetzabstractsubrepo.matchfilesetfs~E****r&cdS)z)handle the files command for this subreporr<)r5rNmrrfmtsubreposs r$ printfileszabstractsubrepo.printfilesjsqr&Tc J!fd|D}n|}t|}t|}|jt d|zt d|}|d|D]f} || } d| vrdpd} d | v} ||| z| | | | || g| |S) Nc*g|]}| |Sr<r<.0rer s r$ z+abstractsubrepo.archive..ps&9991a9Q999r&archiving (%s)files)unittotalrxiil) rlenrArN makeprogressrupdateraddfiler incrementcomplete) r5archiverrr rrrrelpathprogressrflagsmodesymlinks ` r$archivezabstractsubrepo.archivens9  9999 999EEJJLLEE T""7''  7 *8E(    ! !DNN4((E5=*U3eDemG    tWdmmD&.I.I        r&cdS)zv walk recursively through the directory tree, finding all files matched by the match function Nr<)r5r s r$rWzabstractsubrepo.walkr&c ggfSrr<r5r rrdryrun interactives r$forgetzabstractsubrepo.forgets Bxr&c Z|td|jzdS)zremove the matched files from the subrepository and the filesystem, possibly by force and/or after the file has been removed from the filesystem. Return 0 on success, 1 on any warning. s)warning: removefiles not implemented (%s)r)appendrr r5rrrafterforcerrwarningss r$ removefileszabstractsubrepo.removefiless4  : ; ;dj H   qr&cv|jtd|d|dfzgS)Ns)%s: reverting %s subrepos is unsupported rrrr5rpatsrs r$revertzabstractsubrepo.revertsB  ; < <{HQK( )    r&c|Srr<r5revids r$shortidzabstractsubrepo.shortids r&cdS)zH convert this repository from shared to normal storage. Nr<rs r$unsharezabstractsubrepo.unsharer r&cdS)a1verify the revision of this repository that is held in `_state` is present and not hidden. Return 0 on success or warning, 1 on any error. In the case of ``onpush``, warnings or errors will raise an exception if the result of pushing would be a broken remote repository. rr<)r5onpushs r$verifyzabstractsubrepo.verifys qr&ctj|jj|jS)z@return vfs to access the working directory of this subrepository)vfsmodrrrprnr\rrs r$rnzabstractsubrepo.wvfss3z$)..**/44TZ@@AAAr&c|jt|j|jSzCreturn path to this subrepository as seen from outermost repository)rnr^ reporelpathrrprrs r$_relpathzabstractsubrepo._relpaths2y  TY^^-=-=!>!> KKKr&FF)FNFrNT)(r8r9r:r4rrrPrrrrrrrrzrrrrrrrrrrrrrrr rWrrrr r"r% propertycachernr+r<r&r$rrss      """"    6666 """ """""""""" """""":::   """"""++++,   (   BB]BLL]LLLr&rceZdZfdZedZdZdZdZe dZ dZ dZ d Z ed Zed Zed Zed ZedZedZed/dZed0dZdZdZedZedZedZdZed1dZedZedZedZedZ ed Z!d!Z"d"Z#ed#Z$ed2d$Z%d%Z&ed&Z'ed'Z(ed(Z)d)Z*d*Z+ed+Z,d1d,Z-e d-Z.e d.Z/xZ0S)3 hgsubrepoctt|||||_|}|t j|}|o|j d|z }tj |}tj tj t j|} | |kr$tjt#d|zt$|j|||_tj |jjtj |kr#tjd||jjfz||ur|j|_|jj|_dD]?\} } |j| | } | r|j| | | d@|jddd d|||d |dS) Ns%s/.hgrjcreates9failed to reject unsafe subrepo path: %s (expanded to %s)))uiscommitsubrepossubrepor5s_usedassubreposTruer)superr1r4_staterpwjoinr localpathrnexistsosr!normcaserealpathrr r3rr repositorybaseui_repormProgrammingError unfilteredrNconfig setconfig _initrepo)r5rr!rrrrmr4 norm_root real_rootskv __class__s r$r4zhgsubrepo.__init__s i''T222 HHJJwwt~d++,,DQV]]9t3C%D%D!DG$$T** G$$RW%5%5dod6K6K%L%LMM  ! !+@AADH ]]18T&]AA 7  DJO , ,0@0@0F0F F F(-04djo/FG     ..00DJ*-0 7 7DAq Aq!!A 7!!!Q:666 %!2GZHHH q%(F+++++r&cVtj|jt||dSr)rrrArArs r$rzhgsubrepo.addwebdirpaths'dj*T*:*:GDDDDDr&c|j5||cdddS#1swxYwYdSr)rAlock _storecleanrs r$rzhgsubrepo.storecleans Z__   * *##D)) * * * * * * * * * * * * * * * * * *s<AAcd}||}||D]}|t|dkrd}n|rt|ddu}|S)NTF)_calcstorehash_readstorehashcachenext)r5r!clean itercachefilehashs r$rQzhgsubrepo._storecleans''-- 0066  H4 400001  2D))T1E r&c#Kd}dt|zV|jj}|D]Q}tt j||}d||fzVRdS)zcalculate a unique "store hash" This method is used to to detect when there are changes that may require a push to a given remote path.)s bookmarkssstore/phaserootssstore/00changelog.is# %s %s = %s N)r%rArrrr)tryreadr*)r5r+filelistrrelnamerXs r$rSzhgsubrepo._calcstorehashs O*:666666jn 5 5G8=W)=)=>>EEGGHHH'8!44 4 4 4 4 5 5r&cdtj|jjdS)Nscache/storehash)r'rrAr\rs r$_cachestorehashvfszhgsubrepo._cachestorehashvfss%z$*.--.@AABBBr&cVt|}|j|dS)z7read the store hash cache for a given remote repositoryr)r,r_ tryreadlines)r5r+ cachefiles r$rTzhgsubrepo._readstorehashcache s(*:66 &33ItDDDr&c t|}|j5t||}|j}|||ddddddS#1swxYwYdS)zcache the current store hash Each remote repo requires its own store hash cache, because a subrepo store may be "clean" versus a given remote repo, but not versus another swbT)r notindexedN)r,rArPlistrSr_ writelines)r5r+rc storehashrs r$_cachestorehashzhgsubrepo._cachestorehashs +:66 Z__   N NT00<<==I)C NN9ieN M M M N N N N N N N N N N N N N N N N N NsAA99A=A=c|j |jdS|jd}|j|S)zBfetch the context for this subrepo revision, possibly a workingctxNr)rrevrAr8)r5rks r$_getctxzhgsubrepo._getctxs6 9==?? ":d# #+a.C:c? "r&ct|j_|j_|rdgfd}tjd}tjdd}|d|||kr |d|jjdt jd dSdS) Ns[paths] c~|r9d||fzjd||ddSdS)NrZspathsr6)rrNrE)keyvaluelinesr5s r$ addpathconfigz*hgsubrepo._initrepo..addpathconfig-sUHLLe !<===G%%hUJGGGGGHHr&F)abortTsdefaults default-pushrVr&) rA _subparent _subsource _abssourcerwriter tonativeeolr\)r5 parentreporr4rrdefpath defpushpathrqs` @r$rFzhgsubrepo._initrepo%s *  &   M!NE H H H H H H !5999G$TZUCCCK M*g . . .+%% o{;;; JN $*:388E??*K*K L L L L L M Mr&c :tj||j||||fi|Sr)rrrArs r$rz hgsubrepo.add:s2{  E68\  EI   r&cntj|}d|d<tj|j||||S)NTrv)copyrrrA)r5rrrrs r$rzhgsubrepo.addremove@s6 y [ Q$GGGr&c z|jd}|j|}tj|j|j|||||fi|Sr)r8rArrrN)r5r rrrrrkrs r$rz hgsubrepo.catIsLk!njo{ GTZeRV  GK   r&c X |jd}|j|}|j|}|jj||fi|S#tj$r]}|jtd|t|fztjgggggggcYd}~Sd}~wwxYw)Nr*warning: error "%s" in subrepository "%s" ) r8rArr RepoLookupErrorrNr[rrAr)r5rrrev1ctx1ctx2insts r$rzhgsubrepo.statusQs >;q>D:d#D:d#D$4:$T488488 8$ > > > GLL@AAD))*+   >"b"b"b"== = = = = = =  >s:=B) AB$B)$B)c t t|jd}|t|}tj||j||j||j||f|dd|dS#t j$rD}|jtd|t|fzYd}~dSd}~wwxYw)NrT)r listsubreposr) rr8r diffordiffstatrAr rrNr[rrA) r5rNrrr rrnode1rs r$rzhgsubrepo.diff_s  A''E E   %  5! 5! !       $    GLL@AAD))*+          sA A$$B739B22B7NTc,||jdz|}rfd|D}|jd}|j|}t j|j|t j|j|fgt |||}|j D]K} t|| d} tj | } || zdz} || || | |z }L|S)N)rrc*g|]}| |Sr<r<rs r$rz%hgsubrepo.archive..}s&2221q2Q222r&rT/)_getr8rrAr prefetchfilesrk matchfilesrr rr0r subdirmatcher) r5rrr rrrkrrsubpathrJsubmatch subprefixs ` r$r zhgsubrepo.archivexs $+()))   32222222Ek!njo J#''))W%7 E%J%JKL    ''hFF| F FGWd++A-gu==H(4/I QYYxHfEE EEE r&Fc|jd}|dkr|sdS|jd}||kr|sdS||S)Nrr&T)r)r8rAp1rrP)r5rrrGws r$rPzhgsubrepo.dirtysd KN 88L84 Jt    \ 4wwww'''r&c@|jdSN.)rArrs r$rzhgsubrepo.basestatesz$##%%%r&cf|j|j|Sr)rA _checknestedr9rs r$rzhgsubrepo.checknesteds(z&&tz'7'7'='=>>>r&cV|ds|jdS|jdt |z|j|||}|s|jdSt|S)NTrscommitting subrepo %s )rPrArrNdebugrAr)r5rrrns r$rzhgsubrepo.commitszz$ *:d#'')) )  0:d3C3CCDDD J  dD$ / / *:d#'')) )1vv r&cD|j|pdSr)rArrs r$rzhgsubrepo.phasesz%-4(..000r&c|jtdt|zt|j|jjddS)Nremoving subrepo %s F)rNnoterrArrVrAnullidrs r$rzhgsubrepo.removesQ  Q/00:d3C3CCDDD TZ.66666r&c|\}}}jj}|jvr.tjdks|sdS|j_t jfd}tjdkr~jj|rt rʼnj tdtfz|} tjjj|jjdd}|n#|wxYw|_n?|rPj dd} | rt+j| } | j dd d } ni} j td tt/jfz|} tjjji|jjd| \} } |n#|wxYw| _||d nʉj tdtt/jfz} |} t;jj||n#|wxYw| rdS)NrTcFtjiSr)rpeerrA)r5srcurlsr$z hgsubrepo._get..s"''$*b&99r&ssharing subrepo %s from %s F)r bookmarksssharepools poolnaming)rsmodecloning subrepo %s from %s )r shareoptsr3pulling subrepo %s from %s )rArtrCrsharedrurvrrmtreerislocalrNrrrAsharer@rmcloserQrDrrr hidepasswordclonerFrirr pull)r5rrrevisionr|rygetpeerrrpoolrotherclonedcleansubrs` @r$rzhgsubrepo._gets!&$Z* tz,,.. . .4:!##:+<+<+>+>#t & DJ'':9999 tz??a   JN ! ! # # #  ""0 ,rzz&'9'90 ,566!$''01wyy !XX -4 $"' &FJJLLLLDJJLLLL#\\^^ $$&& #7>>(G<