
    6h[                       S SK Jr  S SKrSSKJr  SSKJrJrJr  SSK	J
r
JrJrJrJrJrJrJr  SSKJrJr  SrS	 rS
 rS r " S S5      rS rS rS rS rS rS rS r S r!S r"S r#S r$S r%S.S jr&S r'S r(\RR                  " S5      r*S r+S r,S  r-S/S! jr. S0S" jr/S.S# jr0S$ r1S% r2S& r3S' r4S( r5S1S) jr6S2S* jr7S+ r8S.S, jr9S- r:g)3    )annotationsN   )_)binhexshort)encodingerrorobsutilpycompatrequirementsscmutiltxnutilutil)
stringutilurlutils"   bookmarks.active bookmarks.currentc                <    [         R                  U R                   ;   $ N)r   BOOKMARKS_IN_STORE_REQUIREMENTrepos    5/usr/lib/python3/dist-packages/mercurial/bookmarks.pybookmarksinstorer   (   s    66$:K:KKK    c                R    [        U 5      (       a  U R                  $ U R                  $ r   )r   svfsvfsr   s    r   bookmarksvfsr   ,   s    (..499<DHH<r   c                `    [         R                  " U R                  [        U 5      S5      u  pU$ )zHook so that extensions that mess with the store can hook bm storage.

For core, this just handles wether we should see pending
bookmarks or the committed ones. Other extensions (like share)
may need to tweak this behavior further.
	   bookmarks)r   
trypendingrootr   )r   fppendings      r   
_getbkfiler%   0   s-     $$		<%|KB Ir   c                      \ rS rSrSrS r\S 5       r\R                  S 5       rS r	S r
S rS	 rS
 rS rS rS rSS jrS rS rS rS rS rS rS rS rS rSS jrSrg)bmstore=   a  Storage for bookmarks.

This object should do all bookmark-related reads and writes, so
that it's fairly simple to replace the storage underlying
bookmarks without having to clone the logic surrounding
bookmarks. This type also should manage the active bookmark, if
any.

This particular bmstore implementation stores bookmarks as
{hash}\s{name}\n (the same format as localtags) in
.hg/bookmarks. The mapping is stored as {name: nodeid}.
c           
     L   Xl         0 =U l        n0 =U l        nSU l        SU l        UR
                  R                  R                  n[        n [        U5       nU H  nUR                  5       nU(       d  M   UR                  SS5      u  pU" U5      n
U" U
5      (       ac  [        R                  " U	5      n	XU	'   UR                  U
5      nUc  U	/X:'   M{  UR                  U	5        US   U	:  a  UR!                  5         M  M  M     S S S 5        [3        X5      U l        g ! ["         aV    Sn[%        U5      (       a  SnUR&                  R)                  [+        S5      U[,        R.                  " U5      4-  5         GM%  f = f! , (       d  f       N= f! [0         a     Nf = f)NT    r   s   .hg/bookmarkss   .hg/store/bookmarkss   malformed line in %s: %r
)_repo_refmap_nodemap_clean_aclean	changelogindexhas_noder   r%   stripsplitr	   tolocalgetappendsort
ValueErrorr   uiwarnr   r   bytestrFileNotFoundError_readactive_active)selfr   refmapnodemapr3   tonodebkfilelinesharefspecnodenrefsbookmarkspaths                r   __init__bmstore.__init__K   s   
 ""v"$$>>''00"	D!V"D::<D '+zz$':%c{#D>>&.&6&6w&?G.27O$+KK$5E$}18	 %W 5#(9w#6$)JJL $7 * # "D #4. &  )9+D11,BM;<,h.>.>t.DEF ' "!@ ! 		sb   F F9AD"F*D"F	F "AF=FFF
FF F 
F#"F#c                    U R                   $ r   )r@   rA   s    r   activebmstore.activex   s    ||r   c                ^    Ub  XR                   ;  a  [        SU-  5      eXl        SU l        g )Ns   bookmark %s does not exist!F)r-   AssertionErrorr@   r0   rA   marks     r   rP   rQ   |   s.    LL 8 !?$!FGGr   c                ,    [        U R                  5      $ r   )lenr-   rO   s    r   __len__bmstore.__len__   s    4<<  r   c                ,    [        U R                  5      $ r   )iterr-   rO   s    r   __iter__bmstore.__iter__   s    DLL!!r   c                6    U R                   R                  5       $ r   r-   itemsrO   s    r   	iteritemsbmstore.iteritems       ||!!##r   c                6    U R                   R                  5       $ r   r_   rO   s    r   r`   bmstore.items   rc   r   c                6    U R                   R                  5       $ r   )r-   keysrO   s    r   rg   bmstore.keys   s    ||  ""r   c                6    U R                   R                  5       $ r   )r-   valuesrO   s    r   rj   bmstore.values   s    ||""$$r   c                    XR                   ;   $ r   r-   rT   s     r   __contains__bmstore.__contains__   s    ||##r   c                     U R                   U   $ r   rm   rT   s     r   __getitem__bmstore.__getitem__   s    ||D!!r   Nc                8    U R                   R                  X5      $ r   )r-   r7   )rA   rU   defaults      r   r7   bmstore.get   s    ||..r   c                   SU l         XR                  ;   a  U R                  U5        X R                  U'   U R                  R	                  U5      nUc  U/U R                  U'   g UR                  U5        UR                  5         g )NF)r/   r-   _delr.   r7   r8   r9   rA   rU   rI   rJ   s       r   _setbmstore._set   sh    <<IIdO!T!!$'=#'&DMM$LLJJLr   c                    XR                   ;  a  g SU l        U R                   R                  U5      nU R                  U   n[	        U5      S:X  a  US   U:X  d   eU R                  U	 g UR                  U5        g )NFr   r   )r-   r/   popr.   rW   removerx   s       r   rw   bmstore._del   sm    ||#||%d#u:?8t###d#LLr   c                :    U R                   R                  U/ 5      $ )z@Return a sorted list of bookmarks pointing to the specified node)r.   r7   )rA   rI   s     r   namesbmstore.names   s    }}  r**r   c                :   UR                   R                  S5      nU Hi  u  pVU R                  R                  U5      nUc  U R                  U5        OU R	                  XV5        Uc  MK  UR                  U5      nUb  US   nXv4XE'   Mk     U R                  U5        g)z$Apply a list of changes to bookmarksr    Nr   )changesr7   r-   rw   ry   _recordchange)	rA   r   trr   	bmchangesnamerI   oldpreviouss	            r   applychangesbmstore.applychanges   s    JJNN<0	!JD,,""4(C|		$		$%$$==.'"1+C#&+	 " 	2r   c                    [        U R                  5      (       a  SOSnUR                  SSU R                  USS9  SUR                  S'   g	)
z|record that bookmarks have been changed in a transaction

The transaction is then responsible for updating the file content.r   s   plainr    )r    T)locationpost_finalize   1s   bookmark_movedN)r   r,   addfilegenerator_writehookargs)rA   r   r   s      r   r   bmstore._recordchange   sP     +4::663H
KK 	 	
 *.%&r   c                   UR                   nUR                  U R                  ;  a  SUl        UR                  5         [	        U5      (       a  UR
                  nUR                  5       nOUR                  nUR                  5       nU   U" SSSSS9 nU R                  U5        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)zFactored out for extensibilityNr       wT
atomictemp
checkambig)

_bookmarksrP   r-   _writeactiver   r   lockr   wlockr   )rA   r   rbmr   r   fs         r   
_writerepobmstore._writerepo   s    oo::T\\)CJD!!))C99;D((C::<D\4DTJaA K TJJ Ts$   	
CB6%C6
C	 C
Cc                   U R                   (       a  g U R                  R                  5          U R                  bU  U R                  R	                  SSSSS9 nUR                  [        R                  " U R                  5      5        S S S 5        O%U R                  R                  R                  S5        S S S 5        SU l         g ! , (       d  f       N= f! , (       d  f       N'= f)N   bookmarks.currentr   Tr   )	r0   r,   r   r@   r   writer	   	fromlocal	tryunlink)rA   r   s     r   r   bmstore._writeactive   s    <<ZZ||'ZZ^^($4D $ GGH..t||<= 
 

(()=>      s#   *C0C.C
C	C
C$c                   [        U R                  R                  5       5       H8  u  p#UR                  S[	        U5      [
        R                  " U5      4-  5        M:     SU l        U R                  R                  5         g )Ns   %s %s
T)
sortedr-   r`   r   r   r	   r   r/   r,   invalidatevolatilesets)rA   r#   r   rI   s       r   r   bmstore._write   s\     !3!3!56JDHHZ3t9h.@.@.F"GGH 7

))+r   c                    US:X  a<  U R                   (       a  U R                   $ [        R                  " [        S5      5      eU$ )N   .s   no active bookmark)rP   r
   RepoLookupErrorr   )rA   bnames     r   
expandnamebmstore.expandname  s6    D={{{{"++A.C,DEEr   c                6   U R                   S   R                  5       nXR                  ;   Ga  U(       Gd  U(       Ga  U R                  U   U:X  a  X4:X  a  / $ U R                   U   R                  5       nU R                   R                  R                  U/5      nU R                   X      nU R                   Vs/ s H@  nUR                  SS5      S   UR                  SS5      S   :X  d  M1  U R                  U   PMB     n	nUR                  5       U;  a  X9;   a  [        U R                   U/U5      $ U	 Vs/ s H,  oR                   U   R                  5       U;   d  X:X  d  M*  UPM.     n
n[        U R                   X5      n[        U R                   XpR                   U   5      (       aL  U R                   R                  R                  [        S5      U[        UR                  5       5      4-  5        U$ [        R                  " [        S5      U-  5      eXR                   R                  5       ;   d'  XR                   R                   R#                  5       :X  a&  U(       d  [        R                  " [        S5      5      e[%        U5      S:  aa  U(       dZ   [&        R(                  " U R                   U5      nU(       a1  U R                   R                  R-                  [        S
5      U-  5        / $ s  snf s  snf ! [        R*                   a    S	n N\f = f)aT  check 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.
r      @r   r   s%   moving bookmark '%s' forward from %s
s.   bookmark '%s' already exists (use -f to force)s5   a bookmark cannot have the name of an existing branch   Fs[   bookmark %s matches a changeset hash
(did you leave a -r out of an 'hg bookmark' command?)
)r,   rI   r-   revr1   	ancestorsr5   divergent2delete	validdestr;   statusr   r   r
   Abort	branchmapdirstatebranchrW   r   isrevsymbolLookupErrorr<   )rA   rU   forcetargetcurr   ancbmctxbdivs
deletefromdelbms
shadowhashs                r   checkconflictbmstore.checkconflict	  s    jj##%<<<<%/FMIjj(,,.jj**44cU;

4:. "\\)wwtQ'*djjq.A!.DD $DLLO)   99;c)fn+DJJ$GG  $#!zz!}'8'8':c'AQ[At   *$**jGTZZ

60BCCJJMM((CDuzz|!456 "M++CDtK  JJ((**zz**1133++JK  t9q=#$00TB
 

""'
  	]. $$ #"
#s*   :0K5.K58)K:%K:!K? ?LL)r0   r@   r/   r.   r-   r,   r   )FN)__name__
__module____qualname____firstlineno____doc__rL   propertyrP   setterrX   r\   ra   r`   rg   rj   rn   rq   r7   ry   rw   r   r   r   r   r   r   r   r   __static_attributes__ r   r   r'   r'   =   s    +/Z   ]] !"$$#
%$"/

+".",Cr   r'   c                    U R                   R                  S5      n[        R                  " [        R
                  " U5      5      nUS:X  d  X1;  a  SnU$ )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
r   r   N)r   tryreadr	   r6   r   	firstline)r   markscontentrU   s       r   r?   r?   O  sJ     hh34GJ009:Ds{d'Kr   c                X    XR                   l        U R                   R                  5         g)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
Nr   rP   r   r   rU   s     r   activater   ^  s     "OOOO  "r   c                Z    SU R                   l        U R                   R                  5         g)z/
Unset the active bookmark in this repository.
Nr   r   s    r   
deactivater   h  s      "DOOOO  "r   c                    U R                   nU R                  nU S   R                  5        Vs/ s H  o3R                  5       PM     nnX;   =(       a    X!   U;   $ s  snf )ah  
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`.
N)_activebookmarkr   parentsrI   )r   rU   r   pr   s        r   isactivewdirparentr   p  sX     DOOE!%d!3!3!56!5Avvx!5G6=3U[G33 7s   Ac                .   / nU R                   nU Vs/ s H2  oUR                  SS5      S   UR                  SS5      S   :X  d  M0  UPM4     nnU H<  nUS:X  d  SU;  a  M  U(       d  M  XG   U;   d  M$  Xr:w  d  M+  UR                  U5        M>     U$ s  snf )zVfind divergent versions of bm on nodes in deletefrom.

the list of bookmark to delete.r   r   r   )r   r5   r8   )r   r   bmtodeleter   r   	divergentrU   s           r   r   r     s     HOOEaGGD!,Q/288D!3DQ3GG5   4<4t+4EK:-z%  Os   /BBc                   U R                   (       d  [        S5      eU R                   R                  SS5      S   n/ nU R                  R	                  5        H1  u  p4UR                  SS5      S   U:X  d  M   UR                  U5        M3     U$ )aV  Given 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.
s9   headsforactive() only makes sense with an active bookmarkr   r   r   )r   r:   r5   r   r`   r8   )r   r   headsrU   ns        r   headsforactiver     s     H
 	
 %%dA.q1DE??((*::dAq!T)LLO + Lr   c                    Su  p#UR                   n[        U5      (       a  US   R                  5       nX#4$ U(       a  U R                  [	        S5      U-  5        UnX#4$ )zReturn a tuple (activemark, movemarkfrom) indicating the active bookmark
and where to move the active bookmark from, if needed.)NNr   s   updating to active bookmark %s
)r   r   rI   r   r   )r;   r   checkoutmovemarkfrom
activemarks        r   calculateupdater     sg     (H%%J$Dz( ## 

		!78:EF##r   c                r   UnU R                   nUR                  nU(       d  g/ nXE   U;   a  X   nU Vs/ s H8  nUR                  SS5      S   UR                  SS5      S   :X  d  M1  XU      PM:     n	nU R                  R	                  UR                  5       /5      n
U	 Vs/ s H-  oR                  5       U
;   d  X:X  d  M  UR                  5       PM/     nn[        X XE      U5      (       a   UR                  XWR                  5       45        [        XU5       H  nUR                  US 45        M     U(       aE  U R                  5          U R                  S5       nUR                  XU5        S S S 5        S S S 5        [        U5      $ s  snf s  snf ! , (       d  f       N+= f! , (       d  f       N4= f)NFr   r   r      bookmark)r   rP   r5   r1   r   r   rI   r   r8   r   r   transactionr   bool)r   r   rI   r   r   rP   r   newr   r   r   r   r   s                r   updater     st   JOOE\\FI}j 
wwtQ"fll4&;A&>> DqN 	 

 nn&&	{3(,K13!(haffh
KT.44fhhj12t8"d$ 9 YY[$**;72t3 8[	?!
 L 87[[s;   0F)F$FFF(F2F(
F%	!F((
F6c                F    SU ;   =(       a    U R                  S5      (       + $ )Nr   )endswith)r   s    r   isdivergentr     s    19-QZZ---r   c              #     #    [        U S0 5      nU R                  R                  nUR                  5        H+  u  p4U" U5      (       d  M  [	        U5      (       a  M&  X44v   M-     g 7f)Nr   )getattrr1   hasnoder`   r   )r   r   r   kvs        r   listbinbookmarksr     sN      D,+Enn$$G1::k!nn$J s   AA&
A&
A&c                L    0 n[        U 5       H  u  p#[        U5      X'   M     U$ r   )r   r   )r   dbookrI   s       r   listbookmarksr    s(    
A&t,
d) -Hr   c           	        [        U5      (       a  g[        U 5      (       a  [        R                  " 5       nOU R	                  5       nU   U R                  5          U R                  S5       nU R                  n[        UR                  US5      5      nXr:w  a  Xs:w  a   S S S 5        S S S 5        S S S 5        gUS:X  a  US 4/nO4X0;  a   S S S 5        S S S 5        S S S 5        gXU   R                  5       4/nUR                  XU5         S S S 5        S S S 5        S S S 5        g! , (       d  f       O= fS S S 5        O! , (       d  f       O= fS S S 5        g ! , (       d  f       g = f)NFr    r   T)r   r   r   nullcontextmanagerr   r   r   r   r   r7   rI   r   )	r   keyr   r   r   r   r   existingr   s	            r   pushbookmarkr    s    3'')

			T--l;ruyyc*+?x	 <
 #:T{mG < #Y^^-./G4W- <;;sf   
ED?-3D% D?(E9D%D?E$(D%D?E%
D3/D?6	E?
E		E
E'c                v   U(       a  [        U5      nO[        U5      n[        U5      nXV-  n/ / / / / / / / 4nUS   R                  nUS   R                  n	US   R                  n
US   R                  nUS   R                  nUS   R                  nUS   R                  nUS   R                  n[        U5       H  nUU;  a#  UU;   a  U	" US	UU   45        M  U" US	S	45        M,  UU;  a  U" UUU   S	45        MB  UU   nUU   nUU:X  a  U" UUU45        M_  UU ;   a  UU ;   a  U U   nU U   nUR                  5       UR                  5       :  a,  [	        U UU5      (       a  U" UUU45        M  U" UUU45        M  [	        U UU5      (       a  U
" UUU45        M  U" UUU45        M  U" UUU45        M     U$ )
aC  Compare 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.
r   r      r               N)setr8   r   r   r   )r   srcmarksdstmarkstargetsbset
srcmarkset
dstmarksetresultsaddsrcadddstadvsrcadvdstdivergedifferinvalidsamer   sciddcidsctxdctxs                        r   comparebookmarksr#    s   4 7|]
]
&2r2r2r2.GQZFQZFQZFQZFajGQZFajG1:DD\HH}4!-.D$(hAx{D)*A;DA;Dt|at_%$$,DzDz88:
* tT224/D$0 tT224/D$0 4'9 < Nr   c                   US:X  a  SnUR                  S5      (       a   [        R                  " U5      R                  n[        R                  " U 5       HT  u  pVUR
                  nUR                  S5      (       a   [        R                  " U5      R                  nX':X  d  MN  SX4-  s  $    [        SS5       H  nSX4-  n	X;  d
  X9   U:X  d  M  U	s  $    g)	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``.
r   r   s   file:s   %s@%sr   d   s   %s@%dN)
startswithr   urlpath
list_pathsrawlocrange)
r;   r   r(  
localmarks
remotenoder   r   locxr   s
             r   _diverger0  M  s     	Dy x  {{4 %%%%b)hh>>(##++c"''C;qi'' * 1c]v*-:"=H 
 r   c                V    0 nU R                  5        H  u  p#[        U5      X'   M     U$ r   )r`   r   )r   binremotemarksr   rI   s       r   unhexlifybookmarksr3  l  s+    Nkkm
"4y $r   s   >20sHc           	         / nU Ha  u  p4U(       d  U R                   R                  nUR                  [        R	                  U[        U5      5      5        UR                  U5        Mc     SR                  U5      $ )aQ  encode a '(bookmark, node)' iterable into a binary stream

the binary format is:

    <node><bookmark-length><bookmark-name>

:node: is a 20 bytes binary node,
:bookmark-length: an unsigned short,
:bookmark-name: the name of the bookmark (of length <bookmark-length>)

wdirid (all bits set) will be used as a special value for "missing"
r   )nodeconstantswdiridr8   _binaryentrypackrW   join)r   	bookmarks
binarydatar  rI   s        r   binaryencoder<  v  sg     J
%%,,D,++D#d)<=$	  
 88Jr   c                   [         R                  n/ n UR                  U5      n[        U5      U:  a)  U(       a  [        R
                  " [        S5      5      e U$ [         R                  U5      u  pVUR                  U5      n[        U5      U:  a&  U(       a  [        R
                  " [        S5      5      eXPR                  R                  :X  a  SnUR                  Xu45        M  )aS  decode a binary stream into an '(bookmark, node)' iterable

the binary format is:

    <node><bookmark-length><bookmark-name>

:node: is a 20 bytes binary node,
:bookmark-length: an unsigned short,
:bookmark-name: the name of the bookmark (of length <bookmark-length>))

wdirid (all bits set) will be used as a special value for "missing"
s   bad bookmark streamN)r7  sizereadrW   r
   r   r   unpackr5  r6  r8   )r   stream	entrysizebooksentryrI   lengthbookmarks           r   binarydecoderG    s     !!IE
I&u:	!kk!$:";<< L $**51;;v&x=6!kk!$:";<<%%,,,Dh%& r   c           	     Z   / nUR                   nUR                  5        HM  u  pVXdR                  US5      :w  d  M  Xa;   d  M#  UR                  XVU R                  [        S5      U-  45        MO     U H5  nXR;  d  M
  UR                  USU R                  [        S5      U-  45        M7     U$ )zIcomputes the bookmark changes that set the local bookmarks to
remotemarksN   updating bookmark %s
s   removing bookmark %s
)r   r`   r7   r8   debugr   )r;   r   remotemarkschangedr,  r   ids          r   mirroring_remoterN    s     GJ""$4((RZNNA288Q/H-IA-MNO % NND"((A&?$@1$DE 
 Nr   c           	        UR                   n[        XU5      u  nnnn	n
nnnU R                  nU R                  nU R	                  SS5      (       a  U R
                  =p[        U5      n/ nU Ht  u  nnnUU;   a#  UR                  UUU[        S5      U-  45        M0  UU;   d  M8  UR                  U5        U R                  [        S5      U[        U5      SS 4-  5        Mv     U H(  u  nnnUR                  UUU[        S5      U-  45        M*     UR                  S U 5       5        U
 H  u  nnnUU;   a4  UR                  U5        UR                  UUU[        S	5      U-  45        MA  [        U UX5U5      nU(       a%  UR                  UUU[        S
5      UU4-  45        M{  U" [        S5      U-  5        M     Xy-    HA  u  nnnUU;   d  M  UR                  U5        UR                  UUU[        S	5      U-  45        MC     U HK  u  nnnUU;   d  M  UR                  U5        U R                  [        S5      U[        U5      SS 4-  5        MM     U$ )zmcomputes the bookmark changes that merge remote bookmarks into the
local bookmarks, based on comparebookmarkss   uis   quietbookmarkmoves   adding remote bookmark %s
s0   remote bookmark %s points to locally missing %s
N   rI  c              3  *   #    U  H	  oS    v   M     g7f)r   Nr   ).0r  s     r   	<genexpr>&merging_from_remote.<locals>.<genexpr>  s     5WtWs   s   importing bookmark %s
s#   divergent bookmark %s stored as %s
sA   warning: failed to assign numbered name to divergent bookmark %s
)r   r#  r   r<   
configboolrJ  r  r8   r   r}   r   difference_updatediscardr0  )r;   r   rK  r(  explicitr,  r  r  r  r  r  r  r  r  r   r<   rL  r   r  r   dbs                        r   merging_from_remoterZ    s    J 	J7	 YYF77D	}}U011 8}HG44<NND&!$B"Ca"GH (]OOAGGFGc$in%&    44+D)E)IJK   5W55 4=QNNAtVQ/I-JQ-NOP"a48BABaWL	 6 	! !.  4=QNNAtVQ/I-JQ-NOP )  4=OOAGGFGc$in%&   Nr   c                .   US:X  a  g U R                  S5        US:X  a  [        XU5      nO[        XX#U5      nU(       aV  U" 5       n/ n	S n
[        XzS9 H   u  ppU	R	                  X45        U" U5        M"     UR
                  R                  XU	5        g g )N   ignores   checking for updated bookmarks
   mirrorc                (    U S   U S   =(       d    S4$ )Nr   r   r   r   )ts    r   <lambda>"updatefromremote.<locals>.<lambda>  s    1qt{s+r   )r  )rJ  rN  rZ  r   r8   r   r   )r;   r   rK  r(  trfuncrX  moderL  r   r   r  r   rI   writermsgs                  r   updatefromremoterf    s     yHH01y"2[9%b8LX+$*7$< AVNNA9%3K %= 	$$Tw7 r   c                  ^^ US:X  a  U R                  [        S5      5        gU R                  [        S5      5        UR                  5        n[        UR	                  SSS05      R                  5       5      nSSS5        / mU R                  (       a  S	 mOS
 mU R                  (       a  UU4S jnOUU4S jnUS:X  a  UR                  n[        WR                  5       5      [        UR                  5       5      -  n[        U5       H  n	UR                  U	5      n
UR                  U	5      nX:X  a  M,  U
c  U" U	[        U5      [        S5      5        MM  Uc(  U" U	[        UR                  5      [        S5      5        Mx  U" U	[        U5      [        S5      5        M     O[        UWUR                  5      nUu  pnnnnnnU H#  u  n	nnU" U	[        U5      [        S5      5        M%     U H#  u  n	nnU" U	[        U5      [        S5      5        M%     U H#  u  n	nnU" U	[        U5      [        S5      5        M%     U H#  u  n	nnU" U	[        U5      [        S5      5        M%     T(       d  U R                  [        S5      5        g[        T5       H  nU R!                  U5        M     g! , (       d  f       GN== f)z*Show bookmarks incoming from other to repor\  s+   bookmarks exchange disabled with this path
r       searching for changed bookmarks
   listkeys	   namespacer    Nc                    U $ r   r   rM  s    r   r`  incoming.<locals>.<lambda>1      2r   c                    U S S $ NrP  r   rl  s    r   r`  rm  3  
    2cr7r   c                @   > TR                  SU T" U5      U4-  5        g Ns      %-25s %s %s
r8   r   rM  stgetid	incomingss      r   addincoming.<locals>.add6  "    0AuRy"3EEFr   c                >   > TR                  SU T" U5      4-  5        g Ns      %-25s %s
rt  ru  s      r   ry  rz  ;      -E"I>?r   r]     addeds   removed   changed   advanced   diverged   no changed bookmarks found
r   )r   r   commandexecutorr3  callcommandresult	debugflagverboser   r  rg   r   r7   r   nullidr#  r   )r;   r   peerrc  erK  ry  r,  allmarksr   r.  remrr  r  r  r  r  r  r  r  r  r   srw  rx  s                           @@r   incomingr    sR   y
		!CDEIIa456				1(MM ,
 fh
 
  I	||"	zz	G
	@ y__
{'')*S1B-CC!A..#C//!$CzAs3x8-As4;;':7As3x:/ " T;@IJF$#MAtT3t9ak* $ $MAtT3t9an- $ %MAtT3t9an- % $MAtT3t9a
m, $ 
		!345I
   
 	s   ,J00
J?c                &  ^^ U R                  [        S5      5        [        UR                  S5      5      n[	        XR
                  U5      nUu  pVpxpp/ mU R                  (       a  S mOS mU R                  (       a  UU4S jnOUU4S jnU H"  u  pnU" U[        U5      [        S5      5        M$     U H  u  pnU" US[        S	5      5        M     U H"  u  pnU" U[        U5      [        S
5      5        M$     U	 H"  u  pnU" U[        U5      [        S5      5        M$     U
 H"  u  pnU" U[        U5      [        S5      5        M$     T(       d  U R                  [        S5      5        g[        T5       H  nU R                  U5        M     g)z*Show bookmarks outgoing from repo to otherrh  r    c                    U $ r   r   rl  s    r   r`  outgoing.<locals>.<lambda>q  rn  r   c                    U S S $ rp  r   rl  s    r   r`  r  s  rq  r   c                @   > TR                  SU T" U5      U4-  5        g rs  rt  r   rM  rv  rw  	outgoingss      r   ry  outgoing.<locals>.addv  r{  r   c                >   > TR                  SU T" U5      4-  5        g r}  rt  r  s      r   ry  r  {  r~  r   r  s(                                           s   deletedr  r  r  r  r   r   )r   r   r3  listkeysr#  r   r  r  r   r   r   )r;   r   otherrK  r  r  r  r  r  r  r  r  r  ry  r   r  r   r  rw  r  s                     @@r   outgoingr  g  sX   IIa456$U^^L%ABK<AEFBFFGWI	||"	zz	G
	@  As4y!H+&    Ay!J-(    As4y!K.)   !As4y!K.) !  As4y!J-(   
		!345I
  r   c                   UR                  5        n[        UR                  SSS05      R                  5       5      nSSS5        [	        U WU R
                  5      nUu  pVpxpp[        U5      [        U5      4$ ! , (       d  f       NB= f)zwCompare bookmarks between repo and other for "hg summary" output

This returns "(# of incoming, # of outgoing)" tuple.
ri  rj  r    N)r  r3  r  r  r#  r   rW   )r   r  r  rK  r  r  r  r  r  r  r  r  r  s                r   summaryr    s    
 
			1(MM ,
 fh
 
  	{DOO<AEFBFFGWKV%% 
 	s   ,A99
Bc                    U R                  5       n X:X  a  gU(       d  gU R                  (       a6  UR                  5       [        R                  " XR                  5       /5      ;   $ UR                  U5      $ )z?Is the new bookmark destination a valid update from the old oneFT)
unfilteredobsstorerI   r   
foregroundisancestorof)r   r   r   s      r   r   r     s\    ??D
z 	xxzW//xxzlCCC $$r   c                    UR                  5       nU(       d  [        R                  " [        S5      5      e[        R
                  " XS5        U$ )znreturn a valid version of a potential bookmark name

Raises an abort error if the bookmark name is not valid.
s4   bookmark names cannot consist entirely of whitespacer   )r4   r
   
InputErrorr   r   checknewlabelr   s     r   checkformatr    sE    
 ::<DEF
 	
 $k2Kr   c                    U R                   n/ nU HW  nXS;  a"  [        R                  " [        S5      U-  5      eXPR                  :X  a  [        U 5        UR                  US45        MY     UR                  XU5        g)zUremove a mark from the bookmark store

Raises an abort error if mark does not exist.
   bookmark '%s' does not existN)r   r
   r  r   r   r   r8   r   )r   r   r   r   r   rU   s         r   deleter    st    
 OOEG""1%D#E#LMM'''td|$  
t)r   c                x   U R                   n[        X5      nX&;  a"  [        R                  " [	        S5      U-  5      e/ nUR                  Xt5       H  n	UR                  U	S45        M     UR                  XvU   4US4/5        UR                  XU5        U R                  U:X  a  U(       d  [        X5        ggg)zrename a bookmark from old to new

If force is specified, then the new name can overwrite an existing
bookmark.

If inactive is specified, then do not activate the new bookmark.

Raises an abort error if old is not in the bookmark store.
r  N)r   r  r
   r  r   r   r8   extendr   r   r   )
r   r   r   r   r   inactiver   rU   r   r   s
             r   renamer    s     OOEt!D
q!@ACGHHG!!$.Dz" /NNT:&d45	t)s"8 ,4"r   c                Z   U R                   nU S   R                  5       nSn/ n	U(       a  [        R                  " X/S5      n [        R                  " XS5      n
U(       + =(       a    U
R                  5       SL nU
R                  5       c  U
R                  5       n
U
R                  5       nU(       d   eU Ht  n[        X5      nUc  UnU(       a  XR                  :X  a  [        U 5        M6  UR                  XU5       H  nU	R                  US45        M     U	R                  X45        Mv     U	(       d  gU
R                  5       (       a  U R                  R                  [        S5      U
R!                  5       SS -  5        U
R#                  5       (       aF  [$        R&                  " X
R!                  5       SS U
5      nU R                  R                  SU-  5        UR)                  XU	5        U(       a  XvU   :X  a  [+        X5        gX|:w  a  XR                  :X  a  [        U 5        ggg)a  add a list of bookmarks

If force is specified, then the new name can overwrite an existing
bookmark.

If inactive is specified, then do not activate any bookmark. Otherwise, the
first bookmark is activated.

Raises an abort error if old is not in the bookmark store.
r   Ns   nowarns    bookmarking hidden changeset %s
rP  s   (%s)
)r   rI   r   unhidehashlikerevs	revsingler   p1r  r   r   r   r8   hiddenr;   r<   r   r   obsoleter   _getfilteredreasonr   r   )r   r   r   r   r   r  r   r   newactr   ctxactivatenewtgtrU   r   re  s                   r   addbookmarksr    s    OOE
t*//
CFG ))$yA


Dt
,C,43779#4K
xxzffh
((*CJ34&>F 4 44t%%d37BNNB:& 8{#  
zz||Q;<swwy"~MN<<>>,,T779Sb>3GCGGLLS)	t)sFm+	"6"664 7r   c           
        UR                   n[        U5      S:X  a/  UR                  5       (       a  U R                  [	        S5      5        [        UR                  5       5       H  u  nu  pgnUR                  5         UR                  US9  U R                  (       d  UR                  SU-  US9  UR                  SSXXS9  SS	[        R                  " U5      -
  -  n	UR                  U R                  (       + S
U	S-   UR                  R!                  U5      U" U5      US9  UR#                  [$        U;   S9  UR                  S5        M     g)zprivate method to print bookmarks

Provides a way for extensions to control how bookmarks are printed (e.g.
prepend or postpend names)
r   s   no bookmarks set
r   s    %s )labelr   s   %sr*      s   rev nodes    %d:%s)rP      
N)hexfuncrW   isplainr   r   r   r`   	startitemcontextquietplainr   r	   colwidth	condwriter1   r   dataactivebookmarklabel)
r;   r   fmbmarkshexfnbmarkr   prefixr  pads
             r   _printbookmarksr  +  s    JJE
6{aBJJLL
		!)*+%+FLLN%;!!5




xxHHWv%UH3
eU8b8,,U334
L)ONNq!!H 	 	
 	+u46
! &<r   c                    UR                   n0 nU=(       d    U HO  nXd;  a"  [        R                  " [        S5      U-  5      eUR                  nXg:X  a  S[
        pOSu  pXF   X4XV'   MQ     [        XX%5        g)zlprint bookmarks by the given formatter

Provides a way for extensions to control how bookmarks are printed.
r     *)r*   r   N)r   r
   r  r   r   r  r  )
r;   r   r  r   r   r  r  rP   r  r  s
             r   printbookmarksr  G  s}    
 OOEF%""1%D#E#MNN%%? "5E%MFv5   Bb)r   c                F    Uc  SnUc  SnU [        U5      [        U5      S.$ )Nr   )r   s   nodes   oldnode)r   )r   r   r   s      r   preparehookargsr  [  s+    
{
{Cc#hGGr   r   )r   )r   N)FF)NFF);
__future__r   structi18nr   rI   r   r   r    r	   r
   r   r   r   r   r   r   utilsr   r   r  r   r   r%   r'   r?   r   r   r   r   r   r   r   r   r   r  r  r#  r0  r3  Structr7  r<  rG  rN  rZ  rf  r  r  r  r   r  r  r  r  r  r  r  r   r   r   <module>r     s   #   
	 	 	 < L=
O Od##4&0
$:.	,IX> }}X& ,@ IZ <@8,FR.b&(%"* .6r8*(Hr   