
TVc           @@  s   d  d l  m Z d d l m Z d d l m Z m Z m Z d   Z d   Z	 d   Z
 d   Z d	 d
 d g Z i e	 d	 6e
 d
 6e d 6Z e e d  Z d   Z d   Z d   Z d Z d   Z d S(   i    (   t   absolute_importi   (   t   _(   t	   bookmarkst   errort   obsoletec   
      C@  s   |  d } | j   } | s | j   |  j j | g d t k r | j d t  } t j |  | j	   g  } |  | j	   | k r | r t
 d  } t
 d  }	 t j | d |	  q | s t
 d  } t
 d  }	 t j | d |	  q q q n  d S(	   s|   validate that the destination comply to various rules

    This exists as its own function to help wrapping from extensions.t	   inclusivet   missings   uncommitted changess6   commit and merge, or update --clean to discard changest   hints   not a linear updates'   merge or update --check to force updateN(   t   Nonet   p1t   revt	   changelogt	   ancestorst   Truet   dirtyR   t
   foregroundt   nodeR   R   t   UpdateAbort(
   t   repoR
   t   cleant   checkt   wcR	   R   R   t   msgR   (    (    s6   /usr/lib/python2.7/dist-packages/mercurial/destutil.pyt   _destupdatevalidate   s    
'c   
      C@  s   d } |  d } | j   } d } | j   r | j   r t j |  | j    } | r g  | D] } | D] }	 |	 ^ qj q` } |  j d |  j   } t j	 |   r |  d j   } q q n  | | d f S(   s9   decide of an update destination from obsolescence markerss   max(%ln)t   .N(
   R   R	   R   t   childrent   successorssetsR   t   revst   firstR   t   isactivewdirparent(
   R   R   R   R   R   R	   t   movemarkt
   successorst   subt   n(    (    s6   /usr/lib/python2.7/dist-packages/mercurial/destutil.pyt   _destupdateobs-   s    
&c         C@  sF   d } t j |  j |  d  \ } } | d k	 r9 | } n  | | | f S(   s4   decide on an update destination from active bookmarkN(   R   R   t   calculateupdatet   ui(   R   R   R   t
   activemarkR   R   (    (    s6   /usr/lib/python2.7/dist-packages/mercurial/destutil.pyt   _destupdatebookQ   s
    	c         C@  s   |  d } d } } y; |  j | j    } t j |   rN |  d j   } n  WnW t j k
 r | j   d k r |  j d  } q t j	 t
 d  | j     n X| | d f S(   s3   decide on an update destination from current branchR   t   defaultt   tips   branch %s not foundN(   R   t	   branchtipt   branchR   R   R   R   t   RepoLookupErrort   lookupt   AbortR   (   R   R   R   R   R   R   (    (    s6   /usr/lib/python2.7/dist-packages/mercurial/destutil.pyt   _destupdatebranchZ   s    

#t	   evolutiont   bookmarkR*   c         C@  s~   d } } } x= t D]5 } t | |  | |  \ } } } | d k	 r Pq q W|  | j   } t |  | | |  | | | f S(   s"  destination for bare update operation

    return (rev, movemark, activemark)

    - rev: the revision to update to,
    - movemark: node to move the active bookmark from
                (cf bookmark.calculate update),
    - activemark: a bookmark to activate at the end of the update.
    N(   R   t   destupdatestepst   destupdatestepmapR
   R   (   R   R   R   R   R   R%   t   stepR
   (    (    s6   /usr/lib/python2.7/dist-packages/mercurial/destutil.pyt
   destupdater   s    
c         C@  s   d } |  j |  j  } |  |  j j   } t |  d k rg | | d k rZ | d } q | d } nl t |  d k r t j t d  d t d   n6 t |  d k r t j t d  d t d   n  | d k	 s t  | S(	   s2   find merge destination in the active bookmark casei   i    i   sT   multiple matching bookmarks to merge - please merge with an explicit rev or bookmarkR   s   run 'hg heads' to see all headssM   no matching bookmark to merge - please merge with an explicit rev or bookmarkN(	   R   t   bookmarkheadst   _activebookmarkR   t   lenR   R-   R   t   AssertionError(   R   R   t   bmheadst   curhead(    (    s6   /usr/lib/python2.7/dist-packages/mercurial/destutil.pyt   _destmergebook   s    c   	      C@  s  d } |  d j   } |  j |  } g  | D] } |  | j   s, | ^ q, } t |  d k r t j t d  | t |  f d t d   n  |  j j	   } t |  d k rzt |  d k r t j t d  d t d   n  t |  j
    d k r+t j t d  | d t d   n  t d	  d } } | |  j |  k rbt d
  } n  t j | d |  n  | | k rt j t d  d t d   n  | | d k r| d } n
 | d } | d k	 st  | S(   s,   find merge destination based on branch headsi   s<   branch '%s' has %d heads - please merge with an explicit revR   s   run 'hg heads .' to see headsi   s8   heads are bookmarked - please merge with an explicit revs   run 'hg heads' to see all headss<   branch '%s' has one head - please merge with an explicit revs   nothing to merges   use 'hg update' insteads(   working directory not at a head revisions2   use 'hg update' or merge with an explicit revisioni    iN(   R   R*   t   branchheadsR   R7   R   R-   R   t   dirstateR	   t   headsR,   R8   (	   R   R   R*   t   bheadst   bht   nbhst   parentR   R   (    (    s6   /usr/lib/python2.7/dist-packages/mercurial/destutil.pyt   _destmergebranch   s:    )
c         C@  s2   |  j  r t |   } n t |   } |  | j   S(   N(   R6   R;   RC   R
   (   R   R   (    (    s6   /usr/lib/python2.7/dist-packages/mercurial/destutil.pyt	   destmerge   s    	s3   reverse(only(.) and not public() and not ::merge())c         C@  sa   d d l  m } |  j d d t  } | r] | j | | g  } | r] | j   | j   Sn  d S(   s0   Default base revision to edit for `hg histedit`.i   (   t   scmutilt   histeditt
   defaultrevN(   t    RE   t   configt   histeditdefaultrevsett   revranget   sortR   R   (   R$   R   RE   R'   R   (    (    s6   /usr/lib/python2.7/dist-packages/mercurial/destutil.pyt   desthistedit   s    
N(   t
   __future__R    t   i18nR   RH   R   R   R   R   R"   R&   R.   R1   R2   t   FalseR4   R;   RC   RD   RJ   RM   (    (    (    s6   /usr/lib/python2.7/dist-packages/mercurial/destutil.pyt   <module>   s    		$			

		(	