a
    %0_
                     @   s   d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZmZ i ZeeZdZejZejZddg eded	fgZed
ee e edejdddd ZdS )z5close arbitrary heads without checking them out first    )absolute_import)_)	bookmarkscmdutilcontexterrorpycompat	registrarscmutils   ships-with-hg-core   r   revs   revision to checks   REVs   close-head|close-headss   [OPTION]... [REV]...T)ZhelpcategoryZ	inferrepoc           	   	      sN   fdd}t |tdg 7 }t|}|sNttdg }	 D ]}|
| qZfdd|D }|D ]}||vrttd| qt| sttdd	d
i  d  : |D ]$}| }| }| d< || qW d   n1 s 0    Y  W d   n1 s@0    Y  dS )a	  close the given head revisions

    This is equivalent to checking out each revision in a clean tree and running
    ``hg commit --close-branch``, except that it doesn't change the working
    directory.

    The commit message must be specified with -l or -m.
    c              
      sh   t j| d gg d dd d}d}|d}t| d g| || |  d S )Ns   users   date)parentstextfilesZ	filectxfnuserdateextras   commitT)	r   ZmemctxgetZtransactionZ	commitctxr   updateZmarkcommittedclose)revZcctxZtrZretr   messageoptsrepo 1/usr/lib/python3/dist-packages/hgext/closehead.pydocommit3   s    


zclose_branch.<locals>.docommitr   s   no revisions specifiedc                    s   h | ]} |   qS r   )r   ).0h)r   r   r   	<setcomp>O       zclose_branch.<locals>.<setcomp>s    revision is not an open head: %ds)   no commit message specified with -l or -ms   close   1s   branchNr   )r   Zbyteskwargstupler   r
   Zrevranger   ZAbortr   Z	branchmapextendZbranchheadsr   Z
logmessageZwlocklockbranch)	Zuir   Zrevsr   r   Zheadsr&   r   rr   r   r   close_branch"   s0    
Jr(   N)__doc__Z
__future__r   Zmercurial.i18nr   Z	mercurialr   r   r   r   r   r	   r
   ZcmdtableZcommandZ
testedwithZ
commitoptsZcommitopts2Zcommitopts3ZCATEGORY_CHANGE_MANAGEMENTr(   r   r   r   r   <module>   s"   $


