3
_Af                 @   sd   d dl mZ d dlZd dlmZ d dlmZ d dlmZ G dd deZ	G dd	 d	eZ
d
d ZdS )    )print_functionN)Coloring)InteractiveCommand)
GitCommandc               @   s   e Zd Zdd ZdS )_ProjectListc             C   sF   t j| |d | jdddd| _| jddd| _| jdd	dd| _d S )
Ninteractivepromptbluebold)fgattrheader)r   helpred)r   __init__printerr   r   r   )selfgc r   ?/home/qytech/356xLinux510-101server/.repo/repo/subcmds/stage.pyr      s    z_ProjectList.__init__N)__name__
__module____qualname__r   r   r   r   r   r      s   r   c               @   s4   e Zd ZdZdZdZdZdd Zdd Zd	d
 Z	dS )StageTzStage file(s) for commitz
%prog -i [<project>...]
z>
The '%prog' command stages files to prepare the next commit.
c             C   s   |j dddddd d S )Nz-iz--interactiver   
store_truezuse interactive staging)destactionr   )
add_option)r   pr   r   r   _Options+   s    zStage._Optionsc             C   s    |j r| j|| n| j  d S )N)r   _InteractiveUsage)r   optargsr   r   r   Execute0   s    zStage.Executec       	         s  dd | j |D }|s*tdtjd d S t| jjj}x|jdd |j	  x<t
t|D ],}|| }|jd|d |jd	  |j	  q^W |j	  |jd
d |jd |jd |j	  |jd ytjj  W n tk
r   |j	  P Y nX  dkr
|j	  P  j   j dkr"P  s*q<yt }W n tk
rP   d }Y nX |d k	r|dkrhP d|k r|t|krt||d   q< fdd|D }t|dkr<t|d  q<q<W td d S )Nc             S   s   g | ]}|j  r|qS r   )IsDirty).0r   r   r   r   
<listcomp>7   s    z&Stage._Interactive.<locals>.<listcomp>z*no projects have uncommitted modifications)filez
        %sprojectz
%3d:    %s   /z%3d: (r   qzuit)z	project>  quitexitc                s    g | ]} |j |jgkr|qS r   )namerelpath)r&   r   )ar   r   r'   h   s    zBye.)r,   r.   r/   )GetProjectsprintsysstderrr   manifestmanifestProjectconfigr   nlrangelenwriter1   r   stdinreadlineKeyboardInterruptstriplowerint
ValueError_AddI)	r   r"   r#   all_projectsoutir)   Za_indexprojectsr   )r2   r   r    6   s\    






zStage._InteractiveN)
r   r   r   commonhelpSummary	helpUsagehelpDescriptionr   r$   r    r   r   r   r   r   !   s   r   c             C   s   t | ddgdd}|j  d S )Naddz--interactiveF)bare)r   Wait)r)   r   r   r   r   rE   o   s    rE   )
__future__r   r5   colorr   commandr   git_commandr   r   r   rE   r   r   r   r   <module>   s   N