3
_Af                 @   sX   d dl mZ 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dS )	    )print_function)defaultdictN)Command)git)Progressc               @   s0   e Zd ZdZdZdZdd Zdd Zdd	 Zd
S )AbandonTz(Permanently abandon a development branchz
%prog [--all | <branchname>] [<project>...]

This subcommand permanently abandons a development branch by
deleting it (and all its history) from your local repository.

It is equivalent to "git branch -D <branchname>".
c             C   s*   |j dddddd |j dddd	d
 d S )Nz-qz--quiet
store_trueFzbe quiet)actiondefaulthelpz--allallz#delete all branches in all projects)destr	   r   )
add_option)selfp r   A/home/qytech/356xLinux510-101server/.repo/repo/subcmds/abandon.py_Options'   s    zAbandon._Optionsc             C   sT   |j  r| r| j  |j sD|d }tjd| sP| jjd|  n|jdd d S )Nr   zheads/%sz'%s' is not a valid branch namez'All local branches')r   Usager   check_ref_formatOptionParsererrorinsert)r   optargsnbr   r   r   ValidateOptions/   s    zAbandon.ValidateOptionsc             C   s  |d }t t}t t}| j|dd  }td| t|}xt|D ]l}|j  |jrft|j j }	n|g}	x@|	D ]8}
|j	|
}|d k	rr|r||
 j
| qr||
 j
| qrW qBW |j  d}x |	D ]}
|t|
k rt|
}qW |rNxZ|j D ]N}d| }t|tjd x2|| D ]&}tdt| d|j  tjd qW qW tjd n|srtd	| tjd tjd n|jr~d S td
 x|j D ]v}t|dkrt|t|| krd}n(ddd|  d jdd || D  }td|d|t|  |f  qW d S )Nr      z
Abandon %s   zerror: cannot abandon %s)file z | %sz+error: no project has local branch(es) : %szAbandoned branches:zall projectz%s
z| c             s   s   | ]}|j V  qd S )N)relpath).0r   r   r   r   	<genexpr>l   s    z"Abandon.Execute.<locals>.<genexpr>z	%s%s| %s
)r   listGetProjectsr   lenupdater   GetBrancheskeysAbandonBranchappendendprintsysstderrr"   exitquietjoin)r   r   r   r   errsuccessall_projectspmprojectbranchesnamestatuswidthbrerr_msgprojresultr   r   r   Execute:   sR    



*
$&zAbandon.ExecuteN)	__name__
__module____qualname__commonhelpSummary	helpUsager   r   rA   r   r   r   r   r      s   r   )
__future__r   collectionsr   r/   commandr   git_commandr   progressr   r   r   r   r   r   <module>   s   