ó
ĊZc           @   s0   d  Z  d d l m Z d e f d     YZ d S(   sŬ  For performing many refactorings as a single command

`changestack` module can be used to perform many refactorings on top
of each other as one bigger command.  It can be used like::

  stack = ChangeStack(project, 'my big command')

  #..
  stack.push(refactoring1.get_changes())
  #..
  stack.push(refactoring2.get_changes())
  #..
  stack.push(refactoringX.get_changes())

  stack.pop_all()
  changes = stack.merged()

Now `changes` can be previewed or performed as before.
i˙˙˙˙(   t   changet   ChangeStackc           B   s8   e  Z d  d  Z d   Z d   Z d   Z d   Z RS(   s   merged changesc         C   s   | |  _  | |  _ g  |  _ d  S(   N(   t   projectt   descriptiont   stack(   t   selfR   R   (    (    s7   lib/python2.7/site-packages/rope/contrib/changestack.pyt   __init__   s    		c         C   s$   |  j  j |  |  j j |  d  S(   N(   R   t   appendR   t   do(   R   t   changes(    (    s7   lib/python2.7/site-packages/rope/contrib/changestack.pyt   push   s    c         C   s:   x3 t  t |  j   D] } |  j j j d t  q Wd  S(   Nt   drop(   t   ranget   lenR   R   t   historyt   undot   True(   R   t   i(    (    s7   lib/python2.7/site-packages/rope/contrib/changestack.pyt   pop_all#   s    c         C   sQ   t  j |  j  } x8 |  j D]- } x$ |  j |  D] } | j |  q2 Wq W| S(   N(   R    t	   ChangeSetR   R   t   _basic_changest
   add_change(   R   t   resultR	   t   c(    (    s7   lib/python2.7/site-packages/rope/contrib/changestack.pyt   merged'   s
    c         c   sQ   t  | t j  rH x8 | j D]% } x |  j |  D] } | Vq2 Wq Wn | Vd  S(   N(   t
   isinstanceR    R   R	   R   (   R   R	   t   childt   atom(    (    s7   lib/python2.7/site-packages/rope/contrib/changestack.pyR   .   s
    (   t   __name__t
   __module__R   R
   R   R   R   (    (    (    s7   lib/python2.7/site-packages/rope/contrib/changestack.pyR      s
   			N(   t   __doc__t	   rope.baseR    t   objectR   (    (    (    s7   lib/python2.7/site-packages/rope/contrib/changestack.pyt   <module>   s   