
    q&f                         d Z ddlmZ ddlmZmZmZmZmZ dZ	i Z
 ej                  e
      Z ee	ddg        ee	dd        ee	d	d
       i Z ej                  e      Zd Zd Z	 ddZd Zd ZddZd Zd Zy)a?  implements bookmark-based branching (EXPERIMENTAL)

 - Disables creation of new branches (config: enable_branches=False).
 - Requires an active bookmark on commit (config: require_bookmark=True).
 - Doesn't move the active bookmark on update, only on commit.
 - Requires '--rev' for moving an existing bookmark.
 - Protects special bookmarks (config: protect=@).

 flow related commands

    :hg book NAME: create a new bookmark
    :hg book NAME -r REV: move bookmark to revision (fast-forward)
    :hg up|co NAME: switch to bookmark
    :hg push -B .: push active bookmark
    )_)	bookmarkscommandserror
extensions	registrars   bookflow   protect   @   require-bookmarkT   enable-branchesFc                    |j                   j                  }|rr|| j                  t        d      v r!t	        j
                  t        d      |z        t        ||      s,t	        j
                  t        d      t        d      |z        y	| j                  t        dd      rt	        j
                  t        d            y	)
Nr	   s'   cannot commit, bookmark %s is protectedsA   cannot commit, working directory out of sync with active bookmarks   run 'hg up %s'hintr   Ts(   cannot commit without an active bookmarkr   )	
_bookmarksactive
configlistMY_NAMEr   Abortr   cwd_at_bookmark
configbool)uirepokwargsr   s       0/usr/lib/python3/dist-packages/hgext/bookflow.pycommit_hookr   '   s    __##FR]]7J77++<=F  tV,++X ()F2	   
w 3T	:kk!GHII    c                 4    t        |      dk(  r
 | |||      S y)N   F)len)origr   parentsnodes       r   bookmarks_updater#   :   s"    
7|qD'4(( r   Nc                     |s8|j                   }|D ]'  }||v st        j                  t        d      |z          | ||||||      S )Ns8   bookmark %s already exists, to move use the --rev option)r   r   r   r   )	r    r   trnamesrevforceinactivemarksnames	            r   bookmarks_addbookmarksr,   C   sc      	Du}kkS  	 b%eX66r   c                 4    t        ||        | ||g|i |S N)r   )r    r   r   argsoptss        r   commands_commitr1   S   s#    DD(4(4((r   c                      | ||g|i |}|j                   j                  }|r)t        ||      s|j                  t	        d      |z         |S )NsB   working directory out of sync with active bookmark, run 'hg up %s')r   r   r   warnr   )r    r   r   r/   r0   rcr   s          r   commands_pullr5   X   s]    	b$	&	&	&B__##FodF3
 		
 Ir   c                     |rB|j                  d      s1|j                  d      s t        j                  t        d      d       | |||fi |S )Ncleanr'   s@   creating named branches is disabled and you should use bookmarkss   see 'hg help bookflow'r   )getr   r   r   )r    r   r   labelr0   s        r   commands_branchr:   f   sQ    TXXg&txxkkS +	
 	
 D%(4((r   c                 L    | j                   |   }| j                  d      }||k(  S )N   .)r   lookup)r   markmark_idcur_ids       r   r   r   q   s)    ood#G[[FWr   c                    t        j                  t        dt               t        j                  t        dt               t        j
                  t        j                  dt               t        j
                  t        j                  dt               | j                  t        d      s*t        j
                  t        j                  dt               y y )Nupdateaddbookmarkss   commits   pullr   s   branch)r   wrapfunctionr   r#   r,   wrapcommandr   tabler1   r5   r   r   r:   )r   s    r   uisetuprG   w   s~    Ix1ABI~7MN8>>9oF8>>7MB=="45x~~y/J 6r   )NFFr.   )__doc__mercurial.i18nr   	mercurialr   r   r   r   r   r   configtable
configitemcmdtablecommandr   r#   r,   r1   r5   r:   r   rG    r   r   <module>rP      s       !Y!!+.
 
7J ' 
7' . 
7& .
)

H
%& <A7 )
)Kr   