3
_Af                 @   s`   d dl mZ d dlZd dlmZ d dlmZ G dd deZG dd deZ	G d	d
 d
eZ
dS )    )print_functionN)Coloring)Commandc               @   s   e Zd Zdd ZdS )BranchColoringc             C   s>   t j| |d | jddd| _| jd| _| jddd| _d S )Nbranchcurrentgreen)fglocalnotinprojectred)r   __init__printerr   r
   r   )selfconfig r   B/home/qytech/356xLinux510-101server/.repo/repo/subcmds/branches.pyr      s    zBranchColoring.__init__N)__name__
__module____qualname__r   r   r   r   r   r      s   r   c               @   sL   e Zd Zdd Zdd Zedd Zedd Zed	d
 Zedd Z	dS )
BranchInfoc             C   s"   || _ d| _d| _d| _g | _d S )Nr   )namer   	publishedpublished_equalprojects)r   r   r   r   r   r       s
    zBranchInfo.__init__c             C   sR   |j r|  j d7  _ |jr(|  jd7  _|j|jkrB|  jd7  _| jj| d S )N   )r   r   revisionr   r   append)r   br   r   r   add'   s    zBranchInfo.addc             C   s
   | j dkS )Nr   )r   )r   r   r   r   	IsCurrent0   s    zBranchInfo.IsCurrentc             C   s   | j dko| j t| jkS )Nr   )r   lenr   )r   r   r   r   IsSplitCurrent4   s    zBranchInfo.IsSplitCurrentc             C   s
   | j dkS )Nr   )r   )r   r   r   r   IsPublished8   s    zBranchInfo.IsPublishedc             C   s   | j t| jkS )N)r   r!   r   )r   r   r   r   IsPublishedEqual<   s    zBranchInfo.IsPublishedEqualN)
r   r   r   r   r   propertyr    r"   r#   r$   r   r   r   r   r      s   	r   c               @   s    e Zd ZdZdZdZdd ZdS )BranchesTzView current topic branchesa  
%prog [<project>...]

Summarizes the currently available topic branches.

# Branch Display

The branch display output by this command is organized into four
columns of information; for example:

 *P nocolor                   | in repo
    repo2                     |

The first column contains a * if the branch is the currently
checked out branch in any of the specified projects, or a blank
if no project has the branch checked out.

The second column contains either blank, p or P, depending upon
the upload status of the branch.

 (blank): branch not yet published by repo upload
       P: all commits were published by repo upload
       p: only some commits were published by repo upload

The third column contains the branch name.

The fourth column (after the | separator) lists the projects that
the branch appears in, or does not appear in.  If no project list
is shown, then the branch appears in all projects.

c             C   s  | j |}t| jjj}i }t|}xN|D ]F}x@|j j D ]0\}}	||	_||kr^t	|||< || j
|	 q<W q*W tt|}
|
stdtjd d S d}x |
D ]}|t|k rt|}qW x$|
D ]}|| }t|j}|jrd}|j}n
d}|j}|jrd}n|jrd}nd}|d||||f  |jd	 ||k r|j}g }g }|jsd||| k rd
}x|jD ]6}	|j s|	jr|j|	jj n|j|	jj qpW nT|j}d}t }x|jD ]}	|j
|	j qW x$|D ]}||kr|j|j qW d|dj|f }|j rN|d t| dk rN|jr@|jn|}|| n~|d|  |jrh|jn|j}x*|D ]"}|j  ||d d|   qtW |j}x6|D ]"}|j  ||d d|   qW n
|jd |j  qW d S )Nz   (no branches))file   * Ppz	%c%c %-*sz |inznot inz %s %sz,    P   z %s:z          %sz in all projects)GetProjectsr   manifestmanifestProjectr   r!   GetBranchesitemsprojectr   r   listsortedprintsysstderrr   r    r   r
   r$   r#   writer"   r   relpathr   setjoinnl)r   optargsr   outall_branchesZproject_cntr5   r   r   nameswidthiZin_cntr   hdrr   fmtpathsZnon_cur_pathsZin_typeZhaver,   sr   r   r   Executed   s    







 



zBranches.ExecuteN)r   r   r   commonhelpSummary	helpUsagerK   r   r   r   r   r&   A   s   r&   )
__future__r   r9   colorr   commandr   r   objectr   r&   r   r   r   r   <module>   s   "