^cXddlZddlmZddlmZmZmZddlmZddl m Z m Z m Z mZm Z mZmZmZddlmZmZdZd Zd Zd ZGd d ZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$d0dZ%dZ&dZ'ej(dZ)dZ*dZ+d Z,d1d"Z- d2d#Z.d0d$Z/d%Z0d&Z1d'Z2d(Z3d)Z4d3d+Z5d4d,Z6d-Z7d0d.Z8d/Z9dS)5N)_)binhexshort)getattr)encodingerrorobsutilpycompat requirementsscmutiltxnutilutil) stringutilurlutils"bookmarks.active bookmarks.currentc(tj|jvSN)r BOOKMARKS_IN_STORE_REQUIREMENTrepos 5/usr/lib/python3/dist-packages/mercurial/bookmarks.pybookmarksinstorer(s  6$:K KKc<t|r|jn|jSr)rsvfsvfsrs r bookmarksvfsr,s(.. <499DH'0" D!! V"D::<> 1&.&6w&?&?G.2F7O$+KK$5$5E$}18  % W 5 5 5#(9w#6#6$)JJLLL%    )9 +D11C,BM ;<<,h.>t.D.DEF %               @!    D "4.. s\FE9.BD  E9 AE)%E9(E))E9- F9E==FE=F FFc|jSr)r?r@s ractivezbmstore.activexs |rc\|||jvrtd|z||_d|_dS)Nsbookmark %s does not exist!F)r,AssertionErrorr?r/r@marks rrNzbmstore.active|s:  DL 8 8 !?$!FGG G  rc*t|jSr)lenr,rMs r__len__zbmstore.__len__s4<   rc*t|jSr)iterr,rMs r__iter__zbmstore.__iter__sDL!!!rc4|jSrr,itemsrMs r iteritemszbmstore.iteritems|!!###rc4|jSrrZrMs rr[z bmstore.itemsr]rc4|jSr)r,keysrMs rr`z bmstore.keyss|  """rc4|jSr)r,valuesrMs rrbzbmstore.valuess|""$$$rc||jvSrr,rQs r __contains__zbmstore.__contains__st|##rc|j|SrrdrQs r __getitem__zbmstore.__getitem__s|D!!rNc8|j||Sr)r,r6)r@rRdefaults rr6z bmstore.gets|g...rcd|_||jvr||||j|<|j|}| |g|j|<dS|||dS)NF)r.r,_delr-r6r7r8r@rRrHrIs r_setz bmstore._sets 4<   IIdOOO! T !!$'' =#'&DM$    LL    JJLLLLLrc||jvrdSd|_|j|}|j|}t |dkr|d|ksJ|j|=dS||dS)NFrr)r,r.popr-rTremoverls rrkz bmstore._dels t| # # F |%% d# u::??8t#### d### LL     rc8|j|gS)z@Return a sorted list of bookmarks pointing to the specified node)r-r6)r@rHs rnamesz bmstore.namess}  r***rcT|jd}|D]u\}}|j|}|||n||||&||}||d}||f||<v||dS)z$Apply a list of changes to bookmarksr Nr)changesr6r,rkrm _recordchange) r@rtrrt bmchangesnamerHoldpreviouss r applychangeszbmstore.applychangessJNN<00 ! . .JD$,""4((C| $ $%%%$$==..'"1+C#&+ $ 2rct|jrdnd}|dd|j|dd|jd<d S) zrecord that bookmarks have been changed in a transaction The transaction is then responsible for updating the file content.rsplainr )r T)location post_finalize1sbookmark_movedN)rr+addfilegenerator_writehookargs)r@rvr}s rruzbmstore._recordchanges_+4:66D33H    K    *. %&&&rc|j}|j|jvrd|_|t |r|j}|}n|j}|}|5|dddd5}| |dddn #1swxYwYddddS#1swxYwYdS)zFactored out for extensibilityNr wT atomictemp checkambig) _bookmarksrNr, _writeactiverrlockrwlockr)r@rrbmrrfs r _writerepozbmstore._writereposOo :T\ ) )CJ       D ! ! )C99;;DD(C::<GGH.t|<<===>>>>>>>>>>>>>>>  (()=>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? s5&B9 -B6 B9B B9 B #B99B=B=ct|jD]>\}}|dt |t j|fz?d|_|j dS)Ns%s %s T) sortedr,r[rrr rr.r+invalidatevolatilesets)r@r#rxrHs rrzbmstore._writes~ !3!3!5!566 I IJD$ HHZ3t99h.@.F.F"GG H H H H  ))+++++rcp|dkr/|jr|jStjtd|S)N.sno active bookmark)rNr RepoLookupErrorr)r@bnames r expandnamezbmstore.expandnames= D=={ F{"+A.C,D,DEEE rFc jd}jvrs|sprIjkr|krgSj}jj|g j}fdjD}| vr|vrt jgS fd|D}t j|} tj|jrRjj tdt|fz| Stj tdzjvs"jjkr#|s!tj tdt#dkrf|sd t%jj} n#tj$rd} YnwxYw| r/jjtd zgS) acheck repo for a potential clash of mark with an existing bookmark, branch, or hash If target is supplied, then check that we are moving the bookmark forward. If force is supplied, then forcibly move the bookmark to a new commit regardless if it is a move forward. If divergent bookmark are to be deleted, they will be returned as list. rcg|]I}|ddddddk<j|JS@rr)r4r,).0brRr@s r z)bmstore.checkconflict..sZwwtQ''*djjq.A.A!.DDDLODDDrcbg|]+}j|vs|k)|,S)r+rev)rrancr@targets rrz)bmstore.checkconflict..*sAtz!}'8'8':':c'A'AQ&[[A[[[rs%moving bookmark '%s' forward from %s s.bookmark '%s' already exists (use -f to force)s5a bookmark cannot have the name of an existing branchFs[bookmark %s matches a changeset hash (did you leave a -r out of an 'hg bookmark' command?) )r+rHr,rr0 ancestorsdivergent2delete validdestr:statusrrr Abort branchmapdirstatebranchrTr isrevsymbol LookupErrorr;) r@rRforcercurrbmctxdivs deletefromdelbms shadowhashrs `` ` @r checkconflictzbmstore.checkconflict sj##%% 4<    "<%//FcMMIj(,,..j*44cU;; 4:.!\99;;c))fnn+DJ$GGG# *$*j$GGTZ 60BCC"JM((CDDuzz||!4!456"M+CDDtK  DJ((** * *tz*1133334+JKK  t99q=== #$0TBB $ # # #"  #  ""'   sH22IIr)FN)__name__ __module__ __qualname____doc__rKpropertyrNsetterrUrXr\r[r`rbrergr6rmrkrrr{rurrrrrrrrr'r'=s  +/+/+/ZX ]]!!!"""$$$$$$### %%%$$$"""////      +++" . . ."   ,,, CCCCCCrr'c|jd}tjt j|}|dks||vrd}|S)z Get the active bookmark. We can have an active bookmark that updates itself as we commit. This function returns the name of that bookmark. It is stored in .hg/bookmarks.current rrN)rtryreadr r5r firstline)rmarkscontentrRs rr>r>OsRh344G  J099 : :D s{{d%'' KrcP||j_|jdS)z Set the given bookmark to be 'active', meaning that this bookmark will follow new commits that are made. The name is recorded in .hg/bookmarks.current NrrNrrrRs ractivater^s( "DOO  """""rcPd|j_|jdS)z7 Unset the active bookmark in this repository. Nrrs r deactivaterhs("DOO  """""rc|j}|j}d|dD}||vo |||vS)a Tell whether the 'active' bookmark (the one that follows new commits) points to one of the parents of the current working directory (wdir). While this is normally the case, it can on occasion be false; for example, immediately after a pull, the active bookmark can be moved to point to a place different than the wdir. This is solved by running `hg update`. c6g|]}|Sr)rH)rps rrz&isactivewdirparent..{s 666Aqvvxx666rN)_activebookmarkrparents)rrRrrs risactivewdirparentrpsN  D OE66d!3!3!5!5666G 5= 3U4[G33rcg}|j}fd|D}|D]4}|dksd|vr |r%|||vr|kr||5|S)zZfind divergent versions of bm on nodes in deletefrom. the list of bookmark to delete.cg|]>}|ddddddk<|?Srr4)rrbms rrz$divergent2delete..sPAGGD!,,Q/288D!3D3DQ3GGGGGGrr)rr7)rrrtodeleter divergentrRs ` rrrsH OEI&& 4<<4t++   &E$K:--rzz%%% Orc |jstd|jddd}g}|jD]:\}}|ddd|kr||;|S)avGiven a repo with an active bookmark, return divergent bookmark nodes. Args: repo: A repository with an active bookmark. Returns: A list of binary node ids that is the full list of other revisions with bookmarks divergent from the active bookmark. If there were no divergent bookmarks, then this list will contain only one entry. s9headsforactive() only makes sense with an active bookmarkrrr)rr9r4rr[r7)rrxheadsrRns rheadsforactivers    H      % %dA . .q 1D E?((**a ::dA  q !T ) ) LLOOO Lrcd\}}|j}t|r|d}n)|r'|t d|z|}||fS)zReturn a tuple (activemark, movemarkfrom) indicating the active bookmark and where to move the active bookmark from, if needed.)NNrsupdating to active bookmark %s )rrrHrr)r:rcheckout movemarkfrom activemarks rcalculateupdaterss(Hl%J$Dz((  !788:EFFF l ##rc |}j jsdSg} |vr|  fd D}j g fd|D}t  r)| ft|D]}||df|rp 5 d5} ||dddn #1swxYwYdddn #1swxYwYt|S)NFcg|]J}|ddddddk<|KSrr)rrrNrrs rrzupdate..s\   wwtQ"fll4&;&;A&>>> qN>>>rcpg|]2}|vs|k|3Sr)rrH)rrrnews rrzupdate..s6KKK13!s((affhh(((rbookmark) rrNr0rrrr7rHrr transactionr{bool) rrrHrrwrrrvrNrrrs ` @@@@rupdatersJ OE \F uI V}4j          n&& {33KKKKKKKK T4f . 4 4 3   fchhjj1 2 2 2tZ88%%"d$$$$4 YY[[ 4 4$**;77 42   tR 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4  ??s6ED;/ E;D? ?ED? EEEc6d|vo|d S)Nr)endswith)rs r isdivergentrs 19 -QZZ----rc#Kt|di}|jj}|D]%\}}||rt |s||fV&dS)Nr)rr0hasnoder[r)rrrkvs rlistbinbookmarksrss D, + +En$G 1 71:: k!nn Q$JJJrcXi}t|D]\}}t|||<|Sr)rr)rdbookrHs r listbookmarksrs8 A&t,, dd))$ Hrc 2t|rdSt|rtj}n|}|5|5|d5}|j}t| |d}||kr*||kr$ ddddddddddS|dkr|dfg}nE||vr$ ddddddddddS||| fg}| ||| ddddddddddS#1swxYwYdddn #1swxYwYddddS#1swxYwYdS)NFr rT) rrrnullcontextmanagerrrrrrr6rHr{) rkeyryrrrvrexistingrts r pushbookmarkrs3u'))      T--l;; ruyyc**++ s??x3                     #::T{mGG$                    T#Y^^--./G 4W---                                                             s F  E468E. E49 F E" E4- F 5E: E4 F E! !E4$E! %E4( F 4E8 8F ;E8 <F  FFc|rt|}n#t|}t|}||z}ggggggggf}|dj}|dj} |dj} |dj} |dj} |dj} |dj}|dj}t|D]}||vr(||vr| |d ||f ||d d f/||vr||||d fH||}||}||kr||||fm||vr||vr||}||}||kr/t |||r| |||f| |||ft |||r| |||f| |||f| |||f|S) aCompare bookmarks between srcmarks and dstmarks This returns tuple "(addsrc, adddst, advsrc, advdst, diverge, differ, invalid)", each are list of bookmarks below: :addsrc: added on src side (removed on dst side, perhaps) :adddst: added on dst side (removed on src side, perhaps) :advsrc: advanced on src side :advdst: advanced on dst side :diverge: diverge :differ: changed, but changeset referred on src is unknown on dst :invalid: unknown on both side :same: same on both side Each elements of lists in result tuple is tuple "(bookmark name, changeset ID on source side, changeset ID on destination side)". Each changeset ID is a binary node or None. Changeset IDs of tuples in "addsrc", "adddst", "differ" or "invalid" list may be unknown for repo. If "targets" is specified, only bookmarks listed in it are examined. rrrN)setr7rrr)rsrcmarksdstmarkstargetsbset srcmarkset dstmarksetresultsaddsrcadddstadvsrcadvdstdivergedifferinvalidsamersciddcidsctxdctxs rcomparebookmarksrsV4'7||]] ]] J&2r2r2r2.G QZ F QZ F QZ F QZ FajG QZ FajG 1: D D\\(( H  H}}4!-....D$(((( h   FAx{D) * * * *A;DA;Dt||at_%%%%$$,,DzDz88:: ** tT2214////D$0000 tT2214////D$00004'''' Nrc|dkrd}|drtj|j}tj|D]I\}}|j}|drtj|j}||kr d||fzcSJt ddD]}d||fz} | |vs || |kr| cSdS) zReturn appropriate diverged bookmark for specified ``path`` This returns None, if it is failed to assign any divergent bookmark name. This reuses already existing one with "@number" suffix, if it refers ``remotenode``. rrsfile:s%s@%srds%s@%dN) startswithrurlpath list_pathsrawlocrange) r:rr localmarks remotenoderxrlocxrs r_diverger!Ms Dyy  x  &{4  %%b))((ah >>( # # (+c""'C 3;;q$i' ' ' ' 1c]] 1v  J  *Q-:"="=HHH#> 4rcbi}|D]\}}t|||<|Sr)r[r)rbinremotemarksrxrHs runhexlifybookmarksr$ls;Nkkmm)) d"4yyt rs>20sHc g}|D]c\}}|s |jj}|t|t |||dd|S)amencode a '(bookmark, node)' iterable into a binary stream the binary format is: :node: is a 20 bytes binary node, :bookmark-length: an unsigned short, :bookmark-name: the name of the bookmark (of length ) wdirid (all bits set) will be used as a special value for "missing" r) nodeconstantswdiridr7 _binaryentrypackrTjoin)r bookmarks binarydatarrHs r binaryencoder-vsJ  d -%,D,++D#d))<<===$ 88J  rctj}g} ||}t||kr$|r!t jt dnt|\}}||}t||kr#|r!t jt d||jj krd}| ||f|S)aodecode a binary stream into an '(bookmark, node)' iterable the binary format is: :node: is a 20 bytes binary node, :bookmark-length: an unsigned short, :bookmark-name: the name of the bookmark (of length )) wdirid (all bits set) will be used as a special value for "missing" Tsbad bookmark streamN) r(sizereadrTr rrunpackr&r'r7)rstream entrysizebooksentryrHlengthbookmarks r binarydecoder8s!I E ' I&& u:: ! ! =k!$:";";<<< #**511 f;;v&& x==6 ! ! =k!$:";";<<< 4%, , ,D h%&&& ' Lrc Rg}|j}|D]Q\}}|||dkr2||vr.||||jt d|zfR|D]4}||vr.||d|jt d|zf5|S)zMcomputes the bookmark changes that set the local bookmarks to remotemarksNupdating bookmark %s sremoving bookmark %s )rr[r6r7debugr)r:r remotemarkschangedrrids rmirroring_remoter?sGJ$$&&PPB 4(( ( (R4ZZ NNAr28Q/H-I-IA-MN O O O  K   NND"(A&?$@$@1$DE    Nrrc &|j}t|||\}}}} } } } } |j}|j}|ddr |jx}}t |}g}|D]\}}}||vr*||||td|zf4||vrQ| ||td|t|ddfz|D]/\}}}||||td|zf0| d|D| D]\}}}||vr?| |||||td |zfIt|||||}|r,||||td ||fzf|td |z|| zD]H\}}}||vr>| |||||td |zfI| D][\}}}||vrQ| ||td|t|ddfz\|S) zqcomputes the bookmark changes that merge remote bookmarks into the local bookmarks, based on comparebookmarkssuisquietbookmarkmovesadding remote bookmark %s s0remote bookmark %s points to locally missing %s N r:c3&K|] }|dV dS)rNr)rrs r z&merging_from_remote..s&55qt555555rsimporting bookmark %s s#divergent bookmark %s stored as %s sAwarning: failed to assign numbered name to divergent bookmark %s )rrrr; configboolr;rr7rrprdifference_updatediscardr!)r:rr<rexplicitrrr r r r r rrrr;r=rrrdbs rmerging_from_remoterIs[J {J77  YF 7D }}U011! 8}}HG   4 4<< NND&!$B"C"Ca"GH    (]] OOA    GGFGGc$iin%&     LL 44+D)E)E)IJKKKK 55W555555  4 ==   Q    NNAtVQ/I-J-JQ-NO P P P P"az488B ABBaWL 6  &QQ 4 ==   Q    NNAtVQ/I-J-JQ-NO P P P 4 == OOA    GGFGGc$iin%&    Nrcj|dkrdS|d|dkrt|||}nt|||||}|rh|}g} d} t|| D])\} } } }| | | f| |*|j||| dSdS)Nignoreschecking for updated bookmarks mirrorc&|d|dpdfS)Nrrrr)ts rz"updatefromremote..s1qt{s+r)r)r;r?rIrr7rr{)r:rr<rtrfuncrGmoder=rvrtrrrHwritermsgs rupdatefromremoterTs yHH 0111 y"2t[99%b$ T8LL8 VXX++$*7$<$<$<   AtVS NNAt9 % % % F3KKKK $$T2w7777788rc6|dkr$|tddS|td|5}t|dddi}dddn #1swxYwYg|jrd nd |jrfd }nfd }|d kr|j}t| t| z}t|D]} | | } | | } | | kr3| (|| t| td]| -|| t|jtd|| t| tdnt|||j} | \} }}}}}}}| D]-\} }}|| t|td.|D]-\} }}|| t|td.|D]-\} }}|| t|td.|D]-\} }}|| t|td.s$|tddStD]}||dS)z*Show bookmarks incoming from other to reporKs+bookmarks exchange disabled with this path r searching for changed bookmarks listkeys namespacer Nc|Srrr>s rrOzincoming..12rc|ddSNrArrZs rrOzincoming..32crc7rcPd|||fzdSNs %-25s %s %s r7rr>stgetid incomingss raddzincoming..add62   0AuuRyy"3EE F F F F FrcNd||fzdSNs %-25s %s rarbs rrfzincoming..add;/   -EE"II> ? ? ? ? ?rrLaddedsremovedchangedadvanceddivergedno changed bookmarks found r)rrcommandexecutorr$ callcommandresult debugflagverboserrr`rr6rnullidrr)r:rpeerrQer<rfrallmarksrrremrrr r r r r rrrrsrdres @@rincomingr|s y !CDDEEEqIIa455666     1( MM ,   fhh                  I |# "" z@ G G G G G G G  @ @ @ @ @ @ y_ {''))**S1B1B-C-CC!! 0 0A..##C//!$$CczzAs3xx8----As4;'':7777As3xx://// 0 T; @ @IJF$# + +MAtT C3t99akk * * * *# . .MAtT C3t99a nn - - - -$ . .MAtT C3t99a nn - - - -# - -MAtT C3t99a mm , , , ,  !344555q I    1s#8B''B+.B+c||tdt|d}t ||j|}|\}}}}} } } } g|jrdnd|jrfd} nfd} |D]-\}}}| |t|td.|D] \}}}| |dtd !|D]-\}}}| |t|td .| D]-\}}}| |t|td .| D]-\}}}| |t|td .s$|td dStD]}| |dS)z*Show bookmarks outgoing from repo to otherrVr c|SrrrZs rrOzoutgoing..qr[rc|ddSr]rrZs rrOzoutgoing..sr^rcPd|||fzdSr`rarr>rcrd outgoingss rrfzoutgoing..addvrgrcNd||fzdSrirars rrfzoutgoing..add{rjrrks( sdeletedrmrnrlrorr) rrr$listkeysrrrsrtrrr)r:rotherr<rzrr r r r r rrrfrrrr{rdrs @@routgoingrgsCIIa455666$U^^L%A%ABBKt <