3
_Af#                 @   st   d dl mZ d dlZd dlZd dlmZ d dlmZ 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dS )
    )print_functionN)Command)IsImmutable)git)Progress)
SyncBufferc               @   s4   e Zd ZdZdZdZdZdd Zdd Zd	d
 Z	dS )StartTz"Start a new branch for developmentz.
%prog <newbranchname> [--all | <project>...]
zc
'%prog' begins a new branch of development, starting from the
revision specified in the manifest.
c             C   s>   |j ddddd |j dddd	d
d |j dd	dddd d S )Nz--allall
store_truezbegin branch in all projects)destactionhelpz-rz--revz
--revisionrevisionz1point branch at this revision instead of upstream)r   r   z--headstore_constHEADzabbreviation for --rev HEAD)r   r   constr   )
add_option)selfp r   ?/home/qytech/356xLinux510-101server/.repo/repo/subcmds/start.py_Options(   s    zStart._Optionsc             C   s6   |s| j   |d }tjd| s2| jjd|  d S )Nr   zheads/%sz'%s' is not a valid name)Usager   Zcheck_ref_formatOptionParsererror)r   optargsnbr   r   r   ValidateOptions1   s
    zStart.ValidateOptionsc             C   s  |d }g }g }|j s4|dd  }t|dk r4dg}| j|t| jd}| jr| j|| jdd}x.|D ]&}|jrxd|_nd|_|j|_d |_qfW tj	| j t
jjt
j st
j| jj td| t|}	x|D ]}|	j  | jrV| jj|j }
|
jsVt
jj| jj|j}||_t
jj|s.t
j| |j  t| jjj}|j| |
j|_d	}t|jr|j rv|j }n
| jj!j}|j"|||j#d
s|j$| qW |	j%  |rx&|D ]}t&d|j|f t'j(d qW t'j)d d S )Nr      .)
missing_okT)manifestr!   FzStarting %s )branch_merger   zerror: %s/: cannot start %s)file)*r	   lenGetProjectsboolgitc_manifestZold_revisionZalready_syncedrevisionExpr
gitc_utilsZsave_manifestospathexistsgetcwdchdirr"   topdirr   updatepathsrelpathjoinZgitc_client_dirworktreemakedirsZSync_NetworkHalfr   manifestProjectconfigZSync_LocalHalfZ
revisionIdr   Zdest_branchdefaultZStartBranchr   appendendprintsysstderrexit)r   r   r   r   errprojectsZall_projectsZgitc_projectsprojectZpmZgitc_projectZproj_localdirZsync_bufr$   r   r   r   r   Execute9   sd    







zStart.ExecuteN)
__name__
__module____qualname__commonhelpSummary	helpUsagehelpDescriptionr   r   rD   r   r   r   r   r      s   	r   )
__future__r   r,   r>   commandr   
git_configr   git_commandr   r+   Zprogressr   rC   r   r   r   r   r   r   <module>   s   