ó
Èä9Sc        
   @   s  d  Z  d d l Z d d l m Z d d l m Z d d l m Z d d l m	 Z	 d d l
 m Z d Z d	 Z d
 g Z d Z e	 j e	 j e	 j ƒ g Z e d d d e	 j g d d d d ƒe d d d e	 j g d d d d ƒg Z e j ƒ  Z d „  Z d „  Z d S(   s¦  
Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
iÿÿÿÿN(   t   opt(   t   common(   t   transaction(   t   argparse(   t   outs   Move patches between branchest   patchs4   DEST_BRANCH <patch1> [<patch2>] [<patch3>..<patch4>]sY   
Delete the given patches from the current branch, and add them unapplied to
DEST_BRANCH.s   -fs   --fromt   argst   destt   srct   shorts   Move from branch BRANCHs   -ts   --tos   Move to branch BRANCHc         C   s€   |  | k rx |  j  d ƒ \ } } } | s5 | j r> |  } n  x; t j ƒ  D]& } d | | f } | | k rK | SqK Wn |  Sd  S(   Nt   -s   %s-%d(   t
   rpartitiont   isdigitt	   itertoolst   count(   t   oldnamet	   blacklistt   baset   dasht   numt   it   name(    (    s0   /disk1/sandberg/git/stgit/stgit/commands/move.pyt   find_unique_name,   s    	c            sÔ  t  j j | j ƒ ‰ t  j j | j ƒ } | j r< d ‰  n ˆ j j ‰  t | ƒ sd |  j d ƒ n  t	 j
 | t ˆ j j ƒ t ˆ j j ƒ ƒ ‰ ‡  ‡ f d †  } t j ˆ d d | ƒ} g  ˆ D]! } | ˆ j j | ƒ j f ^ qÂ } y= | j ‡ f d †  ƒ } x | D] }	 | j |	 ˆ  ƒ qWWn! t j k
 rIt j d ƒ n~ Xxz | D]r \ }
 } t |
 t | j j ƒ ƒ }
 | j j |
 | d ƒ } |
 f | j j | j _ t j d |
 | j f ƒ qQW| j ˆ  ƒ S(	   s   Move patches between branches.s   No patch specifiedc            sL   ˆ  d  k r t Sˆ j j r@ |  j o? |  j d ˆ j j d k S|  j Sd  S(   Niÿÿÿÿ(   t   Nonet   Falset
   patchordert   applied(   t   trans(   t   iwR   (    s0   /disk1/sandberg/git/stgit/stgit/commands/move.pyt   allow_conflictsH   s    	t   moveR   c            s
   |  ˆ  k S(   N(    (   t   pn(   t   patches(    s0   /disk1/sandberg/git/stgit/stgit/commands/move.pyt   <lambda>V   s    s!   conflicts, everything rolled backs   Created %s on branch %sN(   t	   directoryt
   repositoryt	   get_stackR   R   R   t
   default_iwt   lent   errorR   t   parse_patchest   listR   t   allR   R   t   StackTransactionR    t   gett   committ   delete_patchest
   push_patcht   TransactionHaltedR   t   infoR   t   sett   newt	   unappliedR   t   run(   t   parsert   optionsR   R   R   R   t   nt   commitst   to_pushR   R   R-   t   newpatch(    (   R   R    R   s0   /disk1/sandberg/git/stgit/stgit/commands/move.pyt   func9   s2    		
	.(   t   __copyright__R   t   stgit.argparseR    t   stgit.commandsR   t	   stgit.libR   t   stgitR   t	   stgit.outR   t   helpt   kindt   usaget   descriptiont   patch_ranget   applied_patchest   unapplied_patchesR   t   stg_branchesR7   t   DirectoryHasRepositoryLibR"   R   R<   (    (    (    s0   /disk1/sandberg/git/stgit/stgit/commands/move.pyt   <module>   s&   		