3
_Af                 @   sH   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S )	    )PagedCommand)Coloring)R_Mc               @   s   e Zd Zdd ZdS )	_Coloringc             C   s   t j| |d d S )Nstatus)r   __init__)selfconfig r
   >/home/qytech/356xLinux510-101server/.repo/repo/subcmds/info.pyr      s    z_Coloring.__init__N)__name__
__module____qualname__r   r
   r
   r
   r   r      s   r   c               @   sH   e Zd ZdZdZdZdd Zdd Zdd	 Zd
d Z	dd Z
dd ZdS )InfoTzDGet info on the manifest branch, current branch or unmerged branchesz$%prog [-dl] [-o [-b]] [<project>...]c             C   sT   |j dddddd |j ddd	dd
d |j dddddd |j dddddd d S )Nz-dz--diffall
store_truez8show full info and commit diff including remote branches)destactionhelpz-oz
--overviewoverviewz"show overview of all local commitsz-bz--current-branchcurrent_branchz"consider only checked out branchesz-lz--local-onlylocalzDisable all remote operations)
add_option)r   pr
   r
   r   _Options    s    zInfo._Optionsc             C   s4  t | jj| _| jjddd| _| jjddd| _| jjddd| _| jjd	dd| _	| jjd
| _
| jjddd| _|| _| jjj}|jdj}|jdpd}| jd | jjjr| j| jjj | jj  | jd | j| | jj  | jd | j| | jj  | j  |js&| j| n
| j| d S )Nheadingbold)attrheadtextyellow)fgredtextredshatextdimtextdimdefaultzmanifest.groupszall,-notdefaultzManifest branch: zManifest merge branch: zManifest groups: )r   manifestglobalConfigoutprinterr   nofmt_printerr   r!   r#   r$   r%   optmanifestProjectr	   	GetBranchmerge	GetStringr'   revisionExprnlprintSeparatorr   printDiffInfoprintCommitOverview)r   r-   argsZmanifestConfigZmergeBranchZmanifestGroupsr
   r
   r   Execute.   s4    










zInfo.Executec             C   s   | j d | jj  d S )Nz----------------------------)r$   r*   r3   )r   r
   r
   r   r4   P   s    
zInfo.printSeparatorc             C   sF  | j |}x4|D ]*}| jd | j|j | jj  | jd | j|j | jj  | jd | j|j  | jj  |j}|r| jd | j| | jj  | jd | j|j	 | jj  t
|j j }| jd | jtt| |r| jd | jdj| | jd	 | jj  | jjr6| j| | j  qW d S )
Nz	Project: zMount path: zCurrent revision: zCurrent branch: zManifest revision: zLocal Branches: z [z, ])GetProjectsr   r   namer*   r3   worktreeGetRevisionIdCurrentBranchr2   listGetBrancheskeysr!   strlenr$   joinr-   r   findRemoteLocalDiffr4   )r   r7   Zprojsr   ZcurrentBranchZlocalBranchesr
   r
   r   r5   T   s<    

















zInfo.printDiffInfoc             C   sl  | j js|jddd t| jjjjdj }|j	j
}d|j	_
|j	jddd|d d	}|j	jdddd| d	}||j	_
| jd
 | jtt| | jd | jj  xH|D ]@}|j }| j|d d  | jdj|dd   | jj  qW | j  | jd | jtt| | jj  xJ|D ]B}|j }| j|d d  | jdj|dd   | jj  q"W d S )NT)quietcurrent_branch_onlyr'   Fz
--abbrev=8z--abbrev-commitz--pretty=onelinez..z--zLocal Commits: z (on current branch)r       zRemote Commits: )r-   r   Sync_NetworkHalfr   r(   r.   r	   r/   r0   bare_git_barerev_listr   r!   rB   rC   r%   r*   r3   splitr#   r$   rD   r4   )r   projectZ	logTargetZbareTmpZlocalCommitsZoriginCommitscrN   r
   r
   r   rE   }   sH    






zInfo.findRemoteLocalDiffc       	         st  g }xZ| j |D ]L  fdd j D }dd |D }| jjrR fdd|D }|j| qW |shd S | jj  | jd d  x|D ]} |jkr|j | jj  | j	 j
 | jj  |j}|j}| jd|j jkrdpd|jt|t|d	krd
pd|f  | jj  x\|D ]T}|j }| jdjdd | j|d d  | jdj|d	d   | jj  qW qW d S )Nc                s   g | ]} j |qS r
   )GetUploadableBranch).0x)rO   r
   r   
<listcomp>   s   z,Info.printCommitOverview.<locals>.<listcomp>c             S   s   g | ]}|r|qS r
   r
   )rR   rS   r
   r
   r   rT      s    c                s   g | ]}|j  jkr|qS r
   )r;   r>   )rR   rS   )rO   r
   r   rT      s    zProjects Overviewz%s %-33s (%2d commit%s, %s)*rH   rI   s z
{0:38}{1} -r   )r:   r@   r-   r   extendr*   r3   r   rO   r   relpathcommitsdater$   r;   r>   rC   rN   formatr#   rD   )	r   r7   all_branchesbrbranchr[   r\   commitrN   r
   )rO   r   r6      sD    









zInfo.printCommitOverviewN)r   r   r   commonhelpSummary	helpUsager   r8   r4   r5   rE   r6   r
   r
   r
   r   r      s   ")/r   N)commandr   colorr   git_refsr   r   r   r
   r
   r
   r   <module>   s   